Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should not display anything if verbose turned off even if duplicate row found', () => {
const compiler = new RemoveDuplicates({
processRows: true,
verbose: false
});
const examples = new Examples();
const row = new TableRow();
row.cells.push(new TableCell('hello'));
row.cells.push(new TableCell('world'));
examples.body.push(row);
examples.body.push(row.clone());
compiler._filterRows(examples, {}, {});
expect(console.log.called, 'console.log is called').to.be.false;
expect(console.warn.called, 'console.warn is called').to.be.false;
})
});
it('should not display anything if verbose turned off even if duplicate row found', () => {
const compiler = new RemoveDuplicates({
processRows: true,
verbose: false
});
const examples = new Examples();
const row = new TableRow();
row.cells.push(new TableCell('hello'));
row.cells.push(new TableCell('world'));
examples.body.push(row);
examples.body.push(row.clone());
compiler._filterRows(examples, {}, {});
expect(console.log.called, 'console.log is called').to.be.false;
expect(console.warn.called, 'console.warn is called').to.be.false;
})
});
it('should not display anything if verbose turned off even if duplicate row found', () => {
const compiler = new RemoveDuplicates({
processRows: true,
verbose: false
});
const examples = new Examples();
const row = new TableRow();
row.cells.push(new TableCell('hello'));
row.cells.push(new TableCell('world'));
examples.body.push(row);
examples.body.push(row.clone());
compiler._filterRows(examples, {}, {});
expect(console.log.called, 'console.log is called').to.be.false;
expect(console.warn.called, 'console.warn is called').to.be.false;
})
});
it('should remove tag if presents on parent', () => {
const compiler = new RemoveDuplicates();
const element = {tags: [new Tag('@onFeature')]};
const parent = {tags: [new Tag('@onFeature')]};
compiler._filterTags(element, parent);
expect(element.tags).to.have.length(0);
expect(parent.tags).to.have.length(1);
});
it('should process macro steps', () => {
const scenario_macro = new Scenario();
const tag = new Tag('@macro(test)');
const step_macro = new Step('When', 'test step');
const step_test = new Step('And', 'macro test is executed');
scenario_macro.tags.push(tag);
scenario_macro.steps.push(step_macro);
macro.preFilterScenario(scenario_macro);
expect(macro.onStep(step_test)).to.eql(scenario_macro.steps);
});
it('should return the correct iterator', () => {
const loop = new ForLoop();
const scenario = new Scenario('Scenario', 'Scenario name');
const tag = new Tag('@loop(4)');
scenario.tags.push(tag);
expect(loop.getIterationNumber(scenario)).to.eql(4);
});
});
it('should throw an error when provided iterator exceeds maximum', () => {
const loop = new ForLoop();
const scenario = new Scenario('Scenario', 'Scenario name');
const tag = new Tag('@loop(42)');
scenario.tags.push(tag);
expect(() => loop.getIterationNumber(scenario)).to.throw(Error);
});
it('should not filter out non macro scenarios', () => {
const scenario = new Scenario();
const tag = new Tag('@notmacro');
scenario.tags.push(tag);
expect(macro.preFilterScenario(scenario)).to.be.undefined;
});
it('should not remove unique tags', () => {
const compiler = new RemoveDuplicates();
const element = {tags: [new Tag('@duplicate'), new Tag('@notDuplicate')]};
const parent = {tags: []};
compiler._filterTags(element, parent);
expect(element.tags).to.have.length(2);
expect(element.tags[0].name).to.equal('@duplicate');
expect(element.tags[1].name).to.equal('@notDuplicate');
});
it('should not remove unique tag if not present on parent', () => {
const compiler = new RemoveDuplicates();
const element = {tags: [new Tag('@onScenario')]};
const parent = {tags: [new Tag('@onFeature')]};
compiler._filterTags(element, parent);
expect(element.tags).to.have.length(1);
expect(element.tags[0].name).to.equal('@onScenario');
});