refactor: init cypress-cucumber-preprocessor install.

This commit is contained in:
2021-09-02 17:02:45 +02:00
parent 89ec2d42ac
commit 1aa57bbd0a
5000 changed files with 408119 additions and 231 deletions

View File

@@ -0,0 +1,52 @@
/* eslint-env mocha */
const assert = require('assert')
const CucumberExpression = require('../src/cucumber_expression')
const ParameterTypeRegistry = require('../src/parameter_type_registry')
describe('CucumberExpression', () => {
describe('RegExp translation', () => {
it('translates no arguments', () => {
assertRegexp(
'I have 10 cukes in my belly now',
/^I have 10 cukes in my belly now$/
)
})
it('translates alternation', () => {
assertRegexp(
'I had/have a great/nice/charming friend',
/^I (?:had|have) a (?:great|nice|charming) friend$/
)
})
it('translates alternation with non-alpha', () => {
assertRegexp('I said Alpha1/Beta1', /^I said (?:Alpha1|Beta1)$/)
})
it('translates parameters', () => {
assertRegexp(
"I have {float} cukes at {int} o'clock",
/^I have (-?\d*\.\d+) cukes at ((?:-?\d+)|(?:\d+)) o'clock$/
)
})
it('translates parenthesis to non-capturing optional capture group', () => {
assertRegexp(
'I have many big(ish) cukes',
/^I have many big(?:ish)? cukes$/
)
})
it('translates parenthesis with alpha unicode', () => {
assertRegexp('Привет, Мир(ы)!', /^Привет, Мир(?:ы)?!$/)
})
})
})
const assertRegexp = (expression, expectedRegexp) => {
const cucumberExpression = new CucumberExpression(
expression,
new ParameterTypeRegistry()
)
assert.deepEqual(cucumberExpression.regexp, expectedRegexp)
}