-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(httpApi): add startWith, endWith matchers as well as concise mat…
…cher expressions
- Loading branch information
Showing
11 changed files
with
642 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
parserOptions: | ||
ecmaVersion: 2017 | ||
ecmaVersion: 2019 | ||
sourceType: script | ||
env: | ||
node: true | ||
es6: true | ||
jest: true | ||
extends: eslint:recommended | ||
rules: | ||
no-unused-vars: off | ||
no-unused-vars: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
exports.registerChaiAssertion = (chai, utils) => { | ||
chai.Assertion.addMethod('startWith', function (expected) { | ||
return this.assert( | ||
typeof this._obj === 'string' && this._obj.startsWith(expected), | ||
`expected #{this} to start with #{exp}`, | ||
`expected #{this} not to start with #{exp}`, | ||
expected | ||
) | ||
}) | ||
chai.Assertion.addMethod('endWith', function (expected) { | ||
return this.assert( | ||
typeof this._obj === 'string' && this._obj.endsWith(expected), | ||
`expected #{this} to end with #{exp}`, | ||
`expected #{this} not to end with #{exp}`, | ||
expected | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const expressionRegex = /(?<field>[^\s]+)\s+(?<matcher>!?(?:[#~*^$]?=|\?))(?:\s+(?<value>.+))?/ | ||
|
||
exports.parseMatchExpression = (expression) => { | ||
const results = expressionRegex.exec(expression) | ||
if (results) return results.groups | ||
throw new TypeError(`'${expression}' is not a valid expression`) | ||
} |
Oops, something went wrong.