Skip to content

Commit

Permalink
chore: aligns expected/asserted grammar in Gherkin suites
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed Jul 3, 2019
1 parent f77395e commit 50883ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion test/cucumber/steps/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ chai.config.truncateThreshold = 0;
const { expect } = chai;

module.exports = function() {
this.Then(/^field "([^"]*)" equals:$/, function(fieldName, expectedJson) {
this.Then(/^result field "([^"]*)" equals:$/, function(
fieldName,
expectedJson
) {
const expected = jhp.parse(expectedJson);
expect(this.result.fields[fieldName]).to.deep.equal(expected);
});
Expand Down
15 changes: 9 additions & 6 deletions test/cucumber/steps/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ module.exports = function() {
this.actual = jhp.parse(actualMessage);
});

this.Given(/^actual "([^"]*)" field equals "([^"]*)"/, function(
this.Given(/^actual field "([^"]*)" equals "([^"]*)"/, function(
fieldName,
value
) {
this.actual[fieldName] = value;
});

this.Given(/^you expect "([^"]*)" field to equal "([^"]*)"$/, function(
this.Given(/^you expect field "([^"]*)" to equal "([^"]*)"$/, function(
fieldName,
expectedValue
) {
this.expected[fieldName] = expectedValue;
});

this.Given(/^you expect "([^"]*)" field to equal:$/, function(
this.Given(/^you expect field "([^"]*)" to equal:$/, function(
fieldName,
codeBlock
) {
Expand All @@ -40,7 +40,7 @@ module.exports = function() {
});

this.Given(
/^you expect "body" field to match the following "([^"]*)":$/,
/^you expect field "body" to match the following "([^"]*)":$/,
function(bodyType, value) {
switch (bodyType.toLowerCase()) {
case 'json schema':
Expand All @@ -53,7 +53,7 @@ module.exports = function() {
}
);

this.Given(/^actual "([^"]*)" field equals:$/, function(
this.Given(/^actual field "([^"]*)" equals:$/, function(
fieldName,
codeBlock
) {
Expand Down Expand Up @@ -93,7 +93,10 @@ ${dmp.patch_toText(dmp.patch_make(stringifiedActual, expectedResult))}
);
});

this.Then(/^field "(\w+)" is( NOT)? valid$/i, function(fieldName, isInvalid) {
this.Then(/^result field "(\w+)" is( NOT)? valid$/i, function(
fieldName,
isInvalid
) {
expect(this.result).to.have.nested.property(
`fields.${fieldName}.valid`,
!isInvalid
Expand Down

0 comments on commit 50883ae

Please sign in to comment.