diff --git a/packages/main/tests/test.feature b/packages/main/tests/test.feature index 13ea126..c24d874 100644 --- a/packages/main/tests/test.feature +++ b/packages/main/tests/test.feature @@ -102,6 +102,33 @@ Feature: Basic Test | 5 | 8 | 13 | | 8 | 13 | 21 | | 13 | 21 | 34 | + + Scenario Outline: DataTables row: + Given the following datatable: + | Product | Quantity | + | | | + | | | + Then datatable should contain "" + + Examples: + | Row | Product1 | Qty1 | Product2 | Qty2 | + | 0 | Widget A | 2 | Widget B | 3 | + | 1 | Widget C | 1 | Widget D | 4 | + + Scenario Outline: DocStrings row: + And the following json: + """ + { + "": "", + "": "" + } + """ + Then json should contain "" + + Examples: + | Row | Product1 | Qty1 | Product2 | Qty2 | + | 0 | Widget A | 2 | Widget B | 3 | + | 1 | Widget C | 1 | Widget D | 4 | Rule: Vitest "todo", "skip", "fails" should work out of the box diff --git a/packages/main/tests/tests.steps.ts b/packages/main/tests/tests.steps.ts index 4a2880c..9389d0a 100644 --- a/packages/main/tests/tests.steps.ts +++ b/packages/main/tests/tests.steps.ts @@ -25,6 +25,10 @@ Given('(I have )a number {int}', (world, int) => { else world.numbers.push(int) }) +Given("the following datatable:", (world, datatable: DataTable) => { + world.datatable = datatable; +}) + Given('the following numbers:', (world, numbers:DataTable) => { world.numbers = numbers.raw().map(n => parseInt(n[0][0])) }) @@ -45,6 +49,21 @@ Then('the sum should be {int}', (world, int) => { expect(world.numbers.reduce((a,b) => a + b, 0)).toBe(int) }) +Then("datatable should contain {string}", (world, value) => { + const values = world.datatable + .rows() + .reduce((prev, curr) => [...curr, ...prev], []); + expect(values.includes(value)).toBe(true); +}); + +Then("json should contain {string}", (world, value) => { + const values = [ + ...Object.keys(world.json), + ...(Object.values(world.json) as string[]).map((v) => v.toString()), + ]; + expect(values.includes(value)).toBe(true); +}); + When('I set the data variable/value/property {string} to {string}', (world, prop, value) => { if (!world.data) world.data = {} set(world.data, prop, value)