Revert removal of compare nesting

Since we want the user to be able to pass a negative comparison function, the extra layer of wrapping is now needed
This commit is contained in:
Kyriacos Souroullas and Sheel Choksi
2013-10-28 13:49:54 -07:00
parent dd8a455f91
commit e346e7dcc1
37 changed files with 493 additions and 435 deletions

View File

@@ -1,35 +1,35 @@
describe("toBeNaN", function() {
it("passes for NaN with a custom .not fail", function() {
var matcherComparator = j$.matchers.toBeNaN(),
var matcher = j$.matchers.toBeNaN(),
result;
result = matcherComparator(Number.NaN);
result = matcher.compare(Number.NaN);
expect(result.pass).toBe(true);
expect(result.message).toEqual("Expected actual not to be NaN.");
});
it("fails for anything not a NaN", function() {
var matcherComparator = j$.matchers.toBeNaN();
var matcher = j$.matchers.toBeNaN();
result = matcherComparator(1);
result = matcher.compare(1);
expect(result.pass).toBe(false);
result = matcherComparator(null);
result = matcher.compare(null);
expect(result.pass).toBe(false);
result = matcherComparator(void 0);
result = matcher.compare(void 0);
expect(result.pass).toBe(false);
result = matcherComparator('');
result = matcher.compare('');
expect(result.pass).toBe(false);
result = matcherComparator(Number.POSITIVE_INFINITY);
result = matcher.compare(Number.POSITIVE_INFINITY);
expect(result.pass).toBe(false);
});
it("has a custom message on failure", function() {
var matcherComparator = j$.matchers.toBeNaN(),
result = matcherComparator(0);
var matcher = j$.matchers.toBeNaN(),
result = matcher.compare(0);
expect(result.message).toEqual("Expected 0 to be NaN.");
});