.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports content when DOM node has non empty text node', function () {
+ it('reports content when DOM node has non empty text node', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!'));
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a =
...
to equal
.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports empty DOM attributes', function () {
+ it('reports empty DOM attributes', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
nodeA.setAttribute('contenteditable', '');
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a =
to equal
.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports 0 attr value as non empty DOM attribute', function () {
+ it('reports 0 attr value as non empty DOM attribute', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
nodeA.setAttribute('contenteditable', 0);
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a =
to equal
.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between a DOM node and a bare Object", function() {
- var actual = {a: this.doc.createElement('div')},
- expected = {a: {}},
- message = 'Expected $.a =
to equal Object({ }).';
+ it('reports mismatches between a DOM node and a bare Object', function() {
+ var actual = { a: this.doc.createElement('div') },
+ expected = { a: {} },
+ message = 'Expected $.a =
to equal Object({ }).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
});
- it("reports asymmetric mismatches", function() {
- var actual = {a: 1},
- expected = {a: jasmineUnderTest.any(String)},
+ it('reports asymmetric mismatches', function() {
+ var actual = { a: 1 },
+ expected = { a: jasmineUnderTest.any(String) },
message = 'Expected $.a = 1 to equal
.';
expect(compareEquals(actual, expected).message).toEqual(message);
- expect(compareEquals(actual, expected).pass).toBe(false)
+ expect(compareEquals(actual, expected).pass).toBe(false);
});
- it("reports asymmetric mismatches when the asymmetric comparand is the actual value", function() {
- var actual = {a: jasmineUnderTest.any(String)},
- expected = {a: 1},
+ it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() {
+ var actual = { a: jasmineUnderTest.any(String) },
+ expected = { a: 1 },
message = 'Expected $.a = to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message);
- expect(compareEquals(actual, expected).pass).toBe(false)
+ expect(compareEquals(actual, expected).pass).toBe(false);
});
- it("does not report a mismatch when asymmetric matchers are satisfied", function() {
- var actual = {a: 'a'},
- expected = {a: jasmineUnderTest.any(String)};
+ it('does not report a mismatch when asymmetric matchers are satisfied', function() {
+ var actual = { a: 'a' },
+ expected = { a: jasmineUnderTest.any(String) };
expect(compareEquals(actual, expected).message).toEqual('');
- expect(compareEquals(actual, expected).pass).toBe(true)
+ expect(compareEquals(actual, expected).pass).toBe(true);
});
- it("works on big complex stuff", function() {
+ it('works on big complex stuff', function() {
var actual = {
- foo: [
- {bar: 1, things: ['a', 'b']},
- {bar: 2, things: ['a', 'b']}
- ],
- baz: [
- {a: {b: 1}}
- ],
+ foo: [{ bar: 1, things: ['a', 'b'] }, { bar: 2, things: ['a', 'b'] }],
+ baz: [{ a: { b: 1 } }],
quux: 1,
nan: 0,
aRegexp: 'hi',
- inf: -1/0,
+ inf: -1 / 0,
boolean: false,
notDefined: 0,
aNull: void 0
@@ -870,16 +879,14 @@ describe("toEqual", function() {
var expected = {
foo: [
- {bar: 2, things: ['a', 'b', 'c']},
- {bar: 2, things: ['a', 'd']}
- ],
- baz: [
- {a: {b: 1, c: 1}}
+ { bar: 2, things: ['a', 'b', 'c'] },
+ { bar: 2, things: ['a', 'd'] }
],
+ baz: [{ a: { b: 1, c: 1 } }],
quux: [],
- nan: 0/0,
+ nan: 0 / 0,
aRegexp: /hi/,
- inf: 1/0,
+ inf: 1 / 0,
boolean: true,
notDefined: void 0,
aNull: null
@@ -903,18 +910,19 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- describe("different length arrays", function() {
- it("actual array is longer", function() {
+ describe('different length arrays', function() {
+ it('actual array is longer', function() {
var actual = [1, 1, 2, 3, 5],
expected = [1, 1, 2, 3],
- message = 'Expected $.length = 5 to equal 4.\n' +
+ message =
+ 'Expected $.length = 5 to equal 4.\n' +
'Unexpected $[4] = 5 in array.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses custom object formatters when the actual array is longer", function() {
+ it('uses custom object formatters when the actual array is longer', function() {
function formatter(x) {
if (typeof x === 'number') {
return '|' + x + '|';
@@ -924,25 +932,27 @@ describe("toEqual", function() {
var actual = [1, 1, 2, 3, 5],
expected = [1, 1, 2, 3],
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
- message = 'Expected $.length = |5| to equal |4|.\n' +
+ message =
+ 'Expected $.length = |5| to equal |4|.\n' +
'Unexpected $[4] = |5| in array.';
expect(matcher.compare(actual, expected).message).toEqual(message);
});
- it("expected array is longer", function() {
+ it('expected array is longer', function() {
var actual = [1, 1, 2, 3],
expected = [1, 1, 2, 3, 5],
- message = 'Expected $.length = 4 to equal 5.\n' +
+ message =
+ 'Expected $.length = 4 to equal 5.\n' +
'Expected $[4] = undefined to equal 5.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("undefined in middle of actual array", function() {
+ it('undefined in middle of actual array', function() {
var actual = [1, void 0, 3],
expected = [1, 2, 3],
message = 'Expected $[1] = undefined to equal 2.';
@@ -951,7 +961,7 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("undefined in middle of expected array", function() {
+ it('undefined in middle of expected array', function() {
var actual = [1, 2, 3],
expected = [1, void 0, 3],
message = 'Expected $[1] = 2 to equal undefined.';
@@ -960,10 +970,11 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("actual array is longer by 4 elements", function() {
+ it('actual array is longer by 4 elements', function() {
var actual = [1, 1, 2, 3, 5, 8, 13],
expected = [1, 1, 2],
- message = 'Expected $.length = 7 to equal 3.\n' +
+ message =
+ 'Expected $.length = 7 to equal 3.\n' +
'Unexpected $[3] = 3 in array.\n' +
'Unexpected $[4] = 5 in array.\n' +
'Unexpected $[5] = 8 in array.\n' +
@@ -973,10 +984,11 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("expected array is longer by 4 elements", function() {
+ it('expected array is longer by 4 elements', function() {
var actual = [1, 1, 2],
expected = [1, 1, 2, 3, 5, 8, 13],
- message = 'Expected $.length = 3 to equal 7.\n' +
+ message =
+ 'Expected $.length = 3 to equal 7.\n' +
'Expected $[3] = undefined to equal 3.\n' +
'Expected $[4] = undefined to equal 5.\n' +
'Expected $[5] = undefined to equal 8.\n' +
@@ -986,10 +998,11 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("different length and different elements", function() {
+ it('different length and different elements', function() {
var actual = [1],
expected = [2, 3],
- message = 'Expected $.length = 1 to equal 2.\n' +
+ message =
+ 'Expected $.length = 1 to equal 2.\n' +
'Expected $[0] = 1 to equal 2.\n' +
'Expected $[1] = undefined to equal 3.';
@@ -997,50 +1010,55 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("object with nested array (actual longer than expected)", function() {
+ it('object with nested array (actual longer than expected)', function() {
var actual = { values: [1, 1, 2, 3] },
expected = { values: [1, 1, 2] },
- message = 'Expected $.values.length = 4 to equal 3.\n' +
+ message =
+ 'Expected $.values.length = 4 to equal 3.\n' +
'Unexpected $.values[3] = 3 in array.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("object with nested array (expected longer than actual)", function() {
+ it('object with nested array (expected longer than actual)', function() {
var actual = { values: [1, 1, 2] },
expected = { values: [1, 1, 2, 3] },
- message = 'Expected $.values.length = 3 to equal 4.\n' +
+ message =
+ 'Expected $.values.length = 3 to equal 4.\n' +
'Expected $.values[3] = undefined to equal 3.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("array with unexpected nested object", function() {
+ it('array with unexpected nested object', function() {
var actual = [1, 1, 2, { value: 3 }],
expected = [1, 1, 2],
- message = 'Expected $.length = 4 to equal 3.\n' +
+ message =
+ 'Expected $.length = 4 to equal 3.\n' +
'Unexpected $[3] = Object({ value: 3 }) in array.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("array with missing nested object", function() {
+ it('array with missing nested object', function() {
var actual = [1, 1, 2],
expected = [1, 1, 2, { value: 3 }],
- message = 'Expected $.length = 3 to equal 4.\n' +
+ message =
+ 'Expected $.length = 3 to equal 4.\n' +
'Expected $[3] = undefined to equal Object({ value: 3 }).';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("array with nested different length array", function() {
+ it('array with nested different length array', function() {
var actual = [[1], [1, 2]],
expected = [[1, 1], [2]],
- message = 'Expected $[0].length = 1 to equal 2.\n' +
+ message =
+ 'Expected $[0].length = 1 to equal 2.\n' +
'Expected $[0][1] = undefined to equal 1.\n' +
'Expected $[1].length = 2 to equal 1.\n' +
'Expected $[1][0] = 1 to equal 2.\n' +
@@ -1050,7 +1068,7 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("last element of longer array is undefined", function() {
+ it('last element of longer array is undefined', function() {
var actual = [1, 2],
expected = [1, 2, void 0],
message = 'Expected $.length = 2 to equal 3.';
@@ -1058,5 +1076,5 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- })
+ });
});
diff --git a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js
index 266758fe..2bf316e3 100644
--- a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js
@@ -1,29 +1,29 @@
-describe("toHaveBeenCalledBefore", function() {
- it("throws an exception when the actual is not a spy", function() {
+describe('toHaveBeenCalledBefore', function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
- pp: jasmineUnderTest.makePrettyPrinter()
- }),
- fn = function() {},
- spy = new jasmineUnderTest.Env().createSpy('a spy');
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ fn = function() {},
+ spy = new jasmineUnderTest.Env().createSpy('a spy');
- expect(function () {
+ expect(function() {
matcher.compare(fn, spy);
}).toThrowError(Error, /Expected a spy, but got Function./);
});
- it("throws an exception when the expected is not a spy", function() {
+ it('throws an exception when the expected is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
- pp: jasmineUnderTest.makePrettyPrinter()
- }),
- spy = new jasmineUnderTest.Env().createSpy('a spy'),
- fn = function() {};
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ spy = new jasmineUnderTest.Env().createSpy('a spy'),
+ fn = function() {};
- expect(function () {
+ expect(function() {
matcher.compare(spy, fn);
}).toThrowError(Error, /Expected a spy, but got Function./);
});
- it("fails when the actual was not called", function () {
+ it('fails when the actual was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy');
@@ -32,10 +32,12 @@ describe("toHaveBeenCalledBefore", function() {
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toMatch(/Expected spy first spy to have been called./);
+ expect(result.message).toMatch(
+ /Expected spy first spy to have been called./
+ );
});
- it("fails when the expected was not called", function () {
+ it('fails when the expected was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy');
@@ -44,10 +46,12 @@ describe("toHaveBeenCalledBefore", function() {
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toMatch(/Expected spy second spy to have been called./);
+ expect(result.message).toMatch(
+ /Expected spy second spy to have been called./
+ );
});
- it("fails when the actual is called after the expected", function () {
+ it('fails when the actual is called after the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -58,10 +62,12 @@ describe("toHaveBeenCalledBefore", function() {
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toEqual('Expected spy first spy to have been called before spy second spy');
+ expect(result.message).toEqual(
+ 'Expected spy first spy to have been called before spy second spy'
+ );
});
- it("fails when the actual is called before and after the expected", function () {
+ it('fails when the actual is called before and after the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -73,10 +79,12 @@ describe("toHaveBeenCalledBefore", function() {
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toEqual('Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)');
+ expect(result.message).toEqual(
+ 'Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)'
+ );
});
- it("fails when the expected is called before and after the actual", function () {
+ it('fails when the expected is called before and after the actual', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -88,10 +96,12 @@ describe("toHaveBeenCalledBefore", function() {
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toEqual('Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)');
+ expect(result.message).toEqual(
+ 'Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)'
+ );
});
- it("passes when the actual is called before the expected", function () {
+ it('passes when the actual is called before the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -102,6 +112,8 @@ describe("toHaveBeenCalledBefore", function() {
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(true);
- expect(result.message).toEqual('Expected spy first spy to not have been called before spy second spy, but it was');
+ expect(result.message).toEqual(
+ 'Expected spy first spy to not have been called before spy second spy, but it was'
+ );
});
});
diff --git a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js
index d79711a5..ff2975c9 100644
--- a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js
@@ -1,6 +1,5 @@
-describe("toHaveBeenCalledOnceWith", function () {
-
- it("passes when the actual was called only once and with matching parameters", function () {
+describe('toHaveBeenCalledOnceWith', function() {
+ it('passes when the actual was called only once and with matching parameters', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
@@ -11,13 +10,23 @@ describe("toHaveBeenCalledOnceWith", function () {
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected spy called-spy to have been called 0 times, multiple times, or once, but with arguments different from:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'b' ].\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called 0 times, multiple times, or once, but with arguments different from:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'b' ].\n\n"
+ );
});
- it("supports custom equality testers", function () {
- var customEqualityTesters = [function() { return true; }],
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: customEqualityTesters}),
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(matchersUtil),
+ it('supports custom equality testers', function() {
+ var customEqualityTesters = [
+ function() {
+ return true;
+ }
+ ],
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: customEqualityTesters
+ }),
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(
+ matchersUtil
+ ),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -27,7 +36,7 @@ describe("toHaveBeenCalledOnceWith", function () {
expect(result.pass).toBe(true);
});
- it("fails when the actual was never called", function () {
+ it('fails when the actual was never called', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
@@ -37,10 +46,12 @@ describe("toHaveBeenCalledOnceWith", function () {
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut it was never called.\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut it was never called.\n\n"
+ );
});
- it("fails when the actual was called once with different parameters", function () {
+ it('fails when the actual was called once with different parameters', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
@@ -51,10 +62,12 @@ describe("toHaveBeenCalledOnceWith", function () {
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'c' ].\nExpected $[1] = 'c' to equal 'b'.\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'c' ].\nExpected $[1] = 'c' to equal 'b'.\n\n"
+ );
});
- it("fails when the actual was called multiple times with expected parameters", function () {
+ it('fails when the actual was called multiple times with expected parameters', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
@@ -66,10 +79,12 @@ describe("toHaveBeenCalledOnceWith", function () {
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'b' ].\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'b' ].\n\n"
+ );
});
- it("fails when the actual was called multiple times (one of them - with expected parameters)", function () {
+ it('fails when the actual was called multiple times (one of them - with expected parameters)', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
@@ -81,15 +96,19 @@ describe("toHaveBeenCalledOnceWith", function () {
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'c' ].\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'c' ].\n\n"
+ );
});
- it("throws an exception when the actual is not a spy", function () {
+ it('throws an exception when the actual is not a spy', function() {
var pp = jasmineUnderTest.makePrettyPrinter(),
util = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
- fn = function () { };
+ fn = function() {};
- expect(function () { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
+ expect(function() {
+ matcher.compare(fn);
+ }).toThrowError(/Expected a spy, but got Function./);
});
});
diff --git a/spec/core/matchers/toHaveBeenCalledSpec.js b/spec/core/matchers/toHaveBeenCalledSpec.js
index 65106cf5..ebc9a9cb 100644
--- a/spec/core/matchers/toHaveBeenCalledSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledSpec.js
@@ -1,5 +1,5 @@
-describe("toHaveBeenCalled", function() {
- it("passes when the actual was called, with a custom .not fail message", function() {
+describe('toHaveBeenCalled', function() {
+ it('passes when the actual was called, with a custom .not fail message', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -8,10 +8,12 @@ describe("toHaveBeenCalled", function() {
result = matcher.compare(calledSpy);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected spy called-spy not to have been called.");
+ expect(result.message).toEqual(
+ 'Expected spy called-spy not to have been called.'
+ );
});
- it("fails when the actual was not called", function() {
+ it('fails when the actual was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
@@ -20,30 +22,35 @@ describe("toHaveBeenCalled", function() {
expect(result.pass).toBe(false);
});
- it("throws an exception when the actual is not a spy", function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {};
- expect(function() { matcher.compare(fn) }).toThrowError(Error, /Expected a spy, but got Function./);
+ expect(function() {
+ matcher.compare(fn);
+ }).toThrowError(Error, /Expected a spy, but got Function./);
});
- it("throws an exception when invoked with any arguments", function() {
+ it('throws an exception when invoked with any arguments', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample spy');
- expect(function() { matcher.compare(spy, 'foo') }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
+ expect(function() {
+ matcher.compare(spy, 'foo');
+ }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
});
- it("has a custom message on failure", function() {
+ it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
result = matcher.compare(spy);
- expect(result.message).toEqual("Expected spy sample-spy to have been called.");
+ expect(result.message).toEqual(
+ 'Expected spy sample-spy to have been called.'
+ );
});
});
-
diff --git a/spec/core/matchers/toHaveBeenCalledTimesSpec.js b/spec/core/matchers/toHaveBeenCalledTimesSpec.js
index e2c0c0ed..12075ad8 100644
--- a/spec/core/matchers/toHaveBeenCalledTimesSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledTimesSpec.js
@@ -1,12 +1,12 @@
-describe("toHaveBeenCalledTimes", function() {
- it("passes when the actual 0 matches the expected 0 ", function () {
+describe('toHaveBeenCalledTimes', function() {
+ it('passes when the actual 0 matches the expected 0 ', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
- calledSpy = new jasmineUnderTest.Spy('called-spy'),
- result;
+ calledSpy = new jasmineUnderTest.Spy('called-spy'),
+ result;
result = matcher.compare(calledSpy, 0);
expect(result.pass).toBeTruthy();
});
- it("passes when the actual matches the expected", function() {
+ it('passes when the actual matches the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -16,18 +16,20 @@ describe("toHaveBeenCalledTimes", function() {
expect(result.pass).toBe(true);
});
- it("fails when expected numbers is not supplied", function(){
- var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
+ it('fails when expected numbers is not supplied', function() {
+ var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('spy'),
result;
spy();
- expect(function() {
- matcher.compare(spy);
- }).toThrowError(/The expected times failed is a required argument and must be a number./);
+ expect(function() {
+ matcher.compare(spy);
+ }).toThrowError(
+ /The expected times failed is a required argument and must be a number./
+ );
});
- it("fails when the actual was called less than the expected", function() {
+ it('fails when the actual was called less than the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
@@ -36,7 +38,7 @@ describe("toHaveBeenCalledTimes", function() {
expect(result.pass).toBe(false);
});
- it("fails when the actual was called more than expected", function() {
+ it('fails when the actual was called more than expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
@@ -48,7 +50,7 @@ describe("toHaveBeenCalledTimes", function() {
expect(result.pass).toBe(false);
});
- it("throws an exception when the actual is not a spy", function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -59,7 +61,7 @@ describe("toHaveBeenCalledTimes", function() {
}).toThrowError(/Expected a spy, but got Function./);
});
- it("has a custom message on failure that tells it was called only once", function() {
+ it('has a custom message on failure that tells it was called only once', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
@@ -69,10 +71,14 @@ describe("toHaveBeenCalledTimes", function() {
spy();
result = matcher.compare(spy, 1);
- expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.');
+ expect(result.message).toEqual(
+ 'Expected spy sample-spy to have been called once. It was called ' +
+ 4 +
+ ' times.'
+ );
});
- it("has a custom message on failure that tells how many times it was called", function() {
+ it('has a custom message on failure that tells how many times it was called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
@@ -82,7 +88,10 @@ describe("toHaveBeenCalledTimes", function() {
spy();
result = matcher.compare(spy, 2);
- expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.');
+ expect(result.message).toEqual(
+ 'Expected spy sample-spy to have been called 2 times. It was called ' +
+ 4 +
+ ' times.'
+ );
});
});
-
diff --git a/spec/core/matchers/toHaveBeenCalledWithSpec.js b/spec/core/matchers/toHaveBeenCalledWithSpec.js
index 5f391d6c..a0f869a4 100644
--- a/spec/core/matchers/toHaveBeenCalledWithSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledWithSpec.js
@@ -1,24 +1,31 @@
-describe("toHaveBeenCalledWith", function() {
-
- it("passes when the actual was called with matching parameters", function() {
+describe('toHaveBeenCalledWith', function() {
+ it('passes when the actual was called with matching parameters', function() {
var matchersUtil = {
- contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
- pp: jasmineUnderTest.makePrettyPrinter()
- },
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
- calledSpy = new jasmineUnderTest.Spy('called-spy'),
- result;
+ contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
+ pp: jasmineUnderTest.makePrettyPrinter()
+ },
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
+ calledSpy = new jasmineUnderTest.Spy('called-spy'),
+ result;
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:\n [ 'a', 'b' ]\nbut it was.");
+ expect(result.message()).toEqual(
+ "Expected spy called-spy not to have been called with:\n [ 'a', 'b' ]\nbut it was."
+ );
});
- it("supports custom equality testers", function() {
- var customEqualityTesters = [function() { return true; }],
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: customEqualityTesters}),
+ it('supports custom equality testers', function() {
+ var customEqualityTesters = [
+ function() {
+ return true;
+ }
+ ],
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: customEqualityTesters
+ }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -28,25 +35,31 @@ describe("toHaveBeenCalledWith", function() {
expect(result.pass).toBe(true);
});
- it("fails when the actual was not called", function() {
+ it('fails when the actual was not called', function() {
var matchersUtil = {
- contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
- pp: jasmineUnderTest.makePrettyPrinter()
- },
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
- uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
- result;
+ contains: jasmine
+ .createSpy('delegated-contains')
+ .and.returnValue(false),
+ pp: jasmineUnderTest.makePrettyPrinter()
+ },
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
+ uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
+ result;
result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected spy uncalled spy to have been called with:\n [ ]\nbut it was never called.");
+ expect(result.message()).toEqual(
+ 'Expected spy uncalled spy to have been called with:\n [ ]\nbut it was never called.'
+ );
});
- it("fails when the actual was called with different parameters", function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
- calledSpy = new jasmineUnderTest.Spy('called spy'),
- result;
+ it('fails when the actual was called with different parameters', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
+ calledSpy = new jasmineUnderTest.Spy('called spy'),
+ result;
calledSpy('a');
calledSpy('c', 'd');
@@ -55,30 +68,32 @@ describe("toHaveBeenCalledWith", function() {
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
- "Expected spy called spy to have been called with:\n" +
- " [ 'a', 'b' ]\n" +
- "but actual calls were:\n" +
- " [ 'a' ],\n" +
- " [ 'c', 'd' ],\n" +
- " [ 'a', 'b', 'c' ].\n\n" +
- "Call 0:\n" +
- " Expected $.length = 1 to equal 2.\n" +
- " Expected $[1] = undefined to equal 'b'.\n" +
- "Call 1:\n" +
- " Expected $[0] = 'c' to equal 'a'.\n" +
- " Expected $[1] = 'd' to equal 'b'.\n" +
- "Call 2:\n" +
- " Expected $.length = 3 to equal 2.\n" +
- " Unexpected $[2] = 'c' in array.");
+ 'Expected spy called spy to have been called with:\n' +
+ " [ 'a', 'b' ]\n" +
+ 'but actual calls were:\n' +
+ " [ 'a' ],\n" +
+ " [ 'c', 'd' ],\n" +
+ " [ 'a', 'b', 'c' ].\n\n" +
+ 'Call 0:\n' +
+ ' Expected $.length = 1 to equal 2.\n' +
+ " Expected $[1] = undefined to equal 'b'.\n" +
+ 'Call 1:\n' +
+ " Expected $[0] = 'c' to equal 'a'.\n" +
+ " Expected $[1] = 'd' to equal 'b'.\n" +
+ 'Call 2:\n' +
+ ' Expected $.length = 3 to equal 2.\n' +
+ " Unexpected $[2] = 'c' in array."
+ );
});
- it("throws an exception when the actual is not a spy", function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({
pp: jasmineUnderTest.makePrettyPrinter()
}),
- fn = function () {
- };
+ fn = function() {};
- expect(function() { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
+ expect(function() {
+ matcher.compare(fn);
+ }).toThrowError(/Expected a spy, but got Function./);
});
});
diff --git a/spec/core/matchers/toHaveClassSpec.js b/spec/core/matchers/toHaveClassSpec.js
index 5f593abc..d56a0a16 100644
--- a/spec/core/matchers/toHaveClassSpec.js
+++ b/spec/core/matchers/toHaveClassSpec.js
@@ -5,7 +5,10 @@ describe('toHaveClass', function() {
it('fails for a DOM element that lacks the expected class', function() {
var matcher = jasmineUnderTest.matchers.toHaveClass(),
- result = matcher.compare(this.domHelpers.createElementWithClassName(''), 'foo');
+ result = matcher.compare(
+ this.domHelpers.createElementWithClassName(''),
+ 'foo'
+ );
expect(result.pass).toBe(false);
});
@@ -41,11 +44,11 @@ describe('toHaveClass', function() {
var textNode = this.domHelpers.document.createTextNode('');
expect(function() {
- matcher.compare(textNode, 'foo')
+ matcher.compare(textNode, 'foo');
}).toThrowError('HTMLNode is not a DOM element');
expect(function() {
- matcher.compare({classList: ''}, 'foo');
+ matcher.compare({ classList: '' }, 'foo');
}).toThrowError("Object({ classList: '' }) is not a DOM element");
});
});
diff --git a/spec/core/matchers/toHaveSizeSpec.js b/spec/core/matchers/toHaveSizeSpec.js
index d25e39e7..fc5baf91 100644
--- a/spec/core/matchers/toHaveSizeSpec.js
+++ b/spec/core/matchers/toHaveSizeSpec.js
@@ -18,28 +18,28 @@ describe('toHaveSize', function() {
it('passes for an object with the proper number of keys', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2}, 2);
+ result = matcher.compare({ a: 1, b: 2 }, 2);
expect(result.pass).toBe(true);
});
it('fails for an object with a different number of keys', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2}, 1);
+ result = matcher.compare({ a: 1, b: 2 }, 1);
expect(result.pass).toBe(false);
});
it('passes for an object with an explicit `length` property that matches', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2, length: 5}, 5);
+ result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
expect(result.pass).toBe(true);
});
it('fails for an object with an explicit `length` property that does not match', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2, length: 5}, 1);
+ result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
expect(result.pass).toBe(false);
});
@@ -62,8 +62,8 @@ describe('toHaveSize', function() {
jasmine.getEnv().requireFunctioningMaps();
var map = new Map();
- map.set('a',1);
- map.set('b',2);
+ map.set('a', 1);
+ map.set('b', 2);
var matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 2);
@@ -75,8 +75,8 @@ describe('toHaveSize', function() {
jasmine.getEnv().requireFunctioningMaps();
var map = new Map();
- map.set('a',1);
- map.set('b',2);
+ map.set('a', 1);
+ map.set('b', 2);
var matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 1);
diff --git a/spec/core/matchers/toMatchSpec.js b/spec/core/matchers/toMatchSpec.js
index b245e34d..aa4d6c54 100644
--- a/spec/core/matchers/toMatchSpec.js
+++ b/spec/core/matchers/toMatchSpec.js
@@ -1,6 +1,5 @@
-describe("toMatch", function() {
-
- it("passes when RegExps are equivalent", function() {
+describe('toMatch', function() {
+ it('passes when RegExps are equivalent', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -8,7 +7,7 @@ describe("toMatch", function() {
expect(result.pass).toBe(true);
});
- it("fails when RegExps are not equivalent", function() {
+ it('fails when RegExps are not equivalent', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -16,7 +15,7 @@ describe("toMatch", function() {
expect(result.pass).toBe(false);
});
- it("passes when the actual matches the expected string as a pattern", function() {
+ it('passes when the actual matches the expected string as a pattern', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -24,7 +23,7 @@ describe("toMatch", function() {
expect(result.pass).toBe(true);
});
- it("fails when the actual matches the expected string as a pattern", function() {
+ it('fails when the actual matches the expected string as a pattern', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -32,7 +31,7 @@ describe("toMatch", function() {
expect(result.pass).toBe(false);
});
- it("throws an Error when the expected is not a String or RegExp", function() {
+ it('throws an Error when the expected is not a String or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toMatch();
expect(function() {
@@ -40,4 +39,3 @@ describe("toMatch", function() {
}).toThrowError(/Expected is not a String or a RegExp/);
});
});
-
diff --git a/spec/core/matchers/toThrowErrorSpec.js b/spec/core/matchers/toThrowErrorSpec.js
index 68fdf8be..c8532276 100644
--- a/spec/core/matchers/toThrowErrorSpec.js
+++ b/spec/core/matchers/toThrowErrorSpec.js
@@ -1,5 +1,5 @@
-describe("toThrowError", function() {
- it("throws an error when the actual is not a function", function() {
+describe('toThrowError', function() {
+ it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowError();
expect(function() {
@@ -7,10 +7,10 @@ describe("toThrowError", function() {
}).toThrowError(/Actual is not a Function/);
});
- it("throws an error when the expected is not an Error, string, or RegExp", function() {
+ it('throws an error when the expected is not an Error, string, or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
@@ -18,21 +18,21 @@ describe("toThrowError", function() {
}).toThrowError(/Expected is not an Error, string, or RegExp./);
});
- it("throws an error when the expected error type is not an Error", function() {
+ it('throws an error when the expected error type is not an Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
- matcher.compare(fn, void 0, "foo");
+ matcher.compare(fn, void 0, 'foo');
}).toThrowError(/Expected error type is not an Error./);
});
- it("throws an error when the expected error message is not a string or RegExp", function() {
+ it('throws an error when the expected error message is not a string or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
@@ -40,7 +40,7 @@ describe("toThrowError", function() {
}).toThrowError(/Expected error message is not a string or RegExp./);
});
- it("fails if actual does not throw at all", function() {
+ it('fails if actual does not throw at all', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
return true;
@@ -50,10 +50,10 @@ describe("toThrowError", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected function to throw an Error.");
+ expect(result.message).toEqual('Expected function to throw an Error.');
});
- it("fails if thrown is not an instanceof Error", function() {
+ it('fails if thrown is not an instanceof Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -64,12 +64,14 @@ describe("toThrowError", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an Error, but it threw 4.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw an Error, but it threw 4.'
+ );
});
- describe("when error is from another frame", function() {
+ describe('when error is from another frame', function() {
function isNotRunningInBrowser() {
- return typeof document === 'undefined'
+ return typeof document === 'undefined';
}
var iframe = null;
@@ -80,31 +82,36 @@ describe("toThrowError", function() {
}
});
- it("passes if thrown is an instanceof Error regardless of global that contains its constructor", function() {
+ it('passes if thrown is an instanceof Error regardless of global that contains its constructor', function() {
if (isNotRunningInBrowser()) {
return;
}
var matcher = jasmineUnderTest.matchers.toThrowError();
- iframe = document.body.appendChild(document.createElement("iframe"));
- iframe.src = "about:blank";
+ iframe = document.body.appendChild(document.createElement('iframe'));
+ iframe.src = 'about:blank';
var iframeDocument = iframe.contentWindow.document;
if (iframeDocument.body) {
- iframeDocument.body.appendChild(iframeDocument.createElement("script"))
- .textContent = "function method() { throw new Error('foo'); }";
+ iframeDocument.body.appendChild(
+ iframeDocument.createElement('script')
+ ).textContent = "function method() { throw new Error('foo'); }";
} else {
// IE 10 and older
- iframeDocument.write("");
+ iframeDocument.write(
+ ""
+ );
}
var result = matcher.compare(iframe.contentWindow.method);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected function not to throw an Error, but it threw Error.");
+ expect(result.message).toEqual(
+ 'Expected function not to throw an Error, but it threw Error.'
+ );
});
});
- it("fails with the correct message if thrown is a falsy value", function() {
+ it('fails with the correct message if thrown is a falsy value', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -115,10 +122,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an Error, but it threw undefined.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw an Error, but it threw undefined.'
+ );
});
- it("passes if thrown is a type of Error, but there is no expected error", function() {
+ it('passes if thrown is a type of Error, but there is no expected error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new TypeError();
@@ -128,70 +137,80 @@ describe("toThrowError", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected function not to throw an Error, but it threw TypeError.");
+ expect(result.message).toEqual(
+ 'Expected function not to throw an Error, but it threw TypeError.'
+ );
});
- it("passes if thrown is an Error and the expected is the same message", function() {
+ it('passes if thrown is an Error and the expected is the same message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
},
result;
- result = matcher.compare(fn, "foo");
+ result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw an exception with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function not to throw an exception with message 'foo'."
+ );
});
- it("fails if thrown is an Error and the expected is not the same message", function() {
+ it('fails if thrown is an Error and the expected is not the same message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
},
result;
- result = matcher.compare(fn, "bar");
+ result = matcher.compare(fn, 'bar');
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'."
+ );
});
- it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
+ it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("a long message");
+ throw new Error('a long message');
},
result;
result = matcher.compare(fn, /long/);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw an exception with a message matching /long/.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw an exception with a message matching /long/.'
+ );
});
- it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
+ it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("a long message");
+ throw new Error('a long message');
},
result;
result = matcher.compare(fn, /foo/);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'."
+ );
});
- it("passes if thrown is an Error and the expected the same Error", function() {
+ it('passes if thrown is an Error and the expected the same Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
@@ -201,12 +220,14 @@ describe("toThrowError", function() {
result = matcher.compare(fn, Error);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw Error.");
+ expect(result.message()).toEqual('Expected function not to throw Error.');
});
- it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
+ it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
- CustomError = function CustomError(arg) { arg.x },
+ CustomError = function CustomError(arg) {
+ arg.x;
+ },
fn = function() {
throw new CustomError({ x: 1 });
},
@@ -217,10 +238,12 @@ describe("toThrowError", function() {
result = matcher.compare(fn, CustomError);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw CustomError.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw CustomError.'
+ );
});
- it("fails if thrown is an Error and the expected is a different Error", function() {
+ it('fails if thrown is an Error and the expected is a different Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
@@ -230,94 +253,108 @@ describe("toThrowError", function() {
result = matcher.compare(fn, TypeError);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw TypeError, but it threw Error.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw TypeError, but it threw Error.'
+ );
});
- it("passes if thrown is a type of Error and it is equal to the expected Error and message", function() {
+ it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
- result = matcher.compare(fn, TypeError, "foo");
+ result = matcher.compare(fn, TypeError, 'foo');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw TypeError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function not to throw TypeError with message 'foo'."
+ );
});
- it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", 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 matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
- CustomError = function CustomError(arg) { this.message = arg.message; },
+ CustomError = function CustomError(arg) {
+ this.message = arg.message;
+ },
fn = function() {
- throw new CustomError({message: "foo"});
+ throw new CustomError({ message: 'foo' });
},
result;
CustomError.prototype = new Error();
- result = matcher.compare(fn, CustomError, "foo");
+ result = matcher.compare(fn, CustomError, 'foo');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw CustomError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function not to throw CustomError with message 'foo'."
+ );
});
- it("fails if thrown is a type of Error and the expected is a different Error", function() {
+ it('fails if thrown is a type of Error and the expected is a different Error', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
- result = matcher.compare(fn, TypeError, "bar");
+ result = matcher.compare(fn, TypeError, 'bar');
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'."
+ );
});
- 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() {
+ 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 matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
result = matcher.compare(fn, TypeError, /foo/);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw TypeError with a message matching /foo/.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw TypeError with a message matching /foo/.'
+ );
});
- it("fails if thrown is a type of Error and the expected is a different Error", function() {
+ it('fails if thrown is a type of Error and the expected is a different Error', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
result = matcher.compare(fn, TypeError, /bar/);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw TypeError with a message matching /bar/, but it threw TypeError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw TypeError with a message matching /bar/, but it threw TypeError with message 'foo'."
+ );
});
});
diff --git a/spec/core/matchers/toThrowMatchingSpec.js b/spec/core/matchers/toThrowMatchingSpec.js
index 507683b0..a5ed2c5c 100644
--- a/spec/core/matchers/toThrowMatchingSpec.js
+++ b/spec/core/matchers/toThrowMatchingSpec.js
@@ -1,16 +1,18 @@
-describe("toThrowMatching", function() {
- it("throws an error when the actual is not a function", function() {
+describe('toThrowMatching', function() {
+ it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching();
expect(function() {
- matcher.compare({}, function() { return true; });
+ matcher.compare({}, function() {
+ return true;
+ });
}).toThrowError(/Actual is not a Function/);
});
- it("throws an error when the expected is not a function", function() {
+ it('throws an error when the expected is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
@@ -18,20 +20,22 @@ describe("toThrowMatching", function() {
}).toThrowError(/Predicate is not a Function/);
});
- it("fails if actual does not throw at all", function() {
+ it('fails if actual does not throw at all', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
fn = function() {
return true;
},
result;
- result = matcher.compare(fn, function() { return true; });
+ result = matcher.compare(fn, function() {
+ return true;
+ });
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected function to throw an exception.");
+ expect(result.message).toEqual('Expected function to throw an exception.');
});
- it("fails with the correct message if thrown is a falsy value", function() {
+ it('fails with the correct message if thrown is a falsy value', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -40,38 +44,50 @@ describe("toThrowMatching", function() {
},
result;
- result = matcher.compare(fn, function() { return false; });
+ result = matcher.compare(fn, function() {
+ return false;
+ });
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception matching a predicate, but it threw undefined.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw an exception matching a predicate, but it threw undefined.'
+ );
});
- it("passes if the argument is a function that returns true when called with the error", function() {
+ it('passes if the argument is a function that returns true when called with the error', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
- predicate = function(e) { return e.message === "nope" },
+ predicate = function(e) {
+ return e.message === 'nope';
+ },
fn = function() {
- throw new TypeError("nope");
+ throw new TypeError('nope');
},
result;
result = matcher.compare(fn, predicate);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected function not to throw an exception matching a predicate.");
+ expect(result.message).toEqual(
+ 'Expected function not to throw an exception matching a predicate.'
+ );
});
- it("fails if the argument is a function that returns false when called with the error", function() {
+ it('fails if the argument is a function that returns false when called with the error', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching({
pp: jasmineUnderTest.makePrettyPrinter()
}),
- predicate = function(e) { return e.message === "oh no" },
+ predicate = function(e) {
+ return e.message === 'oh no';
+ },
fn = function() {
- throw new TypeError("nope");
+ throw new TypeError('nope');
},
result;
result = matcher.compare(fn, predicate);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception matching a predicate, but it threw TypeError with message 'nope'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw an exception matching a predicate, but it threw TypeError with message 'nope'."
+ );
});
});
diff --git a/spec/core/matchers/toThrowSpec.js b/spec/core/matchers/toThrowSpec.js
index 7144b2b3..0ed049d3 100644
--- a/spec/core/matchers/toThrowSpec.js
+++ b/spec/core/matchers/toThrowSpec.js
@@ -1,6 +1,5 @@
-describe("toThrow", function() {
-
- it("throws an error when the actual is not a function", function() {
+describe('toThrow', function() {
+ it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrow();
expect(function() {
@@ -9,7 +8,7 @@ describe("toThrow", function() {
}).toThrowError(/Actual is not a Function/);
});
- it("fails if actual does not throw", function() {
+ it('fails if actual does not throw', function() {
var matcher = jasmineUnderTest.matchers.toThrow(),
fn = function() {
return true;
@@ -19,10 +18,10 @@ describe("toThrow", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected function to throw an exception.");
+ expect(result.message).toEqual('Expected function to throw an exception.');
});
- it("passes if it throws but there is no expected", function() {
+ it('passes if it throws but there is no expected', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -36,10 +35,12 @@ describe("toThrow", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw, but it threw 5.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw, but it threw 5.'
+ );
});
- it("passes even if what is thrown is falsy", function() {
+ it('passes even if what is thrown is falsy', function() {
var matcher = jasmineUnderTest.matchers.toThrow({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -50,10 +51,12 @@ describe("toThrow", function() {
result = matcher.compare(fn);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw, but it threw undefined.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw, but it threw undefined.'
+ );
});
- it("passes if what is thrown is equivalent to what is expected", function() {
+ it('passes if what is thrown is equivalent to what is expected', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -67,10 +70,10 @@ describe("toThrow", function() {
result = matcher.compare(fn, 5);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw 5.");
+ expect(result.message()).toEqual('Expected function not to throw 5.');
});
- it("fails if what is thrown is not equivalent to what is expected", function() {
+ it('fails if what is thrown is not equivalent to what is expected', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -81,13 +84,15 @@ describe("toThrow", function() {
},
result;
- result = matcher.compare(fn, "foo");
+ result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw 'foo', but it threw 5.");
+ expect(result.message()).toEqual(
+ "Expected function to throw 'foo', but it threw 5."
+ );
});
- it("fails if what is thrown is not equivalent to undefined", function() {
+ it('fails if what is thrown is not equivalent to undefined', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -101,6 +106,8 @@ describe("toThrow", function() {
result = matcher.compare(fn, void 0);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw undefined, but it threw 5.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw undefined, but it threw 5.'
+ );
});
});
diff --git a/spec/helpers/checkForArrayBuffer.js b/spec/helpers/checkForArrayBuffer.js
new file mode 100644
index 00000000..a04a94e9
--- /dev/null
+++ b/spec/helpers/checkForArrayBuffer.js
@@ -0,0 +1,25 @@
+/* eslint-disable compat/compat */
+(function(env) {
+ function hasFunctioningArrayBuffers() {
+ if (typeof ArrayBuffer === 'undefined') {
+ return false;
+ }
+
+ try {
+ var buffer = new ArrayBuffer(2);
+ var view8bit = new Uint8Array(buffer);
+ var view16bit = new Uint16Array(buffer);
+ view16bit[0] = 0xabcd;
+ return view8bit[0] === 0xcd && view8bit[1] === 0xab;
+ } catch (e) {
+ return false;
+ }
+ }
+
+ env.requireFunctioningArrayBuffers = function() {
+ env.requireFunctioningTypedArrays();
+ if (!hasFunctioningArrayBuffers()) {
+ env.pending('Browser has incomplete or missing support for ArrayBuffer');
+ }
+ };
+})(jasmine.getEnv());
diff --git a/spec/helpers/checkForUrl.js b/spec/helpers/checkForUrl.js
new file mode 100644
index 00000000..f8401fbb
--- /dev/null
+++ b/spec/helpers/checkForUrl.js
@@ -0,0 +1,17 @@
+/* eslint-disable compat/compat */
+(function(env) {
+ function hasUrlConstructor() {
+ try {
+ new URL('http://localhost/');
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+
+ env.requireUrls = function() {
+ if (!hasUrlConstructor()) {
+ env.pending('Environment does not support URLs');
+ }
+ };
+})(jasmine.getEnv());
diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js
index c41b68bb..2db0e160 100644
--- a/spec/html/HtmlReporterSpec.js
+++ b/spec/html/HtmlReporterSpec.js
@@ -104,6 +104,7 @@ describe('HtmlReporter', function() {
passedExpectations: [],
failedExpectations: []
});
+ /* eslint-disable-next-line no-console */
expect(console.warn).toHaveBeenCalledWith(
"Spec 'Some Name' has no expectations."
);
@@ -118,6 +119,7 @@ describe('HtmlReporter', function() {
passedExpectations: [],
failedExpectations: []
});
+ /* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
"Spec 'Some Name' has no expectations."
);
diff --git a/spec/support/jasmine-browser.js b/spec/support/jasmine-browser.js
index 86b7b974..e1bd519d 100644
--- a/spec/support/jasmine-browser.js
+++ b/spec/support/jasmine-browser.js
@@ -20,10 +20,12 @@ module.exports = {
'helpers/asyncAwait.js',
'helpers/generator.js',
'helpers/BrowserFlags.js',
+ 'helpers/checkForArrayBuffer.js',
'helpers/checkForMap.js',
'helpers/checkForSet.js',
'helpers/checkForSymbol.js',
'helpers/checkForTypedArrays.js',
+ 'helpers/checkForUrl.js',
'helpers/domHelpers.js',
'helpers/integrationMatchers.js',
'helpers/promises.js',
diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json
index b4e97736..91a178c7 100644
--- a/spec/support/jasmine.json
+++ b/spec/support/jasmine.json
@@ -7,10 +7,12 @@
"helpers": [
"helpers/asyncAwait.js",
"helpers/generator.js",
+ "helpers/checkForArrayBuffer.js",
"helpers/checkForMap.js",
"helpers/checkForSet.js",
"helpers/checkForSymbol.js",
"helpers/checkForTypedArrays.js",
+ "helpers/checkForUrl.js",
"helpers/domHelpers.js",
"helpers/integrationMatchers.js",
"helpers/promises.js",
diff --git a/src/core/Env.js b/src/core/Env.js
index 41bbea47..b76cde84 100644
--- a/src/core/Env.js
+++ b/src/core/Env.js
@@ -54,7 +54,7 @@ getJasmineRequireObj().Env = function(j$) {
* Null causes the seed to be determined randomly at the start of execution.
* @name Configuration#seed
* @since 3.3.0
- * @type function
+ * @type (number|string)
* @default null
*/
seed: null,
@@ -84,12 +84,19 @@ getJasmineRequireObj().Env = function(j$) {
* @default false
*/
oneFailurePerSpec: false,
+ /**
+ * A function that takes a spec and returns true if it should be executed
+ * or false if it should be skipped.
+ * @callback SpecFilter
+ * @param {Spec} spec - The spec that the filter is being applied to.
+ * @return boolean
+ */
/**
* Function to use to filter specs
* @name Configuration#specFilter
* @since 3.3.0
- * @type function
- * @default true
+ * @type SpecFilter
+ * @default A function that always returns true.
*/
specFilter: function() {
return true;
@@ -463,6 +470,9 @@ getJasmineRequireObj().Env = function(j$) {
resources.customAsyncMatchers = j$.util.clone(
runnableResources[parentRunnableId].customAsyncMatchers
);
+ resources.customObjectFormatters = j$.util.clone(
+ runnableResources[parentRunnableId].customObjectFormatters
+ );
resources.defaultStrategyFn =
runnableResources[parentRunnableId].defaultStrategyFn;
}
@@ -777,7 +787,27 @@ getJasmineRequireObj().Env = function(j$) {
queueRunnerFactory
);
- // Both params are optional.
+ /**
+ * Executes the specs.
+ *
+ * If called with no parameters or with a falsy value as the first parameter,
+ * all specs will be executed except those that are excluded by a
+ * [spec filter]{@link Configuration#specFilter} or other mechanism. If the
+ * first parameter is a list of spec/suite IDs, only those specs/suites will
+ * be run.
+ *
+ * Both parameters are optional, but a completion callback is only valid as
+ * the second parameter. To specify a completion callback but not a list of
+ * specs/suites to run, pass null or undefined as the first parameter.
+ *
+ * execute should not be called more than once.
+ *
+ * @name Env#execute
+ * @since 2.0.0
+ * @function
+ * @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
+ * @param {Function=} onComplete Function that will be called after all specs have run
+ */
this.execute = function(runnablesToRun, onComplete) {
installGlobalErrors();
@@ -969,6 +999,15 @@ getJasmineRequireObj().Env = function(j$) {
}
});
+ /**
+ * Configures whether Jasmine should allow the same function to be spied on
+ * more than once during the execution of a spec. By default, spying on
+ * a function that is already a spy will cause an error.
+ * @name Env#allowRespy
+ * @function
+ * @since 2.5.0
+ * @param {boolean} allow Whether to allow respying
+ */
this.allowRespy = function(allow) {
spyRegistry.allowRespy(allow);
};
diff --git a/src/core/ExceptionFormatter.js b/src/core/ExceptionFormatter.js
index e6927369..113f7af7 100644
--- a/src/core/ExceptionFormatter.js
+++ b/src/core/ExceptionFormatter.js
@@ -63,7 +63,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
stackTrace.style === 'webkit' ? '' : ' at ';
stackTrace.frames.forEach(function(frame) {
- if (frame.file && frame.file !== jasmineFile) {
+ if (frame.file !== jasmineFile) {
result.push(frame.raw);
} else if (result[result.length - 1] !== jasmineMarker) {
result.push(jasmineMarker);
diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js
index b79976d9..f0253b2d 100644
--- a/src/core/GlobalErrors.js
+++ b/src/core/GlobalErrors.js
@@ -67,9 +67,9 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
if (j$.isError_(event.reason)) {
event.reason.jasmineMessage =
'Unhandled promise rejection: ' + event.reason;
- onerror(event.reason);
+ global.onerror(event.reason);
} else {
- onerror('Unhandled promise rejection: ' + event.reason);
+ global.onerror('Unhandled promise rejection: ' + event.reason);
}
};
@@ -101,12 +101,6 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
throw new Error('popListener expects a listener');
}
- if (listener !== handlers[handlers.length - 1]) {
- throw new Error(
- 'popListener was passed a different listener than the current one'
- );
- }
-
handlers.pop();
};
}
diff --git a/src/core/Spec.js b/src/core/Spec.js
index 83d389d4..81d244dd 100644
--- a/src/core/Spec.js
+++ b/src/core/Spec.js
@@ -1,9 +1,19 @@
getJasmineRequireObj().Spec = function(j$) {
+ /**
+ * @interface Spec
+ * @see Configuration#specFilter
+ */
function Spec(attrs) {
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
this.resultCallback = attrs.resultCallback || function() {};
this.id = attrs.id;
+ /**
+ * The description passed to the {@link it} that created this spec.
+ * @name Spec#description
+ * @readonly
+ * @type {string}
+ */
this.description = attrs.description || '';
this.queueableFn = attrs.queueableFn;
this.beforeAndAfterFns =
@@ -195,6 +205,12 @@ getJasmineRequireObj().Spec = function(j$) {
return 'passed';
};
+ /**
+ * The full description including all ancestors of this spec.
+ * @name Spec#getFullName
+ * @function
+ * @returns {string}
+ */
Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};
diff --git a/src/core/SpyFactory.js b/src/core/SpyFactory.js
index 80c6b954..0f29a3b1 100644
--- a/src/core/SpyFactory.js
+++ b/src/core/SpyFactory.js
@@ -38,6 +38,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
var properties = normalizeKeyValues(propertyNames);
for (var i = 0; i < properties.length; i++) {
descriptor = {
+ enumerable: true,
get: self.createSpy(baseName + '.' + properties[i][0] + '.get'),
set: self.createSpy(baseName + '.' + properties[i][0] + '.set')
};
diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js
index 61273deb..bbee1bdc 100644
--- a/src/core/asymmetric_equality/Any.js
+++ b/src/core/asymmetric_equality/Any.js
@@ -1,10 +1,9 @@
getJasmineRequireObj().Any = function(j$) {
-
function Any(expectedObject) {
if (typeof expectedObject === 'undefined') {
throw new TypeError(
'jasmine.any() expects to be passed a constructor function. ' +
- 'Please pass one or use jasmine.anything() to match any object.'
+ 'Please pass one or use jasmine.anything() to match any object.'
);
}
this.expectedObject = expectedObject;
diff --git a/src/core/asymmetric_equality/Anything.js b/src/core/asymmetric_equality/Anything.js
index 11c6571c..ce436cb4 100644
--- a/src/core/asymmetric_equality/Anything.js
+++ b/src/core/asymmetric_equality/Anything.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().Anything = function(j$) {
-
function Anything() {}
Anything.prototype.asymmetricMatch = function(other) {
diff --git a/src/core/asymmetric_equality/ArrayContaining.js b/src/core/asymmetric_equality/ArrayContaining.js
index ce60c830..6f8765aa 100644
--- a/src/core/asymmetric_equality/ArrayContaining.js
+++ b/src/core/asymmetric_equality/ArrayContaining.js
@@ -5,7 +5,11 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isArray_(this.sample)) {
- throw new Error('You must provide an array to arrayContaining, not ' + j$.basicPrettyPrinter_(this.sample) + '.');
+ throw new Error(
+ 'You must provide an array to arrayContaining, not ' +
+ j$.basicPrettyPrinter_(this.sample) +
+ '.'
+ );
}
// If the actual parameter is not an array, we can fail immediately, since it couldn't
@@ -25,8 +29,8 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
return true;
};
- ArrayContaining.prototype.jasmineToString = function (pp) {
- return '';
+ ArrayContaining.prototype.jasmineToString = function(pp) {
+ return '';
};
return ArrayContaining;
diff --git a/src/core/asymmetric_equality/ArrayWithExactContents.js b/src/core/asymmetric_equality/ArrayWithExactContents.js
index 1a804056..fe3043b0 100644
--- a/src/core/asymmetric_equality/ArrayWithExactContents.js
+++ b/src/core/asymmetric_equality/ArrayWithExactContents.js
@@ -1,12 +1,18 @@
getJasmineRequireObj().ArrayWithExactContents = function(j$) {
-
function ArrayWithExactContents(sample) {
this.sample = sample;
}
- ArrayWithExactContents.prototype.asymmetricMatch = function(other, matchersUtil) {
+ ArrayWithExactContents.prototype.asymmetricMatch = function(
+ other,
+ matchersUtil
+ ) {
if (!j$.isArray_(this.sample)) {
- throw new Error('You must provide an array to arrayWithExactContents, not ' + j$.basicPrettyPrinter_(this.sample) + '.');
+ throw new Error(
+ 'You must provide an array to arrayWithExactContents, not ' +
+ j$.basicPrettyPrinter_(this.sample) +
+ '.'
+ );
}
if (this.sample.length !== other.length) {
diff --git a/src/core/asymmetric_equality/Empty.js b/src/core/asymmetric_equality/Empty.js
index 224c0f5f..1dd28948 100644
--- a/src/core/asymmetric_equality/Empty.js
+++ b/src/core/asymmetric_equality/Empty.js
@@ -1,8 +1,7 @@
-getJasmineRequireObj().Empty = function (j$) {
-
+getJasmineRequireObj().Empty = function(j$) {
function Empty() {}
- Empty.prototype.asymmetricMatch = function (other) {
+ Empty.prototype.asymmetricMatch = function(other) {
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
return other.length === 0;
}
@@ -17,7 +16,7 @@ getJasmineRequireObj().Empty = function (j$) {
return false;
};
- Empty.prototype.jasmineToString = function () {
+ Empty.prototype.jasmineToString = function() {
return '';
};
diff --git a/src/core/asymmetric_equality/Falsy.js b/src/core/asymmetric_equality/Falsy.js
index 242e0af3..d1d3c8ff 100644
--- a/src/core/asymmetric_equality/Falsy.js
+++ b/src/core/asymmetric_equality/Falsy.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().Falsy = function(j$) {
-
function Falsy() {}
Falsy.prototype.asymmetricMatch = function(other) {
diff --git a/src/core/asymmetric_equality/MapContaining.js b/src/core/asymmetric_equality/MapContaining.js
index a35048e6..8e29fbe9 100644
--- a/src/core/asymmetric_equality/MapContaining.js
+++ b/src/core/asymmetric_equality/MapContaining.js
@@ -1,7 +1,10 @@
getJasmineRequireObj().MapContaining = function(j$) {
function MapContaining(sample) {
if (!j$.isMap(sample)) {
- throw new Error('You must provide a map to `mapContaining`, not ' + j$.basicPrettyPrinter_(sample));
+ throw new Error(
+ 'You must provide a map to `mapContaining`, not ' +
+ j$.basicPrettyPrinter_(sample)
+ );
}
this.sample = sample;
@@ -17,8 +20,8 @@ getJasmineRequireObj().MapContaining = function(j$) {
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
if (
- matchersUtil.equals(oKey, key)
- && matchersUtil.equals(oValue, value)
+ matchersUtil.equals(oKey, key) &&
+ matchersUtil.equals(oValue, value)
) {
hasMatch = true;
oBreakLoop();
diff --git a/src/core/asymmetric_equality/NotEmpty.js b/src/core/asymmetric_equality/NotEmpty.js
index 3c0368cf..361b6978 100644
--- a/src/core/asymmetric_equality/NotEmpty.js
+++ b/src/core/asymmetric_equality/NotEmpty.js
@@ -1,8 +1,7 @@
-getJasmineRequireObj().NotEmpty = function (j$) {
-
+getJasmineRequireObj().NotEmpty = function(j$) {
function NotEmpty() {}
- NotEmpty.prototype.asymmetricMatch = function (other) {
+ NotEmpty.prototype.asymmetricMatch = function(other) {
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
return other.length !== 0;
}
@@ -18,7 +17,7 @@ getJasmineRequireObj().NotEmpty = function (j$) {
return false;
};
- NotEmpty.prototype.jasmineToString = function () {
+ NotEmpty.prototype.jasmineToString = function() {
return '';
};
diff --git a/src/core/asymmetric_equality/ObjectContaining.js b/src/core/asymmetric_equality/ObjectContaining.js
index 4a8f4385..5e473033 100644
--- a/src/core/asymmetric_equality/ObjectContaining.js
+++ b/src/core/asymmetric_equality/ObjectContaining.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().ObjectContaining = function(j$) {
-
function ObjectContaining(sample) {
this.sample = sample;
}
@@ -17,7 +16,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
}
function hasProperty(obj, property) {
- if (!obj || typeof(obj) !== 'object') {
+ if (!obj || typeof obj !== 'object') {
return false;
}
@@ -29,12 +28,22 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
}
ObjectContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
- if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
- if (typeof(other) !== 'object') { return false; }
+ if (typeof this.sample !== 'object') {
+ throw new Error(
+ "You must provide an object to objectContaining, not '" +
+ this.sample +
+ "'."
+ );
+ }
+ if (typeof other !== 'object') {
+ return false;
+ }
for (var property in this.sample) {
- if (!hasProperty(other, property) ||
- !matchersUtil.equals(this.sample[property], other[property])) {
+ if (
+ !hasProperty(other, property) ||
+ !matchersUtil.equals(this.sample[property], other[property])
+ ) {
return false;
}
}
@@ -51,7 +60,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
}
var filteredOther = {};
- Object.keys(this.sample).forEach(function (k) {
+ Object.keys(this.sample).forEach(function(k) {
// eq short-circuits comparison of objects that have different key sets,
// so include all keys even if undefined.
filteredOther[k] = other[k];
diff --git a/src/core/asymmetric_equality/SetContaining.js b/src/core/asymmetric_equality/SetContaining.js
index 759cc546..fe4d6293 100644
--- a/src/core/asymmetric_equality/SetContaining.js
+++ b/src/core/asymmetric_equality/SetContaining.js
@@ -1,7 +1,10 @@
getJasmineRequireObj().SetContaining = function(j$) {
function SetContaining(sample) {
if (!j$.isSet(sample)) {
- throw new Error('You must provide a set to `setContaining`, not ' + j$.basicPrettyPrinter_(sample));
+ throw new Error(
+ 'You must provide a set to `setContaining`, not ' +
+ j$.basicPrettyPrinter_(sample)
+ );
}
this.sample = sample;
diff --git a/src/core/asymmetric_equality/StringMatching.js b/src/core/asymmetric_equality/StringMatching.js
index 72334723..ebcc1738 100644
--- a/src/core/asymmetric_equality/StringMatching.js
+++ b/src/core/asymmetric_equality/StringMatching.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().StringMatching = function(j$) {
-
function StringMatching(expected) {
if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
throw new Error('Expected is not a String or a RegExp');
diff --git a/src/core/asymmetric_equality/Truthy.js b/src/core/asymmetric_equality/Truthy.js
index a852fdaf..9e527164 100644
--- a/src/core/asymmetric_equality/Truthy.js
+++ b/src/core/asymmetric_equality/Truthy.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().Truthy = function(j$) {
-
function Truthy() {}
Truthy.prototype.asymmetricMatch = function(other) {
diff --git a/src/core/base.js b/src/core/base.js
index d02606d5..3c1da322 100644
--- a/src/core/base.js
+++ b/src/core/base.js
@@ -161,6 +161,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
);
};
+ j$.isURL = function(obj) {
+ return (
+ obj !== null &&
+ typeof obj !== 'undefined' &&
+ typeof jasmineGlobal.URL !== 'undefined' &&
+ obj.constructor === jasmineGlobal.URL
+ );
+ };
+
j$.isDataView = function(obj) {
return (
obj !== null &&
@@ -335,6 +344,14 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return new j$.SetContaining(sample);
};
+ /**
+ * Determines whether the provided function is a Jasmine spy.
+ * @name jasmine.isSpy
+ * @since 2.0.0
+ * @function
+ * @param {Function} putativeSpy - The function to check.
+ * @return {Boolean}
+ */
j$.isSpy = function(putativeSpy) {
if (!putativeSpy) {
return false;
diff --git a/src/core/matchers/DiffBuilder.js b/src/core/matchers/DiffBuilder.js
index 70b52ea7..c8c0e497 100644
--- a/src/core/matchers/DiffBuilder.js
+++ b/src/core/matchers/DiffBuilder.js
@@ -1,4 +1,4 @@
-getJasmineRequireObj().DiffBuilder = function (j$) {
+getJasmineRequireObj().DiffBuilder = function(j$) {
return function DiffBuilder(config) {
var prettyPrinter = (config || {}).prettyPrinter || j$.makePrettyPrinter(),
mismatches = new j$.MismatchTree(),
@@ -7,21 +7,28 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
expectedRoot = undefined;
return {
- setRoots: function (actual, expected) {
+ setRoots: function(actual, expected) {
actualRoot = actual;
expectedRoot = expected;
},
- recordMismatch: function (formatter) {
+ recordMismatch: function(formatter) {
mismatches.add(path, formatter);
},
- getMessage: function () {
+ getMessage: function() {
var messages = [];
- mismatches.traverse(function (path, isLeaf, formatter) {
- var actualCustom, expectedCustom, useCustom,
- derefResult = dereferencePath(path, actualRoot, expectedRoot, prettyPrinter),
+ mismatches.traverse(function(path, isLeaf, formatter) {
+ var actualCustom,
+ expectedCustom,
+ useCustom,
+ derefResult = dereferencePath(
+ path,
+ actualRoot,
+ expectedRoot,
+ prettyPrinter
+ ),
actual = derefResult.actual,
expected = derefResult.expected;
@@ -32,15 +39,22 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
actualCustom = prettyPrinter.customFormat_(actual);
expectedCustom = prettyPrinter.customFormat_(expected);
- useCustom = !(j$.util.isUndefined(actualCustom) && j$.util.isUndefined(expectedCustom));
+ useCustom = !(
+ j$.util.isUndefined(actualCustom) &&
+ j$.util.isUndefined(expectedCustom)
+ );
if (useCustom) {
- messages.push(wrapPrettyPrinted(actualCustom, expectedCustom, path));
+ messages.push(
+ wrapPrettyPrinted(actualCustom, expectedCustom, path)
+ );
return false; // don't recurse further
}
if (isLeaf) {
- messages.push(defaultFormatter(actual, expected, path, prettyPrinter));
+ messages.push(
+ defaultFormatter(actual, expected, path, prettyPrinter)
+ );
}
return true;
@@ -49,7 +63,7 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
return messages.join('\n');
},
- withPath: function (pathComponent, block) {
+ withPath: function(pathComponent, block) {
var oldPath = path;
path = path.add(pathComponent);
block();
@@ -58,22 +72,32 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
};
function defaultFormatter(actual, expected, path, prettyPrinter) {
- return wrapPrettyPrinted(prettyPrinter(actual), prettyPrinter(expected), path);
+ return wrapPrettyPrinted(
+ prettyPrinter(actual),
+ prettyPrinter(expected),
+ path
+ );
}
function wrapPrettyPrinted(actual, expected, path) {
- return 'Expected ' +
- path + (path.depth() ? ' = ' : '') +
+ return (
+ 'Expected ' +
+ path +
+ (path.depth() ? ' = ' : '') +
actual +
' to equal ' +
expected +
- '.';
+ '.'
+ );
}
};
function dereferencePath(objectPath, actual, expected, pp) {
function handleAsymmetricExpected() {
- if (j$.isAsymmetricEqualityTester_(expected) && j$.isFunction_(expected.valuesForDiff_)) {
+ if (
+ j$.isAsymmetricEqualityTester_(expected) &&
+ j$.isFunction_(expected.valuesForDiff_)
+ ) {
var asymmetricResult = expected.valuesForDiff_(actual, pp);
expected = asymmetricResult.self;
actual = asymmetricResult.other;
@@ -89,7 +113,6 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
handleAsymmetricExpected();
}
- return {actual: actual, expected: expected};
+ return { actual: actual, expected: expected };
}
-
};
diff --git a/src/core/matchers/MismatchTree.js b/src/core/matchers/MismatchTree.js
index 1ce356de..3fdab889 100644
--- a/src/core/matchers/MismatchTree.js
+++ b/src/core/matchers/MismatchTree.js
@@ -1,5 +1,4 @@
-getJasmineRequireObj().MismatchTree = function (j$) {
-
+getJasmineRequireObj().MismatchTree = function(j$) {
/*
To be able to apply custom object formatters at all possible levels of an
object graph, DiffBuilder needs to be able to know not just where the
@@ -14,7 +13,7 @@ getJasmineRequireObj().MismatchTree = function (j$) {
this.isMismatch = false;
}
- MismatchTree.prototype.add = function (path, formatter) {
+ MismatchTree.prototype.add = function(path, formatter) {
var key, child;
if (path.depth() === 0) {
@@ -34,8 +33,9 @@ getJasmineRequireObj().MismatchTree = function (j$) {
}
};
- MismatchTree.prototype.traverse = function (visit) {
- var i, hasChildren = this.children.length > 0;
+ MismatchTree.prototype.traverse = function(visit) {
+ var i,
+ hasChildren = this.children.length > 0;
if (this.isMismatch || hasChildren) {
if (visit(this.path, !hasChildren, this.formatter)) {
@@ -59,4 +59,3 @@ getJasmineRequireObj().MismatchTree = function (j$) {
return MismatchTree;
};
-
diff --git a/src/core/matchers/ObjectPath.js b/src/core/matchers/ObjectPath.js
index a9acfdb2..2ffc8843 100644
--- a/src/core/matchers/ObjectPath.js
+++ b/src/core/matchers/ObjectPath.js
@@ -32,7 +32,7 @@ getJasmineRequireObj().ObjectPath = function(j$) {
return '.' + prop;
}
- return '[\'' + prop + '\']';
+ return "['" + prop + "']";
}
function map(array, fn) {
diff --git a/src/core/matchers/async/toBePending.js b/src/core/matchers/async/toBePending.js
index c73aa3d3..1e438d4f 100644
--- a/src/core/matchers/async/toBePending.js
+++ b/src/core/matchers/async/toBePending.js
@@ -17,8 +17,12 @@ getJasmineRequireObj().toBePending = function(j$) {
}
var want = {};
return Promise.race([actual, Promise.resolve(want)]).then(
- function(got) { return {pass: want === got}; },
- function() { return {pass: false}; }
+ function(got) {
+ return { pass: want === got };
+ },
+ function() {
+ return { pass: false };
+ }
);
}
};
diff --git a/src/core/matchers/async/toBeRejected.js b/src/core/matchers/async/toBeRejected.js
index 3ec95bf3..d75fa34f 100644
--- a/src/core/matchers/async/toBeRejected.js
+++ b/src/core/matchers/async/toBeRejected.js
@@ -17,8 +17,12 @@ getJasmineRequireObj().toBeRejected = function(j$) {
throw new Error('Expected toBeRejected to be called on a promise.');
}
return actual.then(
- function() { return {pass: false}; },
- function() { return {pass: true}; }
+ function() {
+ return { pass: false };
+ },
+ function() {
+ return { pass: true };
+ }
);
}
};
diff --git a/src/core/matchers/async/toBeRejectedWith.js b/src/core/matchers/async/toBeRejectedWith.js
index 6c0af904..7436dbc7 100644
--- a/src/core/matchers/async/toBeRejectedWith.js
+++ b/src/core/matchers/async/toBeRejectedWith.js
@@ -15,35 +15,44 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
return {
compare: function(actualPromise, expectedValue) {
if (!j$.isPromiseLike(actualPromise)) {
- throw new Error('Expected toBeRejectedWith to be called on a promise.');
+ throw new Error(
+ 'Expected toBeRejectedWith to be called on a promise.'
+ );
}
function prefix(passed) {
- return 'Expected a promise ' +
+ return (
+ 'Expected a promise ' +
(passed ? 'not ' : '') +
- 'to be rejected with ' + matchersUtil.pp(expectedValue);
+ 'to be rejected with ' +
+ matchersUtil.pp(expectedValue)
+ );
}
return actualPromise.then(
function() {
- return {
- pass: false,
- message: prefix(false) + ' but it was resolved.'
- };
- },
- function(actualValue) {
- if (matchersUtil.equals(actualValue, expectedValue)) {
- return {
- pass: true,
- message: prefix(true) + '.'
- };
- } else {
return {
pass: false,
- message: prefix(false) + ' but it was rejected with ' + matchersUtil.pp(actualValue) + '.'
+ message: prefix(false) + ' but it was resolved.'
};
+ },
+ function(actualValue) {
+ if (matchersUtil.equals(actualValue, expectedValue)) {
+ return {
+ pass: true,
+ message: prefix(true) + '.'
+ };
+ } else {
+ return {
+ pass: false,
+ message:
+ prefix(false) +
+ ' but it was rejected with ' +
+ matchersUtil.pp(actualValue) +
+ '.'
+ };
+ }
}
- }
);
}
};
diff --git a/src/core/matchers/async/toBeRejectedWithError.js b/src/core/matchers/async/toBeRejectedWithError.js
index 203cd863..5b2aed52 100644
--- a/src/core/matchers/async/toBeRejectedWithError.js
+++ b/src/core/matchers/async/toBeRejectedWithError.js
@@ -18,7 +18,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
return {
compare: function(actualPromise, arg1, arg2) {
if (!j$.isPromiseLike(actualPromise)) {
- throw new Error('Expected toBeRejectedWithError to be called on a promise.');
+ throw new Error(
+ 'Expected toBeRejectedWithError to be called on a promise.'
+ );
}
var expected = getExpectedFromArgs(arg1, arg2, matchersUtil);
@@ -30,7 +32,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
message: 'Expected a promise to be rejected but it was resolved.'
};
},
- function(actualValue) { return matchError(actualValue, expected, matchersUtil); }
+ function(actualValue) {
+ return matchError(actualValue, expected, matchersUtil);
+ }
);
}
};
@@ -42,16 +46,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
}
if (!(actual instanceof expected.error)) {
- return fail(expected, 'rejected with type ' + j$.fnNameFor(actual.constructor));
+ return fail(
+ expected,
+ 'rejected with type ' + j$.fnNameFor(actual.constructor)
+ );
}
var actualMessage = actual.message;
- if (actualMessage === expected.message || typeof expected.message === 'undefined') {
+ if (
+ actualMessage === expected.message ||
+ typeof expected.message === 'undefined'
+ ) {
return pass(expected);
}
- if (expected.message instanceof RegExp && expected.message.test(actualMessage)) {
+ if (
+ expected.message instanceof RegExp &&
+ expected.message.test(actualMessage)
+ ) {
return pass(expected);
}
@@ -61,18 +74,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
function pass(expected) {
return {
pass: true,
- message: 'Expected a promise not to be rejected with ' + expected.printValue + ', but it was.'
+ message:
+ 'Expected a promise not to be rejected with ' +
+ expected.printValue +
+ ', but it was.'
};
}
function fail(expected, message) {
return {
pass: false,
- message: 'Expected a promise to be rejected with ' + expected.printValue + ' but it was ' + message + '.'
+ message:
+ 'Expected a promise to be rejected with ' +
+ expected.printValue +
+ ' but it was ' +
+ message +
+ '.'
};
}
-
function getExpectedFromArgs(arg1, arg2, matchersUtil) {
var error, message;
@@ -87,11 +107,16 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
return {
error: error,
message: message,
- printValue: j$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
+ printValue:
+ j$.fnNameFor(error) +
+ (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
};
}
function isErrorConstructor(value) {
- return typeof value === 'function' && (value === Error || j$.isError_(value.prototype));
+ return (
+ typeof value === 'function' &&
+ (value === Error || j$.isError_(value.prototype))
+ );
}
};
diff --git a/src/core/matchers/async/toBeResolved.js b/src/core/matchers/async/toBeResolved.js
index 997ddeea..b9dda27a 100644
--- a/src/core/matchers/async/toBeResolved.js
+++ b/src/core/matchers/async/toBeResolved.js
@@ -18,8 +18,12 @@ getJasmineRequireObj().toBeResolved = function(j$) {
}
return actual.then(
- function() { return {pass: true}; },
- function() { return {pass: false}; }
+ function() {
+ return { pass: true };
+ },
+ function() {
+ return { pass: false };
+ }
);
}
};
diff --git a/src/core/matchers/async/toBeResolvedTo.js b/src/core/matchers/async/toBeResolvedTo.js
index 61abb9f2..f95e7b10 100644
--- a/src/core/matchers/async/toBeResolvedTo.js
+++ b/src/core/matchers/async/toBeResolvedTo.js
@@ -19,9 +19,12 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
}
function prefix(passed) {
- return 'Expected a promise ' +
+ return (
+ 'Expected a promise ' +
(passed ? 'not ' : '') +
- 'to be resolved to ' + matchersUtil.pp(expectedValue);
+ 'to be resolved to ' +
+ matchersUtil.pp(expectedValue)
+ );
}
return actualPromise.then(
@@ -34,7 +37,11 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
} else {
return {
pass: false,
- message: prefix(false) + ' but it was resolved to ' + matchersUtil.pp(actualValue) + '.'
+ message:
+ prefix(false) +
+ ' but it was resolved to ' +
+ matchersUtil.pp(actualValue) +
+ '.'
};
}
},
diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js
index 3bc912c3..9f488854 100644
--- a/src/core/matchers/matchersUtil.js
+++ b/src/core/matchers/matchersUtil.js
@@ -19,7 +19,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @return {string} The pretty-printed value
*/
this.pp = options.pp || function() {};
- };
+ }
/**
* Determines whether `haystack` contains `needle`, using the same comparison
@@ -35,18 +35,21 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
*/
MatchersUtil.prototype.contains = function(haystack, needle, customTesters) {
if (customTesters) {
- j$.getEnv().deprecatedOnceWithStack('Passing custom equality testers ' +
- 'to MatchersUtil#contains is deprecated. ' +
- 'See for details.');
+ j$.getEnv().deprecatedOnceWithStack(
+ 'Passing custom equality testers ' +
+ 'to MatchersUtil#contains is deprecated. ' +
+ 'See for details.'
+ );
}
if (j$.isSet(haystack)) {
return haystack.has(needle);
}
- if ((Object.prototype.toString.apply(haystack) === '[object Array]') ||
- (!!haystack && !haystack.indexOf))
- {
+ if (
+ Object.prototype.toString.apply(haystack) === '[object Array]' ||
+ (!!haystack && !haystack.indexOf)
+ ) {
for (var i = 0; i < haystack.length; i++) {
if (this.equals(haystack[i], needle, customTesters)) {
return true;
@@ -65,9 +68,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
isNot = args[1],
actual = args[2],
expected = args.slice(3),
- englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
+ englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
+ return ' ' + s.toLowerCase();
+ });
- var message = 'Expected ' +
+ var message =
+ 'Expected ' +
self.pp(actual) +
(isNot ? ' not ' : ' ') +
englishyPredicate;
@@ -84,20 +90,41 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return message + '.';
};
- MatchersUtil.prototype.asymmetricDiff_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
+ MatchersUtil.prototype.asymmetricDiff_ = function(
+ a,
+ b,
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ ) {
if (j$.isFunction_(b.valuesForDiff_)) {
var values = b.valuesForDiff_(a, this.pp);
- this.eq_(values.other, values.self, aStack, bStack, customTesters, diffBuilder);
+ this.eq_(
+ values.other,
+ values.self,
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ );
} else {
diffBuilder.recordMismatch();
}
};
- MatchersUtil.prototype.asymmetricMatch_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
+ MatchersUtil.prototype.asymmetricMatch_ = function(
+ a,
+ b,
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ ) {
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
- asymmetricB = j$.isAsymmetricEqualityTester_(b),
- shim,
- result;
+ asymmetricB = j$.isAsymmetricEqualityTester_(b),
+ shim,
+ result;
if (asymmetricA === asymmetricB) {
return undefined;
@@ -133,22 +160,31 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
* @returns {boolean} True if the values are equal
*/
- MatchersUtil.prototype.equals = function(a, b, customTestersOrDiffBuilder, diffBuilderOrNothing) {
+ MatchersUtil.prototype.equals = function(
+ a,
+ b,
+ customTestersOrDiffBuilder,
+ diffBuilderOrNothing
+ ) {
var customTesters, diffBuilder;
if (isDiffBuilder(customTestersOrDiffBuilder)) {
diffBuilder = customTestersOrDiffBuilder;
} else {
if (customTestersOrDiffBuilder) {
- j$.getEnv().deprecatedOnceWithStack('Passing custom equality testers ' +
- 'to MatchersUtil#equals is deprecated. ' +
- 'See for details.');
+ j$.getEnv().deprecatedOnceWithStack(
+ 'Passing custom equality testers ' +
+ 'to MatchersUtil#equals is deprecated. ' +
+ 'See for details.'
+ );
}
if (diffBuilderOrNothing) {
- j$.getEnv().deprecatedOnceWithStack('Diff builder should be passed ' +
- 'as the third argument to MatchersUtil#equals, not the fourth. ' +
- 'See for details.');
+ j$.getEnv().deprecatedOnceWithStack(
+ 'Diff builder should be passed ' +
+ 'as the third argument to MatchersUtil#equals, not the fourth. ' +
+ 'See for details.'
+ );
}
customTesters = customTestersOrDiffBuilder;
@@ -164,10 +200,26 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
- MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
- var result = true, self = this, i;
+ MatchersUtil.prototype.eq_ = function(
+ a,
+ b,
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ ) {
+ var result = true,
+ self = this,
+ i;
- var asymmetricResult = this.asymmetricMatch_(a, b, aStack, bStack, customTesters, diffBuilder);
+ var asymmetricResult = this.asymmetricMatch_(
+ a,
+ b,
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ );
if (!j$.util.isUndefined(asymmetricResult)) {
return asymmetricResult;
}
@@ -225,7 +277,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
- result = a != +a ? b != +b : (a === 0 && b === 0 ? 1 / a == 1 / b : a == +b);
+ result =
+ a != +a ? b != +b : a === 0 && b === 0 ? 1 / a == 1 / b : a == +b;
if (!result) {
diffBuilder.recordMismatch();
}
@@ -240,12 +293,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
diffBuilder.recordMismatch();
}
return result;
+ case '[object ArrayBuffer]':
+ // If we have an instance of ArrayBuffer the Uint8Array ctor
+ // will be defined as well
+ return self.eq_(
+ new Uint8Array(a), // eslint-disable-line compat/compat
+ new Uint8Array(b), // eslint-disable-line compat/compat
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ );
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
- return a.source == b.source &&
+ return (
+ a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
- a.ignoreCase == b.ignoreCase;
+ a.ignoreCase == b.ignoreCase
+ );
}
if (typeof a != 'object' || typeof b != 'object') {
diffBuilder.recordMismatch();
@@ -279,7 +345,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
- if (aStack[length] == a) { return bStack[length] == b; }
+ if (aStack[length] == a) {
+ return bStack[length] == b;
+ }
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
@@ -301,10 +369,20 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
for (i = 0; i < aLength || i < bLength; i++) {
diffBuilder.withPath(i, function() {
if (i >= bLength) {
- diffBuilder.recordMismatch(actualArrayIsLongerFormatter.bind(null, self.pp));
+ diffBuilder.recordMismatch(
+ actualArrayIsLongerFormatter.bind(null, self.pp)
+ );
result = false;
} else {
- result = self.eq_(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
+ result =
+ self.eq_(
+ i < aLength ? a[i] : void 0,
+ i < bLength ? b[i] : void 0,
+ aStack,
+ bStack,
+ customTesters,
+ diffBuilder
+ ) && result;
}
});
}
@@ -319,11 +397,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
var keysA = [];
var keysB = [];
- a.forEach( function( valueA, keyA ) {
- keysA.push( keyA );
+ a.forEach(function(valueA, keyA) {
+ keysA.push(keyA);
});
- b.forEach( function( valueB, keyB ) {
- keysB.push( keyB );
+ b.forEach(function(valueB, keyB) {
+ keysB.push(keyB);
});
// For both sets of keys, check they map to equal values in both maps.
@@ -344,13 +422,30 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
// Only use the cmpKey when one of the keys is asymmetric and the corresponding key matches,
// otherwise explicitly look up the mapKey in the other Map since we want keys with unique
// obj identity (that are otherwise equal) to not match.
- if (j$.isAsymmetricEqualityTester_(mapKey) || j$.isAsymmetricEqualityTester_(cmpKey) &&
- this.eq_(mapKey, cmpKey, aStack, bStack, customTesters, j$.NullDiffBuilder())) {
+ if (
+ j$.isAsymmetricEqualityTester_(mapKey) ||
+ (j$.isAsymmetricEqualityTester_(cmpKey) &&
+ this.eq_(
+ mapKey,
+ cmpKey,
+ aStack,
+ bStack,
+ customTesters,
+ j$.NullDiffBuilder()
+ ))
+ ) {
mapValueB = b.get(cmpKey);
} else {
mapValueB = b.get(mapKey);
}
- result = this.eq_(mapValueA, mapValueB, aStack, bStack, customTesters, j$.NullDiffBuilder());
+ result = this.eq_(
+ mapValueA,
+ mapValueB,
+ aStack,
+ bStack,
+ customTesters,
+ j$.NullDiffBuilder()
+ );
}
}
@@ -365,12 +460,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
}
var valuesA = [];
- a.forEach( function( valueA ) {
- valuesA.push( valueA );
+ a.forEach(function(valueA) {
+ valuesA.push(valueA);
});
var valuesB = [];
- b.forEach( function( valueB ) {
- valuesB.push( valueB );
+ b.forEach(function(valueB) {
+ valuesB.push(valueB);
});
// For both sets, check they are all contained in the other set
@@ -394,7 +489,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
otherValue = otherValues[l];
prevStackSize = baseStack.length;
// compare by value equality
- found = this.eq_(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
+ found = this.eq_(
+ baseValue,
+ otherValue,
+ baseStack,
+ otherStack,
+ customTesters,
+ j$.NullDiffBuilder()
+ );
if (!found && prevStackSize !== baseStack.length) {
baseStack.splice(prevStackSize);
otherStack.splice(prevStackSize);
@@ -408,28 +510,40 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
diffBuilder.recordMismatch();
return false;
}
+ } else if (j$.isURL(a) && j$.isURL(b)) {
+ // URLs have no enumrable properties, so the default object comparison
+ // would consider any two URLs to be equal.
+ return a.toString() === b.toString();
} else {
-
// Objects with different constructors are not equivalent, but `Object`s
// or `Array`s from different frames are.
- var aCtor = a.constructor, bCtor = b.constructor;
- if (aCtor !== bCtor &&
- isFunction(aCtor) && isFunction(bCtor) &&
- a instanceof aCtor && b instanceof bCtor &&
- !(aCtor instanceof aCtor && bCtor instanceof bCtor)) {
-
- diffBuilder.recordMismatch(constructorsAreDifferentFormatter.bind(null, this.pp));
+ var aCtor = a.constructor,
+ bCtor = b.constructor;
+ if (
+ aCtor !== bCtor &&
+ isFunction(aCtor) &&
+ isFunction(bCtor) &&
+ a instanceof aCtor &&
+ b instanceof bCtor &&
+ !(aCtor instanceof aCtor && bCtor instanceof bCtor)
+ ) {
+ diffBuilder.recordMismatch(
+ constructorsAreDifferentFormatter.bind(null, this.pp)
+ );
return false;
}
}
// Deep compare objects.
- var aKeys = keys(a, className == '[object Array]'), key;
+ var aKeys = keys(a, className == '[object Array]'),
+ key;
size = aKeys.length;
// Ensure that both objects contain the same number of properties before comparing deep equality.
if (keys(b, className == '[object Array]').length !== size) {
- diffBuilder.recordMismatch(objectKeysAreDifferentFormatter.bind(null, this.pp));
+ diffBuilder.recordMismatch(
+ objectKeysAreDifferentFormatter.bind(null, this.pp)
+ );
return false;
}
@@ -437,13 +551,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
key = aKeys[i];
// Deep compare each member
if (!j$.util.has(b, key)) {
- diffBuilder.recordMismatch(objectKeysAreDifferentFormatter.bind(null, this.pp));
+ diffBuilder.recordMismatch(
+ objectKeysAreDifferentFormatter.bind(null, this.pp)
+ );
result = false;
continue;
}
diffBuilder.withPath(key, function() {
- if(!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)) {
+ if (
+ !self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
+ ) {
result = false;
}
});
@@ -461,23 +579,24 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
};
function keys(obj, isArray) {
- var allKeys = Object.keys ? Object.keys(obj) :
- (function(o) {
+ var allKeys = Object.keys
+ ? Object.keys(obj)
+ : (function(o) {
var keys = [];
for (var key in o) {
- if (j$.util.has(o, key)) {
- keys.push(key);
- }
+ if (j$.util.has(o, key)) {
+ keys.push(key);
+ }
}
return keys;
- })(obj);
+ })(obj);
if (!isArray) {
return allKeys;
}
if (allKeys.length === 0) {
- return allKeys;
+ return allKeys;
}
var extraKeys = [];
@@ -496,21 +615,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
var missingProperties = j$.util.objectDifference(expected, actual),
- extraProperties = j$.util.objectDifference(actual, expected),
- missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
- extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
- messages = [];
+ extraProperties = j$.util.objectDifference(actual, expected),
+ missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
+ extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
+ messages = [];
if (!path.depth()) {
path = 'object';
}
if (missingPropertiesMessage.length) {
- messages.push('Expected ' + path + ' to have properties' + missingPropertiesMessage);
+ messages.push(
+ 'Expected ' + path + ' to have properties' + missingPropertiesMessage
+ );
}
if (extraPropertiesMessage.length) {
- messages.push('Expected ' + path + ' not to have properties' + extraPropertiesMessage);
+ messages.push(
+ 'Expected ' + path + ' not to have properties' + extraPropertiesMessage
+ );
}
return messages.join('\n');
@@ -521,17 +644,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
path = 'object';
}
- return 'Expected ' +
- path + ' to be a kind of ' +
+ return (
+ 'Expected ' +
+ path +
+ ' to be a kind of ' +
j$.fnNameFor(expected.constructor) +
- ', but was ' + pp(actual) + '.';
+ ', but was ' +
+ pp(actual) +
+ '.'
+ );
}
function actualArrayIsLongerFormatter(pp, actual, expected, path) {
- return 'Unexpected ' +
- path + (path.depth() ? ' = ' : '') +
+ return (
+ 'Unexpected ' +
+ path +
+ (path.depth() ? ' = ' : '') +
pp(actual) +
- ' in array.';
+ ' in array.'
+ );
}
function formatKeyValuePairs(pp, obj) {
diff --git a/src/core/matchers/toBe.js b/src/core/matchers/toBe.js
index 8115adc0..81177c28 100644
--- a/src/core/matchers/toBe.js
+++ b/src/core/matchers/toBe.js
@@ -9,7 +9,8 @@ getJasmineRequireObj().toBe = function(j$) {
* expect(thing).toBe(realThing);
*/
function toBe(matchersUtil) {
- var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
+ var tip =
+ ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
return {
compare: function(actual, expected) {
@@ -18,7 +19,13 @@ getJasmineRequireObj().toBe = function(j$) {
};
if (typeof expected === 'object') {
- result.message = matchersUtil.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
+ result.message =
+ matchersUtil.buildFailureMessage(
+ 'toBe',
+ result.pass,
+ actual,
+ expected
+ ) + tip;
}
return result;
diff --git a/src/core/matchers/toBeCloseTo.js b/src/core/matchers/toBeCloseTo.js
index 6cd0a018..b5392144 100644
--- a/src/core/matchers/toBeCloseTo.js
+++ b/src/core/matchers/toBeCloseTo.js
@@ -17,8 +17,13 @@ getJasmineRequireObj().toBeCloseTo = function() {
}
if (expected === null || actual === null) {
- throw new Error('Cannot use toBeCloseTo with null. Arguments evaluated to: ' +
- 'expect(' + actual + ').toBeCloseTo(' + expected + ').'
+ throw new Error(
+ 'Cannot use toBeCloseTo with null. Arguments evaluated to: ' +
+ 'expect(' +
+ actual +
+ ').toBeCloseTo(' +
+ expected +
+ ').'
);
}
diff --git a/src/core/matchers/toBeDefined.js b/src/core/matchers/toBeDefined.js
index ae95091a..0c43f7d2 100644
--- a/src/core/matchers/toBeDefined.js
+++ b/src/core/matchers/toBeDefined.js
@@ -11,7 +11,7 @@ getJasmineRequireObj().toBeDefined = function() {
return {
compare: function(actual) {
return {
- pass: (void 0 !== actual)
+ pass: void 0 !== actual
};
}
};
diff --git a/src/core/matchers/toBeGreaterThan.js b/src/core/matchers/toBeGreaterThan.js
index ffe7ad61..07dad333 100644
--- a/src/core/matchers/toBeGreaterThan.js
+++ b/src/core/matchers/toBeGreaterThan.js
@@ -20,4 +20,3 @@ getJasmineRequireObj().toBeGreaterThan = function() {
return toBeGreaterThan;
};
-
diff --git a/src/core/matchers/toBeInstanceOf.js b/src/core/matchers/toBeInstanceOf.js
index 609b9301..2241402e 100644
--- a/src/core/matchers/toBeInstanceOf.js
+++ b/src/core/matchers/toBeInstanceOf.js
@@ -1,5 +1,8 @@
getJasmineRequireObj().toBeInstanceOf = function(j$) {
- var usageError = j$.formatErrorMsg('', 'expect(value).toBeInstanceOf()');
+ var usageError = j$.formatErrorMsg(
+ '',
+ 'expect(value).toBeInstanceOf()'
+ );
/**
* {@link expect} the actual to be an instance of the expected class
@@ -15,27 +18,42 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) {
function toBeInstanceOf(matchersUtil) {
return {
compare: function(actual, expected) {
- var actualType = actual && actual.constructor ? j$.fnNameFor(actual.constructor) : matchersUtil.pp(actual),
- expectedType = expected ? j$.fnNameFor(expected) : matchersUtil.pp(expected),
- expectedMatcher,
- pass;
+ var actualType =
+ actual && actual.constructor
+ ? j$.fnNameFor(actual.constructor)
+ : matchersUtil.pp(actual),
+ expectedType = expected
+ ? j$.fnNameFor(expected)
+ : matchersUtil.pp(expected),
+ expectedMatcher,
+ pass;
try {
- expectedMatcher = new j$.Any(expected);
- pass = expectedMatcher.asymmetricMatch(actual);
+ expectedMatcher = new j$.Any(expected);
+ pass = expectedMatcher.asymmetricMatch(actual);
} catch (error) {
- throw new Error(usageError('Expected value is not a constructor function'));
+ throw new Error(
+ usageError('Expected value is not a constructor function')
+ );
}
if (pass) {
return {
pass: true,
- message: 'Expected instance of ' + actualType + ' not to be an instance of ' + expectedType
+ message:
+ 'Expected instance of ' +
+ actualType +
+ ' not to be an instance of ' +
+ expectedType
};
} else {
return {
pass: false,
- message: 'Expected instance of ' + actualType + ' to be an instance of ' + expectedType
+ message:
+ 'Expected instance of ' +
+ actualType +
+ ' to be an instance of ' +
+ expectedType
};
}
}
diff --git a/src/core/matchers/toBeLessThan.js b/src/core/matchers/toBeLessThan.js
index 319113a0..162e52f1 100644
--- a/src/core/matchers/toBeLessThan.js
+++ b/src/core/matchers/toBeLessThan.js
@@ -10,7 +10,6 @@ getJasmineRequireObj().toBeLessThan = function() {
*/
function toBeLessThan() {
return {
-
compare: function(actual, expected) {
return {
pass: actual < expected
diff --git a/src/core/matchers/toBeLessThanOrEqual.js b/src/core/matchers/toBeLessThanOrEqual.js
index 4820fc97..f2d47b69 100644
--- a/src/core/matchers/toBeLessThanOrEqual.js
+++ b/src/core/matchers/toBeLessThanOrEqual.js
@@ -10,7 +10,6 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() {
*/
function toBeLessThanOrEqual() {
return {
-
compare: function(actual, expected) {
return {
pass: actual <= expected
diff --git a/src/core/matchers/toBeNaN.js b/src/core/matchers/toBeNaN.js
index 7adf5b34..b26ef5fc 100644
--- a/src/core/matchers/toBeNaN.js
+++ b/src/core/matchers/toBeNaN.js
@@ -11,13 +11,15 @@ getJasmineRequireObj().toBeNaN = function(j$) {
return {
compare: function(actual) {
var result = {
- pass: (actual !== actual)
+ pass: actual !== actual
};
if (result.pass) {
result.message = 'Expected actual not to be NaN.';
} else {
- result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.'; };
+ result.message = function() {
+ return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.';
+ };
}
return result;
diff --git a/src/core/matchers/toBeNegativeInfinity.js b/src/core/matchers/toBeNegativeInfinity.js
index fe2de803..2518a9c8 100644
--- a/src/core/matchers/toBeNegativeInfinity.js
+++ b/src/core/matchers/toBeNegativeInfinity.js
@@ -11,13 +11,15 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) {
return {
compare: function(actual) {
var result = {
- pass: (actual === Number.NEGATIVE_INFINITY)
+ pass: actual === Number.NEGATIVE_INFINITY
};
if (result.pass) {
result.message = 'Expected actual not to be -Infinity.';
} else {
- result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.'; };
+ result.message = function() {
+ return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.';
+ };
}
return result;
diff --git a/src/core/matchers/toBePositiveInfinity.js b/src/core/matchers/toBePositiveInfinity.js
index 39cb5e34..17523c97 100644
--- a/src/core/matchers/toBePositiveInfinity.js
+++ b/src/core/matchers/toBePositiveInfinity.js
@@ -11,13 +11,15 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
return {
compare: function(actual) {
var result = {
- pass: (actual === Number.POSITIVE_INFINITY)
+ pass: actual === Number.POSITIVE_INFINITY
};
if (result.pass) {
result.message = 'Expected actual not to be Infinity.';
} else {
- result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.'; };
+ result.message = function() {
+ return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.';
+ };
}
return result;
diff --git a/src/core/matchers/toContain.js b/src/core/matchers/toContain.js
index 5732447e..9ab30154 100644
--- a/src/core/matchers/toContain.js
+++ b/src/core/matchers/toContain.js
@@ -12,7 +12,6 @@ getJasmineRequireObj().toContain = function() {
function toContain(matchersUtil) {
return {
compare: function(actual, expected) {
-
return {
pass: matchersUtil.contains(actual, expected)
};
diff --git a/src/core/matchers/toEqual.js b/src/core/matchers/toEqual.js
index 3a7add38..d2db1bd8 100644
--- a/src/core/matchers/toEqual.js
+++ b/src/core/matchers/toEqual.js
@@ -14,7 +14,7 @@ getJasmineRequireObj().toEqual = function(j$) {
var result = {
pass: false
},
- diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp});
+ diffBuilder = j$.DiffBuilder({ prettyPrinter: matchersUtil.pp });
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
diff --git a/src/core/matchers/toHaveBeenCalled.js b/src/core/matchers/toHaveBeenCalled.js
index 3e6d2601..ef1ea60c 100644
--- a/src/core/matchers/toHaveBeenCalled.js
+++ b/src/core/matchers/toHaveBeenCalled.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalled()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect().toHaveBeenCalled()'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called.
@@ -17,18 +19,24 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
var result = {};
if (!j$.isSpy(actual)) {
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.'));
+ throw new Error(
+ getErrorMsg(
+ 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
+ )
+ );
}
if (arguments.length > 1) {
- throw new Error(getErrorMsg('Does not take arguments, use toHaveBeenCalledWith'));
+ throw new Error(
+ getErrorMsg('Does not take arguments, use toHaveBeenCalledWith')
+ );
}
result.pass = actual.calls.any();
- result.message = result.pass ?
- 'Expected spy ' + actual.and.identity + ' not to have been called.' :
- 'Expected spy ' + actual.and.identity + ' to have been called.';
+ result.message = result.pass
+ ? 'Expected spy ' + actual.and.identity + ' not to have been called.'
+ : 'Expected spy ' + actual.and.identity + ' to have been called.';
return result;
}
diff --git a/src/core/matchers/toHaveBeenCalledBefore.js b/src/core/matchers/toHaveBeenCalledBefore.js
index 293e73ff..ad1de7c0 100644
--- a/src/core/matchers/toHaveBeenCalledBefore.js
+++ b/src/core/matchers/toHaveBeenCalledBefore.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledBefore()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect().toHaveBeenCalledBefore()'
+ );
/**
* {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}.
@@ -15,20 +17,30 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
return {
compare: function(firstSpy, latterSpy) {
if (!j$.isSpy(firstSpy)) {
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.'));
+ throw new Error(
+ getErrorMsg(
+ 'Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.'
+ )
+ );
}
if (!j$.isSpy(latterSpy)) {
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.'));
+ throw new Error(
+ getErrorMsg(
+ 'Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.'
+ )
+ );
}
var result = { pass: false };
if (!firstSpy.calls.count()) {
- result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called.';
+ result.message =
+ 'Expected spy ' + firstSpy.and.identity + ' to have been called.';
return result;
}
if (!latterSpy.calls.count()) {
- result.message = 'Expected spy ' + latterSpy.and.identity + ' to have been called.';
+ result.message =
+ 'Expected spy ' + latterSpy.and.identity + ' to have been called.';
return result;
}
@@ -38,17 +50,36 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
result.pass = latest1stSpyCall < first2ndSpyCall;
if (result.pass) {
- result.message = 'Expected spy ' + firstSpy.and.identity + ' to not have been called before spy ' + latterSpy.and.identity + ', but it was';
+ result.message =
+ 'Expected spy ' +
+ firstSpy.and.identity +
+ ' to not have been called before spy ' +
+ latterSpy.and.identity +
+ ', but it was';
} else {
var first1stSpyCall = firstSpy.calls.first().invocationOrder;
var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
- if(first1stSpyCall < first2ndSpyCall) {
- result.message = 'Expected latest call to spy ' + firstSpy.and.identity + ' to have been called before first call to spy ' + latterSpy.and.identity + ' (no interleaved calls)';
+ if (first1stSpyCall < first2ndSpyCall) {
+ result.message =
+ 'Expected latest call to spy ' +
+ firstSpy.and.identity +
+ ' to have been called before first call to spy ' +
+ latterSpy.and.identity +
+ ' (no interleaved calls)';
} else if (latest2ndSpyCall > latest1stSpyCall) {
- result.message = 'Expected first call to spy ' + latterSpy.and.identity + ' to have been called after latest call to spy ' + firstSpy.and.identity + ' (no interleaved calls)';
+ result.message =
+ 'Expected first call to spy ' +
+ latterSpy.and.identity +
+ ' to have been called after latest call to spy ' +
+ firstSpy.and.identity +
+ ' (no interleaved calls)';
} else {
- result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called before spy ' + latterSpy.and.identity;
+ result.message =
+ 'Expected spy ' +
+ firstSpy.and.identity +
+ ' to have been called before spy ' +
+ latterSpy.and.identity;
}
}
diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js
index 2cd607f8..d3d6b4ef 100644
--- a/src/core/matchers/toHaveBeenCalledOnceWith.js
+++ b/src/core/matchers/toHaveBeenCalledOnceWith.js
@@ -1,6 +1,8 @@
-getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledOnceWith(...arguments)');
+getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect().toHaveBeenCalledOnceWith(...arguments)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments.
@@ -13,31 +15,44 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
*/
function toHaveBeenCalledOnceWith(util) {
return {
- compare: function () {
+ compare: function() {
var args = Array.prototype.slice.call(arguments, 0),
actual = args[0],
expectedArgs = args.slice(1);
if (!j$.isSpy(actual)) {
- throw new Error(getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.'));
+ throw new Error(
+ getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.')
+ );
}
- var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) {
- return ' ' + util.pp(argsForCall);
- });
+ var prettyPrintedCalls = actual.calls
+ .allArgs()
+ .map(function(argsForCall) {
+ return ' ' + util.pp(argsForCall);
+ });
- if (actual.calls.count() === 1 && util.contains(actual.calls.allArgs(), expectedArgs)) {
+ if (
+ actual.calls.count() === 1 &&
+ util.contains(actual.calls.allArgs(), expectedArgs)
+ ) {
return {
pass: true,
- message: 'Expected spy ' + actual.and.identity + ' to have been called 0 times, multiple times, or once, but with arguments different from:\n'
- + ' ' + util.pp(expectedArgs) + '\n'
- + 'But the actual call was:\n'
- + prettyPrintedCalls.join(',\n') + '.\n\n'
+ message:
+ 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called 0 times, multiple times, or once, but with arguments different from:\n' +
+ ' ' +
+ util.pp(expectedArgs) +
+ '\n' +
+ 'But the actual call was:\n' +
+ prettyPrintedCalls.join(',\n') +
+ '.\n\n'
};
}
function getDiffs() {
- return actual.calls.allArgs().map(function (argsForCall, callIx) {
+ return actual.calls.allArgs().map(function(argsForCall, callIx) {
var diffBuilder = new j$.DiffBuilder();
util.equals(argsForCall, expectedArgs, diffBuilder);
return diffBuilder.getMessage();
@@ -49,17 +64,32 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
case 0:
return 'But it was never called.\n\n';
case 1:
- return 'But the actual call was:\n' + prettyPrintedCalls.join(',\n') + '.\n' + getDiffs().join('\n') + '\n\n';
+ return (
+ 'But the actual call was:\n' +
+ prettyPrintedCalls.join(',\n') +
+ '.\n' +
+ getDiffs().join('\n') +
+ '\n\n'
+ );
default:
- return 'But the actual calls were:\n' + prettyPrintedCalls.join(',\n') + '.\n\n';
+ return (
+ 'But the actual calls were:\n' +
+ prettyPrintedCalls.join(',\n') +
+ '.\n\n'
+ );
}
}
return {
pass: false,
- message: 'Expected spy ' + actual.and.identity + ' to have been called only once, and with given args:\n'
- + ' ' + util.pp(expectedArgs) + '\n'
- + butString()
+ message:
+ 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called only once, and with given args:\n' +
+ ' ' +
+ util.pp(expectedArgs) +
+ '\n' +
+ butString()
};
}
};
diff --git a/src/core/matchers/toHaveBeenCalledTimes.js b/src/core/matchers/toHaveBeenCalledTimes.js
index fa3eef3d..f3bcac3f 100644
--- a/src/core/matchers/toHaveBeenCalledTimes.js
+++ b/src/core/matchers/toHaveBeenCalledTimes.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledTimes()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect().toHaveBeenCalledTimes()'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called the specified number of times.
@@ -15,23 +17,43 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
return {
compare: function(actual, expected) {
if (!j$.isSpy(actual)) {
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.'));
+ throw new Error(
+ getErrorMsg(
+ 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
+ )
+ );
}
var args = Array.prototype.slice.call(arguments, 0),
result = { pass: false };
if (!j$.isNumber_(expected)) {
- throw new Error(getErrorMsg('The expected times failed is a required argument and must be a number.'));
+ throw new Error(
+ getErrorMsg(
+ 'The expected times failed is a required argument and must be a number.'
+ )
+ );
}
actual = args[0];
var calls = actual.calls.count();
var timesMessage = expected === 1 ? 'once' : expected + ' times';
result.pass = calls === expected;
- result.message = result.pass ?
- 'Expected spy ' + actual.and.identity + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
- 'Expected spy ' + actual.and.identity + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
+ result.message = result.pass
+ ? 'Expected spy ' +
+ actual.and.identity +
+ ' not to have been called ' +
+ timesMessage +
+ '. It was called ' +
+ calls +
+ ' times.'
+ : 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called ' +
+ timesMessage +
+ '. It was called ' +
+ calls +
+ ' times.';
return result;
}
};
diff --git a/src/core/matchers/toHaveBeenCalledWith.js b/src/core/matchers/toHaveBeenCalledWith.js
index 76628b55..0a646b89 100644
--- a/src/core/matchers/toHaveBeenCalledWith.js
+++ b/src/core/matchers/toHaveBeenCalledWith.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledWith(...arguments)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect().toHaveBeenCalledWith(...arguments)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once.
@@ -20,14 +22,23 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
result = { pass: false };
if (!j$.isSpy(actual)) {
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.'));
+ throw new Error(
+ getErrorMsg(
+ 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
+ )
+ );
}
if (!actual.calls.any()) {
result.message = function() {
- return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
- ' ' + matchersUtil.pp(expectedArgs) +
- '\nbut it was never called.';
+ return (
+ 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called with:\n' +
+ ' ' +
+ matchersUtil.pp(expectedArgs) +
+ '\nbut it was never called.'
+ );
};
return result;
}
@@ -35,28 +46,49 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
if (matchersUtil.contains(actual.calls.allArgs(), expectedArgs)) {
result.pass = true;
result.message = function() {
- return 'Expected spy ' + actual.and.identity + ' not to have been called with:\n' +
- ' ' + matchersUtil.pp(expectedArgs) +
- '\nbut it was.';
+ return (
+ 'Expected spy ' +
+ actual.and.identity +
+ ' not to have been called with:\n' +
+ ' ' +
+ matchersUtil.pp(expectedArgs) +
+ '\nbut it was.'
+ );
};
} else {
result.message = function() {
- var prettyPrintedCalls = actual.calls.allArgs().map(function(argsForCall) {
- return ' ' + matchersUtil.pp(argsForCall);
- });
+ var prettyPrintedCalls = actual.calls
+ .allArgs()
+ .map(function(argsForCall) {
+ return ' ' + matchersUtil.pp(argsForCall);
+ });
- var diffs = actual.calls.allArgs().map(function(argsForCall, callIx) {
- var diffBuilder = new j$.DiffBuilder();
- matchersUtil.equals(argsForCall, expectedArgs, diffBuilder);
- return 'Call ' + callIx + ':\n' +
- diffBuilder.getMessage().replace(/^/mg, ' ');
- });
+ var diffs = actual.calls
+ .allArgs()
+ .map(function(argsForCall, callIx) {
+ var diffBuilder = new j$.DiffBuilder();
+ matchersUtil.equals(argsForCall, expectedArgs, diffBuilder);
+ return (
+ 'Call ' +
+ callIx +
+ ':\n' +
+ diffBuilder.getMessage().replace(/^/gm, ' ')
+ );
+ });
- return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
- ' ' + matchersUtil.pp(expectedArgs) + '\n' + '' +
+ return (
+ 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called with:\n' +
+ ' ' +
+ matchersUtil.pp(expectedArgs) +
+ '\n' +
+ '' +
'but actual calls were:\n' +
- prettyPrintedCalls.join(',\n') + '.\n\n' +
- diffs.join('\n');
+ prettyPrintedCalls.join(',\n') +
+ '.\n\n' +
+ diffs.join('\n')
+ );
};
}
diff --git a/src/core/matchers/toHaveClass.js b/src/core/matchers/toHaveClass.js
index efe17f10..218e729c 100644
--- a/src/core/matchers/toHaveClass.js
+++ b/src/core/matchers/toHaveClass.js
@@ -25,9 +25,9 @@ getJasmineRequireObj().toHaveClass = function(j$) {
}
function isElement(maybeEl) {
- return maybeEl &&
- maybeEl.classList &&
- j$.isFunction_(maybeEl.classList.contains);
+ return (
+ maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains)
+ );
}
return toHaveClass;
diff --git a/src/core/matchers/toHaveSize.js b/src/core/matchers/toHaveSize.js
index 03c8d431..403080a8 100644
--- a/src/core/matchers/toHaveSize.js
+++ b/src/core/matchers/toHaveSize.js
@@ -13,10 +13,14 @@ getJasmineRequireObj().toHaveSize = function(j$) {
return {
compare: function(actual, expected) {
var result = {
- pass: false
- };
+ pass: false
+ };
- if (j$.isA_('WeakSet', actual) || j$.isWeakMap(actual) || j$.isDataView(actual)) {
+ if (
+ j$.isA_('WeakSet', actual) ||
+ j$.isWeakMap(actual) ||
+ j$.isDataView(actual)
+ ) {
throw new Error('Cannot get size of ' + actual + '.');
}
@@ -33,9 +37,14 @@ getJasmineRequireObj().toHaveSize = function(j$) {
};
}
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat
function isLength(value) {
- return (typeof value == 'number') && value > -1 && value % 1 === 0 && value <= MAX_SAFE_INTEGER;
+ return (
+ typeof value == 'number' &&
+ value > -1 &&
+ value % 1 === 0 &&
+ value <= MAX_SAFE_INTEGER
+ );
}
return toHaveSize;
diff --git a/src/core/matchers/toMatch.js b/src/core/matchers/toMatch.js
index 7d8f658c..bb3ca3a9 100644
--- a/src/core/matchers/toMatch.js
+++ b/src/core/matchers/toMatch.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toMatch = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect().toMatch( || )');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect().toMatch( || )'
+ );
/**
* {@link expect} the actual value to match a regular expression
diff --git a/src/core/matchers/toThrow.js b/src/core/matchers/toThrow.js
index a471a5d9..b1db2b4c 100644
--- a/src/core/matchers/toThrow.js
+++ b/src/core/matchers/toThrow.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toThrow = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect(function() {}).toThrow()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect(function() {}).toThrow()'
+ );
/**
* {@link expect} a function to `throw` something.
@@ -37,16 +39,36 @@ getJasmineRequireObj().toThrow = function(j$) {
if (arguments.length == 1) {
result.pass = true;
- result.message = function() { return 'Expected function not to throw, but it threw ' + matchersUtil.pp(thrown) + '.'; };
+ result.message = function() {
+ return (
+ 'Expected function not to throw, but it threw ' +
+ matchersUtil.pp(thrown) +
+ '.'
+ );
+ };
return result;
}
if (matchersUtil.equals(thrown, expected)) {
result.pass = true;
- result.message = function() { return 'Expected function not to throw ' + matchersUtil.pp(expected) + '.'; };
+ result.message = function() {
+ return (
+ 'Expected function not to throw ' +
+ matchersUtil.pp(expected) +
+ '.'
+ );
+ };
} else {
- result.message = function() { return 'Expected function to throw ' + matchersUtil.pp(expected) + ', but it threw ' + matchersUtil.pp(thrown) + '.'; };
+ result.message = function() {
+ return (
+ 'Expected function to throw ' +
+ matchersUtil.pp(expected) +
+ ', but it threw ' +
+ matchersUtil.pp(thrown) +
+ '.'
+ );
+ };
}
return result;
diff --git a/src/core/matchers/toThrowError.js b/src/core/matchers/toThrowError.js
index 00f3e69a..38513603 100644
--- a/src/core/matchers/toThrowError.js
+++ b/src/core/matchers/toThrowError.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toThrowError = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('', 'expect(function() {}).toThrowError(, )');
+ var getErrorMsg = j$.formatErrorMsg(
+ '',
+ 'expect(function() {}).toThrowError(, )'
+ );
/**
* {@link expect} a function to `throw` an `Error`.
@@ -34,7 +36,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
if (!j$.isError_(thrown)) {
- return fail(function() { return 'Expected function to throw an Error, but it threw ' + matchersUtil.pp(thrown) + '.'; });
+ return fail(function() {
+ return (
+ 'Expected function to throw an Error, but it threw ' +
+ matchersUtil.pp(thrown) +
+ '.'
+ );
+ });
}
return errorMatcher.match(thrown);
@@ -68,7 +76,11 @@ getJasmineRequireObj().toThrowError = function(j$) {
function anyMatcher() {
return {
match: function(error) {
- return pass('Expected function not to throw an Error, but it threw ' + j$.fnNameFor(error) + '.');
+ return pass(
+ 'Expected function not to throw an Error, but it threw ' +
+ j$.fnNameFor(error) +
+ '.'
+ );
}
};
}
@@ -76,9 +88,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
function exactMatcher(expected, errorType) {
if (expected && !isStringOrRegExp(expected)) {
if (errorType) {
- throw new Error(getErrorMsg('Expected error message is not a string or RegExp.'));
+ throw new Error(
+ getErrorMsg('Expected error message is not a string or RegExp.')
+ );
} else {
- throw new Error(getErrorMsg('Expected is not an Error, string, or RegExp.'));
+ throw new Error(
+ getErrorMsg('Expected is not an Error, string, or RegExp.')
+ );
}
}
@@ -90,11 +106,15 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
}
- var errorTypeDescription = errorType ? j$.fnNameFor(errorType) : 'an exception';
+ var errorTypeDescription = errorType
+ ? j$.fnNameFor(errorType)
+ : 'an exception';
function thrownDescription(thrown) {
- var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception',
- thrownMessage = '';
+ var thrownName = errorType
+ ? j$.fnNameFor(thrown.constructor)
+ : 'an exception',
+ thrownMessage = '';
if (expected) {
thrownMessage = ' with message ' + matchersUtil.pp(thrown.message);
@@ -114,20 +134,33 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
function matches(error) {
- return (errorType === null || error instanceof errorType) &&
- (expected === null || messageMatch(error.message));
+ return (
+ (errorType === null || error instanceof errorType) &&
+ (expected === null || messageMatch(error.message))
+ );
}
return {
match: function(thrown) {
if (matches(thrown)) {
return pass(function() {
- return 'Expected function not to throw ' + errorTypeDescription + messageDescription() + '.';
+ return (
+ 'Expected function not to throw ' +
+ errorTypeDescription +
+ messageDescription() +
+ '.'
+ );
});
} else {
return fail(function() {
- return 'Expected function to throw ' + errorTypeDescription + messageDescription() +
- ', but it threw ' + thrownDescription(thrown) + '.';
+ return (
+ 'Expected function to throw ' +
+ errorTypeDescription +
+ messageDescription() +
+ ', but it threw ' +
+ thrownDescription(thrown) +
+ '.'
+ );
});
}
}
@@ -135,7 +168,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
}
function isStringOrRegExp(potential) {
- return potential instanceof RegExp || (typeof potential == 'string');
+ return potential instanceof RegExp || typeof potential == 'string';
}
function isAnErrorType(type) {
diff --git a/src/core/matchers/toThrowMatching.js b/src/core/matchers/toThrowMatching.js
index 45e3fc85..e594b1f5 100644
--- a/src/core/matchers/toThrowMatching.js
+++ b/src/core/matchers/toThrowMatching.js
@@ -1,5 +1,8 @@
getJasmineRequireObj().toThrowMatching = function(j$) {
- var usageError = j$.formatErrorMsg('', 'expect(function() {}).toThrowMatching()');
+ var usageError = j$.formatErrorMsg(
+ '',
+ 'expect(function() {}).toThrowMatching()'
+ );
/**
* {@link expect} a function to `throw` something matching a predicate.
@@ -31,20 +34,29 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
}
if (predicate(thrown)) {
- return pass('Expected function not to throw an exception matching a predicate.');
+ return pass(
+ 'Expected function not to throw an exception matching a predicate.'
+ );
} else {
- return fail(function() {
- return 'Expected function to throw an exception matching a predicate, ' +
- 'but it threw ' + thrownDescription(thrown) + '.';
- });
+ return fail(function() {
+ return (
+ 'Expected function to throw an exception matching a predicate, ' +
+ 'but it threw ' +
+ thrownDescription(thrown) +
+ '.'
+ );
+ });
}
}
};
function thrownDescription(thrown) {
if (thrown && thrown.constructor) {
- return j$.fnNameFor(thrown.constructor) + ' with message ' +
- matchersUtil.pp(thrown.message);
+ return (
+ j$.fnNameFor(thrown.constructor) +
+ ' with message ' +
+ matchersUtil.pp(thrown.message)
+ );
} else {
return matchersUtil.pp(thrown);
}
diff --git a/src/core/util.js b/src/core/util.js
index 4118deec..64aedef1 100644
--- a/src/core/util.js
+++ b/src/core/util.js
@@ -7,16 +7,6 @@ getJasmineRequireObj().util = function(j$) {
childClass.prototype = new Subclass();
};
- util.htmlEscape = function(str) {
- if (!str) {
- return str;
- }
- return str
- .replace(/&/g, '&')
- .replace(//g, '>');
- };
-
util.argsToArray = function(args) {
var arrayOfArgs = [];
for (var i = 0; i < args.length; i++) {