Matchers can have a negativeCompare

- Passing in a 'negativeCompare' will cause that function to be used when it is a 'not' assertion
- Otherwise, the reversal of the compare's result will be used instead

[finishes #59703824]
This commit is contained in:
Kyriacos Souroullas and Sheel Choksi
2013-10-28 15:26:48 -07:00
parent e346e7dcc1
commit cd9d5284cd
3 changed files with 107 additions and 3 deletions
+22
View File
@@ -56,6 +56,28 @@ describe("Custom Matchers (Integration)", function() {
env.execute();
});
it("uses the negative compare function for a negative comparison, if provided", function(done) {
env.addMatchers({
toBeReal: function() {
return {
compare: function() { return { pass: true }; },
negativeCompare: function() { return { pass: true }; }
};
}
});
env.it("spec with custom negative comparison matcher", function() {
env.expect(true).not.toBeReal();
});
var specExpectations = function(result) {
expect(result.status).toEqual('passed');
}
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
env.addMatchers({
toBeReal: function() {