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

@@ -307,10 +307,12 @@ describe('Env', function() {
it('creates an expectationFactory that uses the current custom equality testers', function(done) {
function customEqualityTester() {}
function prettyPrinter() {}
var RealSpec = jasmineUnderTest.Spec,
specInstance,
expectationFactory;
spyOn(jasmineUnderTest, 'MatchersUtil');
spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter);
spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) {
expectationFactory = options.expectationFactory;
specInstance = new RealSpec(options);
@@ -325,7 +327,8 @@ describe('Env', function() {
env.addReporter({
jasmineDone: function() {
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
customTesters: [customEqualityTester]
customTesters: [customEqualityTester],
pp: prettyPrinter
});
done();
}
@@ -336,10 +339,12 @@ describe('Env', function() {
it('creates an asyncExpectationFactory that uses the current custom equality testers', function(done) {
function customEqualityTester() {}
function prettyPrinter() {}
var RealSpec = jasmineUnderTest.Spec,
specInstance,
asyncExpectationFactory;
spyOn(jasmineUnderTest, 'MatchersUtil');
spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter);
spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) {
asyncExpectationFactory = options.asyncExpectationFactory;
specInstance = new RealSpec(options);
@@ -354,7 +359,8 @@ describe('Env', function() {
env.addReporter({
jasmineDone: function() {
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
customTesters: [customEqualityTester]
customTesters: [customEqualityTester],
pp: prettyPrinter
});
done();
}