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:
@@ -3,12 +3,12 @@ describe("toHaveBeenCalledWith", function() {
|
||||
var util = {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||
},
|
||||
matcherComparator = j$.matchers.toHaveBeenCalledWith(util),
|
||||
matcher = j$.matchers.toHaveBeenCalledWith(util),
|
||||
calledSpy = j$.createSpy('called-spy'),
|
||||
result;
|
||||
|
||||
calledSpy('a', 'b');
|
||||
result = matcherComparator(calledSpy, 'a', 'b');
|
||||
result = matcher.compare(calledSpy, 'a', 'b');
|
||||
|
||||
expect(result.pass).toBe(true);
|
||||
expect(result.message).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was.");
|
||||
@@ -18,11 +18,11 @@ describe("toHaveBeenCalledWith", function() {
|
||||
var util = {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
||||
},
|
||||
matcherComparator = j$.matchers.toHaveBeenCalledWith(util),
|
||||
matcher = j$.matchers.toHaveBeenCalledWith(util),
|
||||
uncalledSpy = j$.createSpy('uncalled spy'),
|
||||
result;
|
||||
|
||||
result = matcherComparator(uncalledSpy);
|
||||
result = matcher.compare(uncalledSpy);
|
||||
expect(result.pass).toBe(false);
|
||||
expect(result.message).toEqual("Expected spy uncalled spy to have been called with [ ] but it was never called.");
|
||||
});
|
||||
@@ -31,22 +31,22 @@ describe("toHaveBeenCalledWith", function() {
|
||||
var util = {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
|
||||
},
|
||||
matcherComparator = j$.matchers.toHaveBeenCalledWith(util),
|
||||
matcher = j$.matchers.toHaveBeenCalledWith(util),
|
||||
calledSpy = j$.createSpy('called spy'),
|
||||
result;
|
||||
|
||||
calledSpy('a');
|
||||
calledSpy('c', 'd');
|
||||
result = matcherComparator(calledSpy, 'a', 'b');
|
||||
result = matcher.compare(calledSpy, 'a', 'b');
|
||||
|
||||
expect(result.pass).toBe(false);
|
||||
expect(result.message).toEqual("Expected spy called spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a' ], [ 'c', 'd' ].");
|
||||
});
|
||||
|
||||
it("throws an exception when the actual is not a spy", function() {
|
||||
var matcherComparator = j$.matchers.toHaveBeenCalledWith(),
|
||||
var matcher = j$.matchers.toHaveBeenCalledWith(),
|
||||
fn = function() {};
|
||||
|
||||
expect(function() { matcherComparator(fn) }).toThrow(new Error("Expected a spy, but got Function."));
|
||||
expect(function() { matcher.compare(fn) }).toThrow(new Error("Expected a spy, but got Function."));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user