Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
331 additions
and
239 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,77 @@ | ||
"use strict"; | ||
|
||
var assert = require("@sinonjs/referee").assert; | ||
var samsam = require("./samsam"); | ||
var match = samsam.match; | ||
|
||
describe("matcher-integration", function() { | ||
context("samsam.match", function() { | ||
context("returns true", function() { | ||
it("if matching custom matcher", function() { | ||
var matchAlways = samsam.createMatcher(function() { | ||
return true; | ||
}); | ||
assert.isTrue(match(42, matchAlways)); | ||
}); | ||
|
||
it("if matching boolean", function() { | ||
assert.isTrue(match(false, match.bool)); | ||
}); | ||
|
||
it("if matching number", function() { | ||
assert.isTrue(match(42, match.number)); | ||
}); | ||
|
||
it("if matching string", function() { | ||
assert.isTrue(match("abc", match.string)); | ||
}); | ||
|
||
it("when matching nested matcher", function() { | ||
assert.isTrue(match({ x: 1 }, { x: match.number })); | ||
}); | ||
}); | ||
|
||
context("returns false", function() { | ||
it("if not matching custom matcher", function() { | ||
var matchAlways = samsam.createMatcher(function() { | ||
return false; | ||
}); | ||
assert.isFalse(match(42, matchAlways)); | ||
}); | ||
|
||
it("if not matching boolean", function() { | ||
assert.isFalse(match(0, match.bool)); | ||
}); | ||
|
||
it("if not matching number", function() { | ||
assert.isFalse(match("42", match.number)); | ||
}); | ||
|
||
it("if not matching string", function() { | ||
assert.isFalse(match(123, match.string)); | ||
}); | ||
|
||
it("when not matching nested matcher", function() { | ||
assert.isFalse(match({ x: 1 }, { x: match.string })); | ||
}); | ||
}); | ||
}); | ||
|
||
context("samsam.deepEqual", function() { | ||
context("returns true", function() { | ||
it("if matching boolean", function() { | ||
assert.isTrue(samsam.deepEqual(false, match.bool)); | ||
}); | ||
|
||
it("when matching nested matcher", function() { | ||
assert.isTrue(samsam.deepEqual({ x: 1 }, { x: match.number })); | ||
}); | ||
}); | ||
|
||
context("returns false", function() { | ||
it("when not matching nested matcher", function() { | ||
assert.isFalse(samsam.deepEqual({ x: 1 }, { x: match.string })); | ||
}); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.