it('should edit decision id', inject(function(viewer) {

    // given
    const editor = queryEditor('.decision-id', testContainer);

    editor.focus();

    // when
    triggerInputEvent(editor, 'foo');

    // then
    expect(viewer.getDecision().id).to.equal('foo');
  }));
Exemple #2
0
  function openDescriptionEditor(elementId) {
    const cellEl = domQuery(`[data-element-id="${ elementId }"]`, testContainer);

    expect(cellEl).to.exist;

    triggerClick(cellEl);

    const editorEl = queryEditor('.description-editor', testContainer);

    expect(editorEl).to.exist;

    return editorEl;
  }
      it('accept if valid', inject(function(sheet) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        // when
        triggerInputEvent(id, 'bar');

        // then
        const root = sheet.getRoot();

        expect(root.businessObject.$parent.id).to.equal('bar');
      }));
    it('should edit name', inject(function(sheet) {

      // given
      const name = queryEditor('.decision-table-name', testContainer);

      name.focus();

      // when
      triggerInputEvent(name, 'foo');

      // then
      const root = sheet.getRoot();

      expect(root.businessObject.$parent.name).to.equal('foo');
    }));
      it('undo edit', inject(function(sheet, commandStack) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        triggerInputEvent(id, 'bar');

        // when
        commandStack.undo();

        // then
        expect(id.textContent).to.equal('decision');
      }));
  it('should validate decision id', inject(function(viewer) {

    // given
    const decisionId = domQuery('.decision-id', testContainer);
    const editor = queryEditor('.decision-id', testContainer);

    editor.focus();

    // when
    triggerInputEvent(editor, 'foo bar');

    // then
    expect(viewer.getDecision().id).to.equal('season');

    expect(domClasses(decisionId).has('invalid')).to.be.true;
  }));
      it('reject if invalid', inject(function(sheet) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        // when
        triggerInputEvent(id, '!foo');

        // then
        const root = sheet.getRoot();

        expect(root.businessObject.$parent.id).to.equal('decision');
        expect(domClasses(id.parentNode).has('invalid')).to.be.true;
      }));
  it('should edit annotation', inject(function(sheet) {

    // given
    const cell = queryEditor('td.annotation', testContainer);

    // when
    cell.focus();

    triggerInputEvent(cell, 'foo');

    // then
    const root = sheet.getRoot();

    const rule = root.businessObject.rule[0];

    expect(rule.description).to.equal('foo');
  }));