Skip to content

Commit

Permalink
test: add cases for undo/redo
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul99ahad committed Aug 30, 2024
1 parent 760ba19 commit e222864
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,70 @@ describe('NameChangeBehavior', function() {
],
}));

describe('should update variable name when element name is changed', function() {

it('should update variable name when element name is changed', inject(
function(modeling, sheet) {

// given
const root = sheet.getRoot(),
decisionTable = root.businessObject;
it('<do>', inject(
function(modeling, sheet) {

const decision = decisionTable.$parent;
// given
const root = sheet.getRoot(),
decisionTable = root.businessObject;

// when
modeling.editDecisionTableName('foo');
const decision = decisionTable.$parent;

// then
const variable = decision.get('variable');
// when
modeling.editDecisionTableName('foo');

expect(variable.get('name')).to.equal('foo');
}
));
// then
const variable = decision.get('variable');

expect(variable.get('name')).to.equal('foo');
}
));


it('<undo>', inject(
function(modeling, sheet, commandStack) {

// given
const root = sheet.getRoot(),
decisionTable = root.businessObject;

const decision = decisionTable.$parent;
modeling.editDecisionTableName('foo');

// when
commandStack.undo();

// then
const variable = decision.get('variable');

expect(variable.get('name')).to.equal('Season');
}
));


it('<redo>', inject(
function(modeling, sheet, commandStack) {

// given
const root = sheet.getRoot(),
decisionTable = root.businessObject;

const decision = decisionTable.$parent;
modeling.editDecisionTableName('foo');

// when
commandStack.undo();
commandStack.redo();

// then
const variable = decision.get('variable');

expect(variable.get('name')).to.equal('foo');
}
));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,57 @@ describe('NameChangeBehavior', function() {
],
}));

describe('should update variable name when label is changed', function() {

it('should update variable name when label is changed', inject(
function(modeling, elementRegistry) {

it('<do>', inject(
function(modeling, elementRegistry) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;

// when
modeling.updateLabel(decision,'foo');

// then
expect(variable.get('name')).to.equal('foo');
}
));


it('<undo>', inject(function(modeling, elementRegistry, commandStack) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateLabel(decision,'foo');

// when
commandStack.undo();

// then
expect(variable.get('name')).to.equal('season');
}));


it('<redo>', inject(function(modeling, elementRegistry, commandStack) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateLabel(decision,'foo');

// when
commandStack.undo();
commandStack.redo();

// then
expect(variable.get('name')).to.equal('foo');
}
));
}));
});
});
});

0 comments on commit e222864

Please sign in to comment.