Remove an extra layer of wrapping for matchers/custom matchers

Helps reduce how nested custom matchers have to be for users as well as
Jasmine internal matchers

[#59161378]
This commit is contained in:
Sheel Choksi
2013-10-19 22:46:19 -07:00
parent 5f429fcb37
commit 39d7ebf28e
37 changed files with 437 additions and 494 deletions
+7 -11
View File
@@ -10,10 +10,8 @@ describe("Custom Matchers (Integration)", function() {
env.it('spec defining a custom matcher', function() {
env.addMatchers({
matcherForSpec: function() {
return {
compare: function(actual, expected) {
return { pass: false, message: "matcherForSpec: actual: " + actual + "; expected: " + expected };
}
return function(actual, expected) {
return { pass: false, message: "matcherForSpec: actual: " + actual + "; expected: " + expected };
}
}
});
@@ -40,7 +38,7 @@ describe("Custom Matchers (Integration)", function() {
it("passes the spec if the custom matcher passes", function(done) {
env.addMatchers({
toBeReal: function() {
return { compare: function() { return { pass: true }; } };
return function() { return { pass: true }; };
}
});
@@ -59,10 +57,8 @@ describe("Custom Matchers (Integration)", function() {
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
env.addMatchers({
toBeReal: function() {
return {
compare: function() {
return { pass: false };
}
return function() {
return { pass: false };
}
}
});
@@ -83,7 +79,7 @@ describe("Custom Matchers (Integration)", function() {
var argumentSpy = jasmine.createSpy("argument spy").and.returnValue({ pass: true });
env.addMatchers({
toBeReal: function() {
return { compare: argumentSpy };
return argumentSpy;
}
});
@@ -104,7 +100,7 @@ describe("Custom Matchers (Integration)", function() {
});
it("passes the jasmine utility and current equality matchers to the expectation factory", function(done) {
var matcherFactory = function() { return { compare: function() { return {pass: true}; }}; },
var matcherFactory = function() { return function() { return { pass: true }; }; },
argumentSpy = jasmine.createSpy("argument spy").and.returnValue(matcherFactory),
customEqualityFn = function() { return true; };