|
1 |
| -import { Query as GherkinQuery } from '@cucumber/gherkin-utils' |
2 |
| -import * as messages from '@cucumber/messages' |
3 |
| -import { Query as CucumberQuery } from '@cucumber/query' |
4 |
| -import { expect } from 'chai' |
5 |
| -import React from 'react' |
6 |
| - |
7 |
| -import { render } from '../../../test-utils/index.js' |
8 |
| -import { GherkinStep } from './GherkinStep.js' |
9 |
| - |
10 |
| -describe('<GherkinStep>', () => { |
11 |
| - it('renders', () => { |
12 |
| - const step: messages.Step = { |
13 |
| - keyword: 'Given', |
14 |
| - text: 'the 48 pixies', |
15 |
| - location: { column: 1, line: 1 }, |
16 |
| - id: '123', |
17 |
| - } |
18 |
| - |
19 |
| - class StubCucumberQuery extends CucumberQuery { |
20 |
| - public getStepMatchArgumentsLists(): messages.StepMatchArgumentsList[] { |
21 |
| - return [ |
22 |
| - { |
23 |
| - stepMatchArguments: [ |
24 |
| - { |
25 |
| - group: { |
26 |
| - start: 4, |
27 |
| - value: '48', |
28 |
| - children: [], |
29 |
| - }, |
30 |
| - }, |
31 |
| - ], |
32 |
| - }, |
33 |
| - ] |
34 |
| - } |
35 |
| - } |
36 |
| - |
37 |
| - class StubGherkinQuery extends GherkinQuery { |
38 |
| - getPickleStepIds(): string[] { |
39 |
| - return ['dummy-id'] |
40 |
| - } |
41 |
| - } |
42 |
| - |
43 |
| - const { container } = render(<GherkinStep step={step} hasExamples={false} />, { |
44 |
| - gherkinQuery: new StubGherkinQuery(), |
45 |
| - cucumberQuery: new StubCucumberQuery(), |
46 |
| - }) |
47 |
| - |
48 |
| - expect(container).to.contain.text('Given') |
49 |
| - expect(container).to.contain.text('the 48 pixies') |
50 |
| - }) |
51 |
| -}) |
| 1 | +import { Query as GherkinQuery } from '@cucumber/gherkin-utils' |
| 2 | +import * as messages from '@cucumber/messages' |
| 3 | +import { Query as CucumberQuery } from '@cucumber/query' |
| 4 | +import { expect } from 'chai' |
| 5 | +import React from 'react' |
| 6 | + |
| 7 | +import { render } from '../../../test-utils/index.js' |
| 8 | +import { GherkinStep } from './GherkinStep.js' |
| 9 | + |
| 10 | +describe('<GherkinStep>', () => { |
| 11 | + it('renders', () => { |
| 12 | + const step: messages.Step = { |
| 13 | + keyword: 'Given', |
| 14 | + text: 'the 48 pixies', |
| 15 | + location: { column: 1, line: 1 }, |
| 16 | + id: '123', |
| 17 | + } |
| 18 | + |
| 19 | + class StubCucumberQuery extends CucumberQuery { |
| 20 | + public getStepMatchArgumentsLists(): messages.StepMatchArgumentsList[] { |
| 21 | + return [ |
| 22 | + { |
| 23 | + stepMatchArguments: [ |
| 24 | + { |
| 25 | + group: { |
| 26 | + start: 4, |
| 27 | + value: '48', |
| 28 | + children: [], |
| 29 | + }, |
| 30 | + }, |
| 31 | + ], |
| 32 | + }, |
| 33 | + ] |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + class StubGherkinQuery extends GherkinQuery { |
| 38 | + getPickleStepIds(): string[] { |
| 39 | + return ['dummy-id'] |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + const { container } = render(<GherkinStep step={step} hasExamples={false} />, { |
| 44 | + gherkinQuery: new StubGherkinQuery(), |
| 45 | + cucumberQuery: new StubCucumberQuery(), |
| 46 | + }) |
| 47 | + |
| 48 | + expect(container).to.contain.text('Given') |
| 49 | + expect(container).to.contain.text('the 48 pixies') |
| 50 | + }) |
| 51 | + it('empty parameters are respected correctly', () => { |
| 52 | + const step: messages.Step = { |
| 53 | + keyword: 'Given', |
| 54 | + text: 'the order is placed', |
| 55 | + location: { column: 1, line: 1 }, |
| 56 | + id: '123', |
| 57 | + } |
| 58 | + |
| 59 | + class StubCucumberQuery extends CucumberQuery { |
| 60 | + public getStepMatchArgumentsLists(): messages.StepMatchArgumentsList[] { |
| 61 | + return [ |
| 62 | + { |
| 63 | + stepMatchArguments: [ |
| 64 | + { |
| 65 | + group: { |
| 66 | + start: 9, |
| 67 | + value: '', |
| 68 | + children: [], |
| 69 | + }, |
| 70 | + }, |
| 71 | + ], |
| 72 | + }, |
| 73 | + ] |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + class StubGherkinQuery extends GherkinQuery { |
| 78 | + getPickleStepIds(): string[] { |
| 79 | + return ['dummy-id'] |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + const { container } = render(<GherkinStep step={step} hasExamples={false} />, { |
| 84 | + gherkinQuery: new StubGherkinQuery(), |
| 85 | + cucumberQuery: new StubCucumberQuery(), |
| 86 | + }) |
| 87 | + |
| 88 | + expect(container).to.not.contain.text('the orderthe order is placed') |
| 89 | + }) |
| 90 | +}) |
0 commit comments