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

View File

@@ -56,7 +56,7 @@ describe("Expectation", function() {
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
var fakeCompare = function() { return { pass: true }; },
matcherFactory = jasmine.createSpy("matcher").and.returnValue({ compare: fakeCompare }),
matcherFactory = jasmine.createSpy("matcher").and.returnValue(fakeCompare),
matchers = {
toFoo: matcherFactory
},
@@ -83,9 +83,7 @@ describe("Expectation", function() {
var fakeCompare = jasmine.createSpy('fake-compare').and.returnValue({pass: true}),
matchers = {
toFoo: function() {
return {
compare: fakeCompare
};
return fakeCompare;
}
},
util = {
@@ -110,9 +108,7 @@ describe("Expectation", function() {
it("reports a passing result to the spec when the comparison passes", function() {
var matchers = {
toFoo: function() {
return {
compare: function() { return { pass: true }; }
};
return function() { return { pass: true }; };
}
},
util = {
@@ -144,9 +140,7 @@ describe("Expectation", function() {
it("reports a failing result to the spec when the comparison fails", function() {
var matchers = {
toFoo: function() {
return {
compare: function() { return { pass: false }; }
};
return function() { return { pass: false }; };
}
},
util = {
@@ -178,13 +172,11 @@ describe("Expectation", function() {
it("reports a failing result and a custom fail message to the spec when the comparison fails", function() {
var matchers = {
toFoo: function() {
return {
compare: function() {
return {
pass: false,
message: "I am a custom message"
};
}
return function() {
return {
pass: false,
message: "I am a custom message"
};
};
}
},
@@ -213,9 +205,7 @@ describe("Expectation", function() {
it("reports a passing result to the spec when the comparison fails for a negative expectation", function() {
var matchers = {
toFoo: function() {
return {
compare: function() { return { pass: false }; }
};
return function() { return { pass: false }; };
}
},
util = {
@@ -248,9 +238,7 @@ describe("Expectation", function() {
it("reports a failing result to the spec when the comparison passes for a negative expectation", function() {
var matchers = {
toFoo: function() {
return {
compare: function() { return { pass: true }; }
};
return function() { return { pass: true }; };
}
},
util = {
@@ -284,13 +272,11 @@ describe("Expectation", function() {
it("reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation", function() {
var matchers = {
toFoo: function() {
return {
compare: function() {
return {
pass: true,
message: "I am a custom message"
};
}
return function() {
return {
pass: true,
message: "I am a custom message"
};
};
}
},
@@ -317,4 +303,4 @@ describe("Expectation", function() {
message: "I am a custom message"
});
});
});
});