Inject a per-runable pretty printer into MatchersUtil

This will allow us to add support for custom object formatters, which
will be a per-runable resource like custom matchers, by injecting them
into the pretty-printer.
This commit is contained in:
Steve Gravrock
2019-10-08 22:57:07 -07:00
committed by Steve Gravrock
parent dec67bd535
commit 1f23f1e4d2
46 changed files with 546 additions and 401 deletions

View File

@@ -2,7 +2,8 @@ describe("toHaveBeenCalledWith", function() {
it("passes when the actual was called with matching parameters", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
@@ -29,7 +30,8 @@ describe("toHaveBeenCalledWith", function() {
it("fails when the actual was not called", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
@@ -41,7 +43,7 @@ describe("toHaveBeenCalledWith", function() {
});
it("fails when the actual was called with different parameters", function() {
var util = new jasmineUnderTest.MatchersUtil(),
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
calledSpy = new jasmineUnderTest.Env().createSpy('called spy'),
result;
@@ -71,8 +73,11 @@ describe("toHaveBeenCalledWith", function() {
});
it("throws an exception when the actual is not a spy", function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(),
fn = function() {};
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function () {
};
expect(function() { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
});