Refer to MatchersUtil instances as matchersUtil, not util

This commit is contained in:
Pivotal
2020-02-10 14:12:56 -08:00
committed by Steve Gravrock
parent d41139fea2
commit ea3dd9dffc
21 changed files with 154 additions and 148 deletions

View File

@@ -1,7 +1,7 @@
describe("toBe", function() {
it("passes with no message when actual === expected", function() {
var util = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare(1, 1);
@@ -9,8 +9,8 @@ describe("toBe", function() {
});
it("passes with a custom message when expected is an array", function() {
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result,
array = [1];
@@ -20,8 +20,8 @@ describe("toBe", function() {
});
it("passes with a custom message when expected is an object", function() {
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result,
obj = {foo: "bar"};
@@ -31,8 +31,8 @@ describe("toBe", function() {
});
it("fails with no message when actual !== expected", function() {
var util = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare(1, 2);
@@ -41,8 +41,8 @@ describe("toBe", function() {
});
it("fails with a custom message when expected is an array", function() {
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare([1], [1]);
@@ -51,8 +51,8 @@ describe("toBe", function() {
});
it("fails with a custom message when expected is an object", function() {
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare({foo: "bar"}, {foo: "bar"});
@@ -63,8 +63,8 @@ describe("toBe", function() {
it("works with custom object formatters when expected is an object", function() {
var formatter = function(x) { return '<' + x.foo + '>'; },
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
matcher = jasmineUnderTest.matchers.toBe(util),
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare({foo: "bar"}, {foo: "bar"});

View File

@@ -1,13 +1,13 @@
describe("toContain", function() {
it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
var util = {
var matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
matcher = jasmineUnderTest.matchers.toContain(util),
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
result;
result = matcher.compare("ABC", "B");
expect(util.contains).toHaveBeenCalledWith("ABC", "B");
expect(matchersUtil.contains).toHaveBeenCalledWith("ABC", "B");
expect(result.pass).toBe(true);
});

View File

@@ -2,10 +2,10 @@ describe("toEqual", function() {
"use strict";
function compareEquals(actual, expected) {
var util = new jasmineUnderTest.MatchersUtil({
var matchersUtil = new jasmineUnderTest.MatchersUtil({
pp: jasmineUnderTest.makePrettyPrinter()
}),
matcher = jasmineUnderTest.matchers.toEqual(util);
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
var result = matcher.compare(actual, expected);
@@ -13,19 +13,19 @@ describe("toEqual", function() {
}
it("delegates to equals function", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
buildFailureMessage: function() {
return 'does not matter'
return 'does not matter';
},
DiffBuilder: new jasmineUnderTest.DiffBuilder()
},
matcher = jasmineUnderTest.matchers.toEqual(util),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
result;
result = matcher.compare(1, 1);
expect(util.equals).toHaveBeenCalledWith(1, 1, jasmine.anything());
expect(matchersUtil.equals).toHaveBeenCalledWith(1, 1, jasmine.anything());
expect(result.pass).toBe(true);
});
@@ -33,8 +33,8 @@ describe("toEqual", function() {
var tester = function (a, b) {
return a.toString() === b.toString();
},
util = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
matcher = jasmineUnderTest.matchers.toEqual(util),
matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
result;
result = matcher.compare(1, '1');
@@ -107,8 +107,8 @@ describe("toEqual", function() {
var actual = {x: {y: 1, z: 2, f: 4}},
expected = {x: {y: 1, z: 2, g: 3}},
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
matcher = jasmineUnderTest.matchers.toEqual(util),
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
message =
"Expected $.x to have properties\n" +
" g: |3|\n" +
@@ -128,8 +128,8 @@ describe("toEqual", function() {
var actual = [{foo: 4}],
expected = [{foo: 5}],
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
matcher = jasmineUnderTest.matchers.toEqual(util),
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
message = "Expected $[0].foo = |4| to equal |5|.";
expect(matcher.compare(actual, expected).message).toEqual(message);
@@ -151,8 +151,8 @@ describe("toEqual", function() {
bar: "shouldn't be pretty printed"
}],
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
matcher = jasmineUnderTest.matchers.toEqual(util),
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
message = "Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n" +
"Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'.";
@@ -348,8 +348,8 @@ describe("toEqual", function() {
expected = {x: new Bar()},
message = "Expected $.x to be a kind of Bar, but was |[object Object]|.",
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
matcher = jasmineUnderTest.matchers.toEqual(util);
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
expect(matcher.compare(actual, expected).message).toEqual(message);
});
@@ -889,8 +889,8 @@ describe("toEqual", function() {
var actual = [1, 1, 2, 3, 5],
expected = [1, 1, 2, 3],
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
matcher = jasmineUnderTest.matchers.toEqual(util),
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
message = 'Expected $.length = |5| to equal |4|.\n' +
'Unexpected $[4] = |5| in array.';

View File

@@ -1,11 +1,11 @@
describe("toHaveBeenCalledWith", function() {
it("passes when the actual was called with matching parameters", function() {
var util = {
var matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
result;
@@ -29,11 +29,11 @@ describe("toHaveBeenCalledWith", function() {
});
it("fails when the actual was not called", function() {
var util = {
var matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
result;
@@ -43,8 +43,8 @@ describe("toHaveBeenCalledWith", function() {
});
it("fails when the actual was called with different parameters", function() {
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Env().createSpy('called spy'),
result;

View File

@@ -192,10 +192,7 @@ describe("toThrowError", function() {
});
it("passes if thrown is an Error and the expected the same Error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = jasmineUnderTest.matchers.toThrowError(),
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
},
@@ -208,10 +205,7 @@ describe("toThrowError", function() {
});
it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
},
matcher = jasmineUnderTest.matchers.toThrowError(),
var matcher = jasmineUnderTest.matchers.toThrowError(),
CustomError = function CustomError(arg) { arg.x },
fn = function() {
throw new CustomError({ x: 1 });
@@ -227,10 +221,7 @@ describe("toThrowError", function() {
});
it("fails if thrown is an Error and the expected is a different Error", function() {
var util = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
},
matcher = jasmineUnderTest.matchers.toThrowError(),
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
},
@@ -243,11 +234,11 @@ describe("toThrowError", function() {
});
it("passes if thrown is a type of Error and it is equal to the expected Error and message", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(util),
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError("foo");
},
@@ -260,12 +251,12 @@ describe("toThrowError", function() {
});
it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(util),
CustomError = function CustomError(arg) { this.message = arg.message },
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
CustomError = function CustomError(arg) { this.message = arg.message; },
fn = function() {
throw new CustomError({message: "foo"});
},
@@ -280,11 +271,11 @@ describe("toThrowError", function() {
});
it("fails if thrown is a type of Error and the expected is a different Error", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(util),
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError("foo");
},
@@ -297,11 +288,11 @@ describe("toThrowError", function() {
});
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(util),
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError("foo");
},
@@ -314,11 +305,11 @@ describe("toThrowError", function() {
});
it("fails if thrown is a type of Error and the expected is a different Error", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(util),
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError("foo");
},

View File

@@ -23,11 +23,11 @@ describe("toThrow", function() {
});
it("passes if it throws but there is no expected", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(util),
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
@@ -54,11 +54,11 @@ describe("toThrow", function() {
});
it("passes if what is thrown is equivalent to what is expected", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(util),
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
@@ -71,11 +71,11 @@ describe("toThrow", function() {
});
it("fails if what is thrown is not equivalent to what is expected", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(util),
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
@@ -88,11 +88,11 @@ describe("toThrow", function() {
});
it("fails if what is thrown is not equivalent to undefined", function() {
var util = {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(util),
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},