-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tmatch support to expect(object).toMatch
Fixes #81
- Loading branch information
Showing
4 changed files
with
119 additions
and
32 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
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,55 @@ | ||
import expect from '../index' | ||
|
||
describe('expect(string).toNotMatch', () => { | ||
it('requires the pattern to be a RegExp', () => { | ||
expect(() => { | ||
expect('actual').toNotMatch('expected') | ||
}).toThrow(/must be a RegExp/) | ||
}) | ||
|
||
it('does not throw when the actual value does not match the pattern', () => { | ||
expect(() => { | ||
expect('actual').toNotMatch(/nope/) | ||
}).toNotThrow() | ||
}) | ||
|
||
it('throws when the actual value matches the pattern', () => { | ||
expect(() => { | ||
expect('actual').toNotMatch(/^actual$/) | ||
}).toThrow(/to not match/) | ||
}) | ||
}) | ||
|
||
describe('expect(object).toNotMatch', () => { | ||
it('does not throw when the actual value does not match the pattern', () => { | ||
expect(() => { | ||
expect({ | ||
statusCode: 200, | ||
headers: { | ||
server: 'nginx web server' | ||
} | ||
}).toNotMatch({ | ||
statusCode: 200, | ||
headers: { | ||
server: /express/ | ||
} | ||
}) | ||
}).toNotThrow() | ||
}) | ||
|
||
it('throws when the actual value matches the pattern', () => { | ||
expect(() => { | ||
expect({ | ||
statusCode: 200, | ||
headers: { | ||
server: 'express web server' | ||
} | ||
}).toNotMatch({ | ||
statusCode: 200, | ||
headers: { | ||
server: /express/ | ||
} | ||
}) | ||
}).toThrow(/to not match/) | ||
}) | ||
}) |
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