diff --git a/spec/core/AsyncExpectationSpec.js b/spec/core/AsyncExpectationSpec.js index e7653b4e..511b8125 100644 --- a/spec/core/AsyncExpectationSpec.js +++ b/spec/core/AsyncExpectationSpec.js @@ -7,14 +7,14 @@ describe('AsyncExpectation', function() { describe('#not', function() { it('converts a pass to a fail', function() { - const addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = Promise.resolve(), - pp = privateUnderTest.makePrettyPrinter(), - expectation = privateUnderTest.Expectation.asyncFactory({ - matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }), - actual: actual, - addExpectationResult: addExpectationResult - }); + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const actual = Promise.resolve(); + const pp = privateUnderTest.makePrettyPrinter(); + const expectation = privateUnderTest.Expectation.asyncFactory({ + matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }), + actual: actual, + addExpectationResult: addExpectationResult + }); return expectation.not.toBeResolved().then(function() { expect(addExpectationResult).toHaveBeenCalledWith( @@ -28,15 +28,15 @@ describe('AsyncExpectation', function() { }); it('converts a fail to a pass', function() { - const addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = Promise.reject(new Error('nope')), - expectation = privateUnderTest.Expectation.asyncFactory({ - matchersUtil: new privateUnderTest.MatchersUtil({ - pp: function() {} - }), - actual: actual, - addExpectationResult: addExpectationResult - }); + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const actual = Promise.reject(new Error('nope')); + const expectation = privateUnderTest.Expectation.asyncFactory({ + matchersUtil: new privateUnderTest.MatchersUtil({ + pp: function() {} + }), + actual: actual, + addExpectationResult: addExpectationResult + }); return expectation.not.toBeResolved().then(function() { expect(addExpectationResult).toHaveBeenCalledWith( @@ -53,12 +53,12 @@ describe('AsyncExpectation', function() { it('propagates rejections from the comparison function', function() { const error = new Error('ExpectationSpec failure'); - const addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = dummyPromise(), - expectation = privateUnderTest.Expectation.asyncFactory({ - actual: actual, - addExpectationResult: addExpectationResult - }); + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const actual = dummyPromise(); + const expectation = privateUnderTest.Expectation.asyncFactory({ + actual: actual, + addExpectationResult: addExpectationResult + }); spyOn(expectation, 'toBeResolved').and.returnValue(Promise.reject(error)); @@ -75,16 +75,16 @@ describe('AsyncExpectation', function() { describe('#withContext', function() { it('prepends the context to the generated failure message', function() { const matchersUtil = { - pp: function(val) { - return val.toString(); - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.asyncFactory({ - actual: Promise.reject('rejected'), - addExpectationResult: addExpectationResult, - matchersUtil: matchersUtil - }); + pp: function(val) { + return val.toString(); + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.asyncFactory({ + actual: Promise.reject('rejected'), + addExpectationResult: addExpectationResult, + matchersUtil: matchersUtil + }); return expectation .withContext('Some context') @@ -102,17 +102,17 @@ describe('AsyncExpectation', function() { it('prepends the context to a custom failure message', function() { const matchersUtil = { - buildFailureMessage: function() { - return 'failure message'; - }, - pp: privateUnderTest.makePrettyPrinter() + buildFailureMessage: function() { + return 'failure message'; }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.asyncFactory({ - actual: Promise.reject('b'), - addExpectationResult: addExpectationResult, - matchersUtil: matchersUtil - }); + pp: privateUnderTest.makePrettyPrinter() + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.asyncFactory({ + actual: Promise.reject('b'), + addExpectationResult: addExpectationResult, + matchersUtil: matchersUtil + }); return expectation .withContext('Some context') @@ -159,14 +159,14 @@ describe('AsyncExpectation', function() { }); it('works with #not', function() { - const addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = Promise.resolve(), - pp = privateUnderTest.makePrettyPrinter(), - expectation = privateUnderTest.Expectation.asyncFactory({ - actual: actual, - addExpectationResult: addExpectationResult, - matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }) - }); + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const actual = Promise.resolve(); + const pp = privateUnderTest.makePrettyPrinter(); + const expectation = privateUnderTest.Expectation.asyncFactory({ + actual: actual, + addExpectationResult: addExpectationResult, + matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }) + }); return expectation .withContext('Some context') @@ -183,15 +183,15 @@ describe('AsyncExpectation', function() { }); it('works with #not and a custom message', function() { - const addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = Promise.resolve('a'), - expectation = privateUnderTest.Expectation.asyncFactory({ - actual: actual, - addExpectationResult: addExpectationResult, - matchersUtil: new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }) - }); + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const actual = Promise.resolve('a'); + const expectation = privateUnderTest.Expectation.asyncFactory({ + actual: actual, + addExpectationResult: addExpectationResult, + matchersUtil: new privateUnderTest.MatchersUtil({ + pp: privateUnderTest.makePrettyPrinter() + }) + }); return expectation .withContext('Some context') @@ -211,12 +211,12 @@ describe('AsyncExpectation', function() { describe('async matchers', function() { it('makes custom matchers available to this expectation', function() { const asyncMatchers = { - toFoo: function() {}, - toBar: function() {} - }, - expectation = privateUnderTest.Expectation.asyncFactory({ - customAsyncMatchers: asyncMatchers - }); + toFoo: function() {}, + toBar: function() {} + }; + const expectation = privateUnderTest.Expectation.asyncFactory({ + customAsyncMatchers: asyncMatchers + }); expect(expectation.toFoo).toBeDefined(); expect(expectation.toBar).toBeDefined(); @@ -224,24 +224,24 @@ describe('AsyncExpectation', function() { it("wraps matchers's compare functions, passing in matcher dependencies", function() { const fakeCompare = function() { - return Promise.resolve({ pass: true }); - }, - matcherFactory = jasmine - .createSpy('matcher') - .and.returnValue({ compare: fakeCompare }), - matchers = { - toFoo: matcherFactory - }, - matchersUtil = { - buildFailureMessage: jasmine.createSpy('buildFailureMessage') - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.asyncFactory({ - matchersUtil: matchersUtil, - customAsyncMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + return Promise.resolve({ pass: true }); + }; + const matcherFactory = jasmine + .createSpy('matcher') + .and.returnValue({ compare: fakeCompare }); + const matchers = { + toFoo: matcherFactory + }; + const matchersUtil = { + buildFailureMessage: jasmine.createSpy('buildFailureMessage') + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.asyncFactory({ + matchersUtil: matchersUtil, + customAsyncMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); return expectation.toFoo('hello').then(function() { expect(matcherFactory).toHaveBeenCalledWith(matchersUtil); @@ -250,25 +250,25 @@ describe('AsyncExpectation', function() { it("wraps matchers's compare functions, passing the actual and expected", function() { const fakeCompare = jasmine - .createSpy('fake-compare') - .and.returnValue(Promise.resolve({ pass: true })), - matchers = { - toFoo: function() { - return { - compare: fakeCompare - }; - } - }, - matchersUtil = { - buildFailureMessage: jasmine.createSpy('buildFailureMessage') - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.asyncFactory({ - matchersUtil: matchersUtil, - customAsyncMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + .createSpy('fake-compare') + .and.returnValue(Promise.resolve({ pass: true })); + const matchers = { + toFoo: function() { + return { + compare: fakeCompare + }; + } + }; + const matchersUtil = { + buildFailureMessage: jasmine.createSpy('buildFailureMessage') + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.asyncFactory({ + matchersUtil: matchersUtil, + customAsyncMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); return expectation.toFoo('hello').then(function() { expect(fakeCompare).toHaveBeenCalledWith('an actual', 'hello'); @@ -310,19 +310,19 @@ describe('AsyncExpectation', function() { it('reports a failing result to the spec when the comparison fails', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return Promise.resolve({ pass: false }); - } - }; - } - }, - matchersUtil = { - buildFailureMessage: function() { - return ''; - } - }; + toFoo: function() { + return { + compare: function() { + return Promise.resolve({ pass: false }); + } + }; + } + }; + const matchersUtil = { + buildFailureMessage: function() { + return ''; + } + }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.asyncFactory({ @@ -440,19 +440,19 @@ describe('AsyncExpectation', function() { it('reports a failing result to the spec when the comparison passes for a negative expectation', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return Promise.resolve({ pass: true }); - } - }; - } - }, - matchersUtil = { - buildFailureMessage: function() { - return 'default message'; - } - }; + toFoo: function() { + return { + compare: function() { + return Promise.resolve({ pass: true }); + } + }; + } + }; + const matchersUtil = { + buildFailureMessage: function() { + return 'default message'; + } + }; const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.asyncFactory({ diff --git a/spec/core/CallTrackerSpec.js b/spec/core/CallTrackerSpec.js index 07d6d83d..2ae896dc 100644 --- a/spec/core/CallTrackerSpec.js +++ b/spec/core/CallTrackerSpec.js @@ -33,8 +33,8 @@ describe('CallTracker', function() { it("tracks the 'this' object from each execution", function() { const callTracker = new privateUnderTest.CallTracker(); - const this0 = {}, - this1 = {}; + const this0 = {}; + const this1 = {}; callTracker.track({ object: this0, args: [] }); callTracker.track({ object: this1, args: [] }); callTracker.track({ args: [] }); @@ -120,8 +120,8 @@ describe('CallTracker', function() { const callTracker = new privateUnderTest.CallTracker(); callTracker.saveArgumentsByValue(); - const objectArg = { foo: 'bar' }, - arrayArg = ['foo', 'bar']; + const objectArg = { foo: 'bar' }; + const arrayArg = ['foo', 'bar']; callTracker.track({ object: {}, @@ -138,8 +138,8 @@ describe('CallTracker', function() { const callTracker = new privateUnderTest.CallTracker(); callTracker.saveArgumentsByValue(args => JSON.parse(JSON.stringify(args))); - const objectArg = { foo: { bar: { baz: ['qux'] } } }, - arrayArg = ['foo', 'bar']; + const objectArg = { foo: { bar: { baz: ['qux'] } } }; + const arrayArg = ['foo', 'bar']; callTracker.track({ object: {}, @@ -161,9 +161,9 @@ describe('CallTracker', function() { const callTracker = new privateUnderTest.CallTracker(); callTracker.saveArgumentsByValue(JSON.stringify); - const objectArg = { foo: { bar: { baz: ['qux'] } } }, - arrayArg = ['foo', 'bar'], - args = [objectArg, arrayArg, false, undefined, null, NaN, '', 0, 1.0]; + const objectArg = { foo: { bar: { baz: ['qux'] } } }; + const arrayArg = ['foo', 'bar']; + const args = [objectArg, arrayArg, false, undefined, null, NaN, '', 0, 1.0]; callTracker.track({ object: {}, args }); @@ -171,8 +171,8 @@ describe('CallTracker', function() { }); it('saves primitive arguments by value', function() { - const callTracker = new privateUnderTest.CallTracker(), - args = [undefined, null, false, '', /\s/, 0, 1.2, NaN]; + const callTracker = new privateUnderTest.CallTracker(); + const args = [undefined, null, false, '', /\s/, 0, 1.2, NaN]; callTracker.saveArgumentsByValue(); callTracker.track({ object: {}, args: args }); diff --git a/spec/core/ClockSpec.js b/spec/core/ClockSpec.js index 719fbca1..01fad850 100644 --- a/spec/core/ClockSpec.js +++ b/spec/core/ClockSpec.js @@ -5,25 +5,25 @@ describe('Clock', function() { typeof process.versions.node === 'string'; it('does not replace setTimeout until it is installed', function() { - const fakeSetTimeout = jasmine.createSpy('global setTimeout'), - fakeGlobal = { setTimeout: fakeSetTimeout }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['scheduleFunction'] - ), - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeSetTimeout = jasmine.createSpy('global setTimeout'); + const fakeGlobal = { setTimeout: fakeSetTimeout }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['scheduleFunction'] + ); + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); fakeGlobal.setTimeout(delayedFn, 0); @@ -40,24 +40,24 @@ describe('Clock', function() { }); it('does not replace clearTimeout until it is installed', function() { - const fakeClearTimeout = jasmine.createSpy('global cleartimeout'), - fakeGlobal = { clearTimeout: fakeClearTimeout }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['removeFunctionWithId'] - ), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeClearTimeout = jasmine.createSpy('global cleartimeout'); + const fakeGlobal = { clearTimeout: fakeClearTimeout }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['removeFunctionWithId'] + ); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); fakeGlobal.clearTimeout('foo'); @@ -76,25 +76,25 @@ describe('Clock', function() { }); it('does not replace setInterval until it is installed', function() { - const fakeSetInterval = jasmine.createSpy('global setInterval'), - fakeGlobal = { setInterval: fakeSetInterval }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['scheduleFunction'] - ), - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeSetInterval = jasmine.createSpy('global setInterval'); + const fakeGlobal = { setInterval: fakeSetInterval }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['scheduleFunction'] + ); + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); fakeGlobal.setInterval(delayedFn, 0); @@ -111,24 +111,24 @@ describe('Clock', function() { }); it('does not replace clearInterval until it is installed', function() { - const fakeClearInterval = jasmine.createSpy('global clearinterval'), - fakeGlobal = { clearInterval: fakeClearInterval }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['removeFunctionWithId'] - ), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeClearInterval = jasmine.createSpy('global clearinterval'); + const fakeGlobal = { clearInterval: fakeClearInterval }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['removeFunctionWithId'] + ); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); fakeGlobal.clearInterval('foo'); @@ -147,18 +147,18 @@ describe('Clock', function() { }); it('does not install if the current setTimeout is not the original function on the global', function() { - const originalFakeSetTimeout = function() {}, - replacedSetTimeout = function() {}, - fakeGlobal = { setTimeout: originalFakeSetTimeout }, - delayedFunctionSchedulerFactory = jasmine.createSpy( - 'delayedFunctionSchedulerFactory' - ), - mockDate = {}, - clock = new privateUnderTest.Clock( - fakeGlobal, - delayedFunctionSchedulerFactory, - mockDate - ); + const originalFakeSetTimeout = function() {}; + const replacedSetTimeout = function() {}; + const fakeGlobal = { setTimeout: originalFakeSetTimeout }; + const delayedFunctionSchedulerFactory = jasmine.createSpy( + 'delayedFunctionSchedulerFactory' + ); + const mockDate = {}; + const clock = new privateUnderTest.Clock( + fakeGlobal, + delayedFunctionSchedulerFactory, + mockDate + ); fakeGlobal.setTimeout = replacedSetTimeout; @@ -171,18 +171,18 @@ describe('Clock', function() { }); it('does not install if the current clearTimeout is not the original function on the global', function() { - const originalFakeClearTimeout = function() {}, - replacedClearTimeout = function() {}, - fakeGlobal = { clearTimeout: originalFakeClearTimeout }, - delayedFunctionSchedulerFactory = jasmine.createSpy( - 'delayedFunctionSchedulerFactory' - ), - mockDate = {}, - clock = new privateUnderTest.Clock( - fakeGlobal, - delayedFunctionSchedulerFactory, - mockDate - ); + const originalFakeClearTimeout = function() {}; + const replacedClearTimeout = function() {}; + const fakeGlobal = { clearTimeout: originalFakeClearTimeout }; + const delayedFunctionSchedulerFactory = jasmine.createSpy( + 'delayedFunctionSchedulerFactory' + ); + const mockDate = {}; + const clock = new privateUnderTest.Clock( + fakeGlobal, + delayedFunctionSchedulerFactory, + mockDate + ); fakeGlobal.clearTimeout = replacedClearTimeout; @@ -195,18 +195,18 @@ describe('Clock', function() { }); it('does not install if the current setInterval is not the original function on the global', function() { - const originalFakeSetInterval = function() {}, - replacedSetInterval = function() {}, - fakeGlobal = { setInterval: originalFakeSetInterval }, - delayedFunctionSchedulerFactory = jasmine.createSpy( - 'delayedFunctionSchedulerFactory' - ), - mockDate = {}, - clock = new privateUnderTest.Clock( - fakeGlobal, - delayedFunctionSchedulerFactory, - mockDate - ); + const originalFakeSetInterval = function() {}; + const replacedSetInterval = function() {}; + const fakeGlobal = { setInterval: originalFakeSetInterval }; + const delayedFunctionSchedulerFactory = jasmine.createSpy( + 'delayedFunctionSchedulerFactory' + ); + const mockDate = {}; + const clock = new privateUnderTest.Clock( + fakeGlobal, + delayedFunctionSchedulerFactory, + mockDate + ); fakeGlobal.setInterval = replacedSetInterval; @@ -219,18 +219,18 @@ describe('Clock', function() { }); it('does not install if the current clearInterval is not the original function on the global', function() { - const originalFakeClearInterval = function() {}, - replacedClearInterval = function() {}, - fakeGlobal = { clearInterval: originalFakeClearInterval }, - delayedFunctionSchedulerFactory = jasmine.createSpy( - 'delayedFunctionSchedulerFactory' - ), - mockDate = {}, - clock = new privateUnderTest.Clock( - fakeGlobal, - delayedFunctionSchedulerFactory, - mockDate - ); + const originalFakeClearInterval = function() {}; + const replacedClearInterval = function() {}; + const fakeGlobal = { clearInterval: originalFakeClearInterval }; + const delayedFunctionSchedulerFactory = jasmine.createSpy( + 'delayedFunctionSchedulerFactory' + ); + const mockDate = {}; + const clock = new privateUnderTest.Clock( + fakeGlobal, + delayedFunctionSchedulerFactory, + mockDate + ); fakeGlobal.clearInterval = replacedClearInterval; @@ -243,33 +243,33 @@ describe('Clock', function() { }); it('restores the global timer functions on uninstall', function() { - const fakeSetTimeout = jasmine.createSpy('global setTimeout'), - fakeClearTimeout = jasmine.createSpy('global clearTimeout'), - fakeSetInterval = jasmine.createSpy('global setInterval'), - fakeClearInterval = jasmine.createSpy('global clearInterval'), - fakeGlobal = { - setTimeout: fakeSetTimeout, - clearTimeout: fakeClearTimeout, - setInterval: fakeSetInterval, - clearInterval: fakeClearInterval + const fakeSetTimeout = jasmine.createSpy('global setTimeout'); + const fakeClearTimeout = jasmine.createSpy('global clearTimeout'); + const fakeSetInterval = jasmine.createSpy('global setInterval'); + const fakeClearInterval = jasmine.createSpy('global clearInterval'); + const fakeGlobal = { + setTimeout: fakeSetTimeout, + clearTimeout: fakeClearTimeout, + setInterval: fakeSetInterval, + clearInterval: fakeClearInterval + }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['scheduleFunction', 'reset'] + ); + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['scheduleFunction', 'reset'] - ), - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} - }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); clock.uninstall(); @@ -286,33 +286,33 @@ describe('Clock', function() { }); it('can be installed for the duration of a passed in function and uninstalled when done', function() { - const fakeSetTimeout = jasmine.createSpy('global setTimeout'), - fakeClearTimeout = jasmine.createSpy('global clearTimeout'), - fakeSetInterval = jasmine.createSpy('global setInterval'), - fakeClearInterval = jasmine.createSpy('global clearInterval'), - fakeGlobal = { - setTimeout: fakeSetTimeout, - clearTimeout: fakeClearTimeout, - setInterval: fakeSetInterval, - clearInterval: fakeClearInterval + const fakeSetTimeout = jasmine.createSpy('global setTimeout'); + const fakeClearTimeout = jasmine.createSpy('global clearTimeout'); + const fakeSetInterval = jasmine.createSpy('global setInterval'); + const fakeClearInterval = jasmine.createSpy('global clearInterval'); + const fakeGlobal = { + setTimeout: fakeSetTimeout, + clearTimeout: fakeClearTimeout, + setInterval: fakeSetInterval, + clearInterval: fakeClearInterval + }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['scheduleFunction', 'reset', 'removeFunctionWithId'] + ); + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['scheduleFunction', 'reset', 'removeFunctionWithId'] - ), - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} - }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); let passedFunctionCalled = false; clock.withMock(function() { @@ -346,33 +346,33 @@ describe('Clock', function() { }); it('can be installed for the duration of a passed in function and uninstalled if an error is thrown', function() { - const fakeSetTimeout = jasmine.createSpy('global setTimeout'), - fakeClearTimeout = jasmine.createSpy('global clearTimeout'), - fakeSetInterval = jasmine.createSpy('global setInterval'), - fakeClearInterval = jasmine.createSpy('global clearInterval'), - fakeGlobal = { - setTimeout: fakeSetTimeout, - clearTimeout: fakeClearTimeout, - setInterval: fakeSetInterval, - clearInterval: fakeClearInterval + const fakeSetTimeout = jasmine.createSpy('global setTimeout'); + const fakeClearTimeout = jasmine.createSpy('global clearTimeout'); + const fakeSetInterval = jasmine.createSpy('global setInterval'); + const fakeClearInterval = jasmine.createSpy('global clearInterval'); + const fakeGlobal = { + setTimeout: fakeSetTimeout, + clearTimeout: fakeClearTimeout, + setInterval: fakeSetInterval, + clearInterval: fakeClearInterval + }; + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['scheduleFunction', 'reset', 'removeFunctionWithId'] + ); + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['scheduleFunction', 'reset', 'removeFunctionWithId'] - ), - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} - }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); let passedFunctionCalled = false; expect(function() { @@ -445,24 +445,24 @@ describe('Clock', function() { describe('setTimeout', function() { it('schedules the delayed function with the fake timer', function() { - const fakeSetTimeout = jasmine.createSpy('setTimeout'), - scheduleFunction = jasmine.createSpy('scheduleFunction'), - delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, - fakeGlobal = { setTimeout: fakeSetTimeout }, - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeSetTimeout = jasmine.createSpy('setTimeout'); + const scheduleFunction = jasmine.createSpy('scheduleFunction'); + const delayedFunctionScheduler = { scheduleFunction: scheduleFunction }; + const fakeGlobal = { setTimeout: fakeSetTimeout }; + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ), - timeout = new clock.FakeTimeout(); + mockDate + ); + const timeout = new clock.FakeTimeout(); clock.install(); clock.setTimeout(delayedFn, 0, 'a', 'b'); @@ -487,26 +487,26 @@ describe('Clock', function() { }); it('returns an id for the delayed function', function() { - const fakeSetTimeout = jasmine.createSpy('setTimeout'), - scheduleId = 123, - scheduleFunction = jasmine - .createSpy('scheduleFunction') - .and.returnValue(scheduleId), - delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, - fakeGlobal = { setTimeout: fakeSetTimeout }, - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeSetTimeout = jasmine.createSpy('setTimeout'); + const scheduleId = 123; + const scheduleFunction = jasmine + .createSpy('scheduleFunction') + .and.returnValue(scheduleId); + const delayedFunctionScheduler = { scheduleFunction: scheduleFunction }; + const fakeGlobal = { setTimeout: fakeSetTimeout }; + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); const timeout = clock.setTimeout(delayedFn, 0); @@ -521,24 +521,24 @@ describe('Clock', function() { describe('clearTimeout', function() { it('clears the scheduled function with the scheduler', function() { - const fakeClearTimeout = jasmine.createSpy('clearTimeout'), - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['removeFunctionWithId'] - ), - fakeGlobal = { setTimeout: fakeClearTimeout }, - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeClearTimeout = jasmine.createSpy('clearTimeout'); + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['removeFunctionWithId'] + ); + const fakeGlobal = { setTimeout: fakeClearTimeout }; + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); clock.clearTimeout(123); @@ -552,24 +552,24 @@ describe('Clock', function() { describe('setInterval', function() { it('schedules the delayed function with the fake timer', function() { - const fakeSetInterval = jasmine.createSpy('setInterval'), - scheduleFunction = jasmine.createSpy('scheduleFunction'), - delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, - fakeGlobal = { setInterval: fakeSetInterval }, - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeSetInterval = jasmine.createSpy('setInterval'); + const scheduleFunction = jasmine.createSpy('scheduleFunction'); + const delayedFunctionScheduler = { scheduleFunction: scheduleFunction }; + const fakeGlobal = { setInterval: fakeSetInterval }; + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ), - timeout = new clock.FakeTimeout(); + mockDate + ); + const timeout = new clock.FakeTimeout(); clock.install(); clock.setInterval(delayedFn, 0, 'a', 'b'); @@ -595,26 +595,26 @@ describe('Clock', function() { }); it('returns an id for the delayed function', function() { - const fakeSetInterval = jasmine.createSpy('setInterval'), - scheduleId = 123, - scheduleFunction = jasmine - .createSpy('scheduleFunction') - .and.returnValue(scheduleId), - delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, - fakeGlobal = { setInterval: fakeSetInterval }, - delayedFn = jasmine.createSpy('delayedFn'), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const fakeSetInterval = jasmine.createSpy('setInterval'); + const scheduleId = 123; + const scheduleFunction = jasmine + .createSpy('scheduleFunction') + .and.returnValue(scheduleId); + const delayedFunctionScheduler = { scheduleFunction: scheduleFunction }; + const fakeGlobal = { setInterval: fakeSetInterval }; + const delayedFn = jasmine.createSpy('delayedFn'); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); const interval = clock.setInterval(delayedFn, 0); @@ -629,24 +629,24 @@ describe('Clock', function() { describe('clearInterval', function() { it('clears the scheduled function with the scheduler', function() { - const clearInterval = jasmine.createSpy('clearInterval'), - delayedFunctionScheduler = jasmine.createSpyObj( - 'delayedFunctionScheduler', - ['removeFunctionWithId'] - ), - fakeGlobal = { setInterval: clearInterval }, - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const clearInterval = jasmine.createSpy('clearInterval'); + const delayedFunctionScheduler = jasmine.createSpyObj( + 'delayedFunctionScheduler', + ['removeFunctionWithId'] + ); + const fakeGlobal = { setInterval: clearInterval }; + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + fakeGlobal, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - fakeGlobal, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); clock.clearInterval(123); @@ -671,23 +671,23 @@ describe('Clock', function() { describe('Clock (acceptance)', function() { it('can run setTimeouts/setIntervals synchronously', function() { - const delayedFn1 = jasmine.createSpy('delayedFn1'), - delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFn3 = jasmine.createSpy('delayedFn3'), - recurring1 = jasmine.createSpy('recurring1'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const delayedFn1 = jasmine.createSpy('delayedFn1'); + const delayedFn2 = jasmine.createSpy('delayedFn2'); + const delayedFn3 = jasmine.createSpy('delayedFn3'); + const recurring1 = jasmine.createSpy('recurring1'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setTimeout: setTimeout }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setTimeout: setTimeout }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); @@ -776,10 +776,10 @@ describe('Clock (acceptance)', function() { }); it('can run setTimeouts/setIntervals asynchronously', function() { - const recurring = jasmine.createSpy('recurring'), - fn1 = jasmine.createSpy('fn1'), - fn2 = jasmine.createSpy('fn2'), - fn3 = jasmine.createSpy('fn3'); + const recurring = jasmine.createSpy('recurring'); + const fn1 = jasmine.createSpy('fn1'); + const fn2 = jasmine.createSpy('fn2'); + const fn3 = jasmine.createSpy('fn3'); const intervalId = clock.setInterval(recurring, 50); // In a microtask, add some timeouts. @@ -884,20 +884,20 @@ describe('Clock (acceptance)', function() { }); it('can clear a previously set timeout', function() { - const clearedFn = jasmine.createSpy('clearedFn'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const clearedFn = jasmine.createSpy('clearedFn'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setTimeout: function() {} }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setTimeout: function() {} }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); @@ -911,20 +911,20 @@ describe('Clock (acceptance)', function() { }); it("can clear a previously set interval using that interval's handler", function() { - const spy = jasmine.createSpy('spy'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const spy = jasmine.createSpy('spy'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setInterval: function() {} }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setInterval: function() {} }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); @@ -938,20 +938,20 @@ describe('Clock (acceptance)', function() { }); it('correctly schedules functions after the Clock has advanced', function() { - const delayedFn1 = jasmine.createSpy('delayedFn1'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const delayedFn1 = jasmine.createSpy('delayedFn1'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setTimeout: function() {} }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setTimeout: function() {} }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); clock.install(); @@ -964,21 +964,21 @@ describe('Clock (acceptance)', function() { }); it('correctly schedules functions while the Clock is advancing', function() { - const delayedFn1 = jasmine.createSpy('delayedFn1'), - delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const delayedFn1 = jasmine.createSpy('delayedFn1'); + const delayedFn2 = jasmine.createSpy('delayedFn2'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setTimeout: function() {} }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setTimeout: function() {} }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); @@ -995,21 +995,21 @@ describe('Clock (acceptance)', function() { }); it('correctly calls functions scheduled while the Clock is advancing', function() { - const delayedFn1 = jasmine.createSpy('delayedFn1'), - delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const delayedFn1 = jasmine.createSpy('delayedFn1'); + const delayedFn2 = jasmine.createSpy('delayedFn2'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setTimeout: function() {} }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setTimeout: function() {} }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); @@ -1023,21 +1023,21 @@ describe('Clock (acceptance)', function() { }); it('correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled', function() { - const delayedFn1 = jasmine.createSpy('delayedFn1'), - delayedFn2 = jasmine.createSpy('delayedFn2'), - delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - mockDate = { - install: function() {}, - tick: function() {}, - uninstall: function() {} + const delayedFn1 = jasmine.createSpy('delayedFn1'); + const delayedFn2 = jasmine.createSpy('delayedFn2'); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const mockDate = { + install: function() {}, + tick: function() {}, + uninstall: function() {} + }; + const clock = new privateUnderTest.Clock( + { setTimeout: function() {} }, + function() { + return delayedFunctionScheduler; }, - clock = new privateUnderTest.Clock( - { setTimeout: function() {} }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + mockDate + ); delayedFn1.and.callFake(function() { clock.uninstall(); @@ -1057,16 +1057,16 @@ describe('Clock (acceptance)', function() { }); it('does not mock the Date object by default', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - { setTimeout: setTimeout }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + { setTimeout: setTimeout }, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); clock.install(); @@ -1080,16 +1080,16 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and sets it to current time', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - { setTimeout: setTimeout }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + { setTimeout: setTimeout }, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); clock.install().mockDate(); @@ -1110,17 +1110,17 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and sets it to a given time', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - { setTimeout: setTimeout }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ), - baseTime = new Date(2013, 9, 23); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + { setTimeout: setTimeout }, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); + const baseTime = new Date(2013, 9, 23); clock.install().mockDate(baseTime); @@ -1143,16 +1143,16 @@ describe('Clock (acceptance)', function() { }); it('throws mockDate is called with a non-Date', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - { setTimeout: setTimeout }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + { setTimeout: setTimeout }, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); expect(() => clock.mockDate(12345)).toThrowError( 'The argument to jasmine.clock().mockDate(), if specified, should be ' + @@ -1161,17 +1161,17 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and updates the date per delayed function', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - { setTimeout: setTimeout }, - function() { - return delayedFunctionScheduler; - }, - mockDate - ), - baseTime = new Date(); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + { setTimeout: setTimeout }, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); + const baseTime = new Date(); clock.install().mockDate(baseTime); @@ -1200,16 +1200,16 @@ describe('Clock (acceptance)', function() { }); it('correctly clears a scheduled timeout while the Clock is advancing', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date, setTimeout: undefined }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - global, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date, setTimeout: undefined }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + global, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); clock.install(); @@ -1225,16 +1225,16 @@ describe('Clock (acceptance)', function() { }); it('correctly clears a scheduled interval while the Clock is advancing', function() { - const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(), - global = { Date: Date, setTimeout: undefined }, - mockDate = new privateUnderTest.MockDate(global), - clock = new privateUnderTest.Clock( - global, - function() { - return delayedFunctionScheduler; - }, - mockDate - ); + const delayedFunctionScheduler = new privateUnderTest.DelayedFunctionScheduler(); + const global = { Date: Date, setTimeout: undefined }; + const mockDate = new privateUnderTest.MockDate(global); + const clock = new privateUnderTest.Clock( + global, + function() { + return delayedFunctionScheduler; + }, + mockDate + ); clock.install(); diff --git a/spec/core/DelayedFunctionSchedulerSpec.js b/spec/core/DelayedFunctionSchedulerSpec.js index 6a2f775e..82601295 100644 --- a/spec/core/DelayedFunctionSchedulerSpec.js +++ b/spec/core/DelayedFunctionSchedulerSpec.js @@ -2,8 +2,8 @@ describe('DelayedFunctionScheduler', function() { 'use strict'; it('schedules a function for later execution', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0); @@ -25,8 +25,8 @@ describe('DelayedFunctionScheduler', function() { }); it('#tick defaults to 0', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0); @@ -38,8 +38,8 @@ describe('DelayedFunctionScheduler', function() { }); it('defaults delay to 0', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn); @@ -51,8 +51,8 @@ describe('DelayedFunctionScheduler', function() { }); it('optionally passes params to scheduled functions', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0, ['foo', 'bar']); @@ -64,8 +64,8 @@ describe('DelayedFunctionScheduler', function() { }); it('scheduled fns can optionally reoccur', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 20, [], true); @@ -97,9 +97,9 @@ describe('DelayedFunctionScheduler', function() { }); it('#removeFunctionWithId removes a previously scheduled function with a given id', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - timeoutKey = scheduler.scheduleFunction(fn, 0); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + const timeoutKey = scheduler.scheduleFunction(fn, 0); expect(fn).not.toHaveBeenCalled(); @@ -132,9 +132,9 @@ describe('DelayedFunctionScheduler', function() { }); it('schedules a function for later execution during a tick', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - fnDelay = 10; + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + const fnDelay = 10; scheduler.scheduleFunction(function() { scheduler.scheduleFunction(fn, fnDelay); @@ -148,9 +148,9 @@ describe('DelayedFunctionScheduler', function() { }); it('#removeFunctionWithId removes a previously scheduled function with a given id during a tick', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - fnDelay = 10; + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + const fnDelay = 10; let timeoutKey; scheduler.scheduleFunction(function() { @@ -199,10 +199,10 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions after rescheduling them', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - recurring = function() { - expect(scheduler.scheduleFunction).toHaveBeenCalled(); - }; + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const recurring = function() { + expect(scheduler.scheduleFunction).toHaveBeenCalled(); + }; scheduler.scheduleFunction(recurring, 10, [], true); @@ -212,10 +212,10 @@ describe('DelayedFunctionScheduler', function() { }); it('removes functions during a tick that runs the function', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - spy = jasmine.createSpy('fn'), - spyAndRemove = jasmine.createSpy('fn'), - fnDelay = 10; + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const spy = jasmine.createSpy('fn'); + const spyAndRemove = jasmine.createSpy('fn'); + const fnDelay = 10; let timeoutKey; spyAndRemove.and.callFake(function() { @@ -233,9 +233,9 @@ describe('DelayedFunctionScheduler', function() { }); it('removes functions during the first tick that runs the function', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - fnDelay = 10; + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + const fnDelay = 10; let timeoutKey; timeoutKey = scheduler.scheduleFunction(fn, fnDelay, [], true); @@ -252,9 +252,9 @@ describe('DelayedFunctionScheduler', function() { }); it("does not remove a function that hasn't been added yet", function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - fnDelay = 10; + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + const fnDelay = 10; scheduler.removeFunctionWithId('foo'); scheduler.scheduleFunction(fn, fnDelay, [], false, 'foo'); @@ -303,8 +303,8 @@ describe('DelayedFunctionScheduler', function() { }); it('updates the mockDate per scheduled time', function() { - const scheduler = new privateUnderTest.DelayedFunctionScheduler(), - tickDate = jasmine.createSpy('tickDate'); + const scheduler = new privateUnderTest.DelayedFunctionScheduler(); + const tickDate = jasmine.createSpy('tickDate'); scheduler.scheduleFunction(function() {}); scheduler.scheduleFunction(function() {}, 1); diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index 2c420d31..ba0c7856 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -2,13 +2,13 @@ describe('ExceptionFormatter', function() { describe('#message', function() { it('formats Firefox exception messages', function() { const sampleFirefoxException = { - fileName: 'foo.js', - lineNumber: '1978', - message: 'you got your foo in my bar', - name: 'A Classic Mistake' - }, - exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - message = exceptionFormatter.message(sampleFirefoxException); + fileName: 'foo.js', + lineNumber: '1978', + message: 'you got your foo in my bar', + name: 'A Classic Mistake' + }; + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const message = exceptionFormatter.message(sampleFirefoxException); expect(message).toEqual( 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)' @@ -17,13 +17,13 @@ describe('ExceptionFormatter', function() { it('formats Webkit exception messages', function() { const sampleWebkitException = { - sourceURL: 'foo.js', - line: '1978', - message: 'you got your foo in my bar', - name: 'A Classic Mistake' - }, - exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - message = exceptionFormatter.message(sampleWebkitException); + sourceURL: 'foo.js', + line: '1978', + message: 'you got your foo in my bar', + name: 'A Classic Mistake' + }; + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const message = exceptionFormatter.message(sampleWebkitException); expect(message).toEqual( 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)' @@ -32,11 +32,11 @@ describe('ExceptionFormatter', function() { it('formats V8 exception messages', function() { const sampleV8 = { - message: 'you got your foo in my bar', - name: 'A Classic Mistake' - }, - exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - message = exceptionFormatter.message(sampleV8); + message: 'you got your foo in my bar', + name: 'A Classic Mistake' + }; + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const message = exceptionFormatter.message(sampleV8); expect(message).toEqual('A Classic Mistake: you got your foo in my bar'); }); @@ -44,8 +44,8 @@ describe('ExceptionFormatter', function() { it('formats unnamed exceptions with message', function() { const unnamedError = { message: 'This is an unnamed error message.' }; - const exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - message = exceptionFormatter.message(unnamedError); + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const message = exceptionFormatter.message(unnamedError); expect(message).toEqual('This is an unnamed error message.'); }); @@ -57,16 +57,16 @@ describe('ExceptionFormatter', function() { }; const emptyError = new EmptyError(); - const exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - message = exceptionFormatter.message(emptyError); + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const message = exceptionFormatter.message(emptyError); expect(message).toEqual('[EmptyError] thrown'); }); it("formats thrown exceptions that aren't errors", function() { - const thrown = 'crazy error', - exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - message = exceptionFormatter.message(thrown); + const thrown = 'crazy error'; + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const message = exceptionFormatter.message(thrown); expect(message).toEqual('crazy error thrown'); }); diff --git a/spec/core/ExpectationFilterChainSpec.js b/spec/core/ExpectationFilterChainSpec.js index f0acbb5d..e19c2f28 100644 --- a/spec/core/ExpectationFilterChainSpec.js +++ b/spec/core/ExpectationFilterChainSpec.js @@ -1,12 +1,12 @@ describe('ExpectationFilterChain', function() { describe('#addFilter', function() { it('returns a new filter chain with the added filter', function() { - const first = jasmine.createSpy('first'), - second = jasmine.createSpy('second'), - orig = new privateUnderTest.ExpectationFilterChain({ - modifyFailureMessage: first - }), - added = orig.addFilter({ selectComparisonFunc: second }); + const first = jasmine.createSpy('first'); + const second = jasmine.createSpy('second'); + const orig = new privateUnderTest.ExpectationFilterChain({ + modifyFailureMessage: first + }); + const added = orig.addFilter({ selectComparisonFunc: second }); added.modifyFailureMessage(); expect(first).toHaveBeenCalled(); @@ -15,8 +15,8 @@ describe('ExpectationFilterChain', function() { }); it('does not modify the original filter chain', function() { - const orig = new privateUnderTest.ExpectationFilterChain({}), - f = jasmine.createSpy('f'); + const orig = new privateUnderTest.ExpectationFilterChain({}); + const f = jasmine.createSpy('f'); orig.addFilter({ selectComparisonFunc: f }); @@ -36,13 +36,13 @@ describe('ExpectationFilterChain', function() { describe('When some filters have #selectComparisonFunc', function() { it('calls the first filter that has #selectComparisonFunc', function() { - const first = jasmine.createSpy('first').and.returnValue('first'), - second = jasmine.createSpy('second').and.returnValue('second'), - chain = new privateUnderTest.ExpectationFilterChain() - .addFilter({ selectComparisonFunc: first }) - .addFilter({ selectComparisonFunc: second }), - matcher = {}, - result = chain.selectComparisonFunc(matcher); + const first = jasmine.createSpy('first').and.returnValue('first'); + const second = jasmine.createSpy('second').and.returnValue('second'); + const chain = new privateUnderTest.ExpectationFilterChain() + .addFilter({ selectComparisonFunc: first }) + .addFilter({ selectComparisonFunc: second }); + const matcher = {}; + const result = chain.selectComparisonFunc(matcher); expect(first).toHaveBeenCalledWith(matcher); expect(second).not.toHaveBeenCalled(); @@ -62,15 +62,15 @@ describe('ExpectationFilterChain', function() { describe('When some filters have #buildFailureMessage', function() { it('calls the first filter that has #buildFailureMessage', function() { - const first = jasmine.createSpy('first').and.returnValue('first'), - second = jasmine.createSpy('second').and.returnValue('second'), - chain = new privateUnderTest.ExpectationFilterChain() - .addFilter({ buildFailureMessage: first }) - .addFilter({ buildFailureMessage: second }), - matcherResult = { pass: false }, - matcherName = 'foo', - args = [], - matchersUtil = {}; + const first = jasmine.createSpy('first').and.returnValue('first'); + const second = jasmine.createSpy('second').and.returnValue('second'); + const chain = new privateUnderTest.ExpectationFilterChain() + .addFilter({ buildFailureMessage: first }) + .addFilter({ buildFailureMessage: second }); + const matcherResult = { pass: false }; + const matcherName = 'foo'; + const args = []; + const matchersUtil = {}; const result = chain.buildFailureMessage( matcherResult, @@ -102,12 +102,12 @@ describe('ExpectationFilterChain', function() { describe('When some filters have #modifyFailureMessage', function() { it('calls the first filter that has #modifyFailureMessage', function() { - const first = jasmine.createSpy('first').and.returnValue('first'), - second = jasmine.createSpy('second').and.returnValue('second'), - chain = new privateUnderTest.ExpectationFilterChain() - .addFilter({ modifyFailureMessage: first }) - .addFilter({ modifyFailureMessage: second }), - result = chain.modifyFailureMessage('original'); + const first = jasmine.createSpy('first').and.returnValue('first'); + const second = jasmine.createSpy('second').and.returnValue('second'); + const chain = new privateUnderTest.ExpectationFilterChain() + .addFilter({ modifyFailureMessage: first }) + .addFilter({ modifyFailureMessage: second }); + const result = chain.modifyFailureMessage('original'); expect(first).toHaveBeenCalledWith('original'); expect(second).not.toHaveBeenCalled(); diff --git a/spec/core/ExpectationSpec.js b/spec/core/ExpectationSpec.js index 0e1f110f..9d2a1076 100644 --- a/spec/core/ExpectationSpec.js +++ b/spec/core/ExpectationSpec.js @@ -1,12 +1,12 @@ describe('Expectation', function() { it('makes custom matchers available to this expectation', function() { const matchers = { - toFoo: function() {}, - toBar: function() {} - }, - expectation = privateUnderTest.Expectation.factory({ - customMatchers: matchers - }); + toFoo: function() {}, + toBar: function() {} + }; + const expectation = privateUnderTest.Expectation.factory({ + customMatchers: matchers + }); expect(expectation.toFoo).toBeDefined(); expect(expectation.toBar).toBeDefined(); @@ -26,18 +26,18 @@ describe('Expectation', function() { it("wraps matchers's compare functions, passing in matcher dependencies", function() { const fakeCompare = function() { - return { pass: true }; - }, - matcherFactory = jasmine - .createSpy('matcher') - .and.returnValue({ compare: fakeCompare }), - matchers = { - toFoo: matcherFactory - }, - matchersUtil = { - buildFailureMessage: jasmine.createSpy('buildFailureMessage') - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + return { pass: true }; + }; + const matcherFactory = jasmine + .createSpy('matcher') + .and.returnValue({ compare: fakeCompare }); + const matchers = { + toFoo: matcherFactory + }; + const matchersUtil = { + buildFailureMessage: jasmine.createSpy('buildFailureMessage') + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ matchersUtil: matchersUtil, @@ -53,19 +53,19 @@ describe('Expectation', function() { it("wraps matchers's compare functions, passing the actual and expected", function() { const fakeCompare = jasmine - .createSpy('fake-compare') - .and.returnValue({ pass: true }), - matchers = { - toFoo: function() { - return { - compare: fakeCompare - }; - } - }, - matchersUtil = { - buildFailureMessage: jasmine.createSpy('buildFailureMessage') - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + .createSpy('fake-compare') + .and.returnValue({ pass: true }); + const matchers = { + toFoo: function() { + return { + compare: fakeCompare + }; + } + }; + const matchersUtil = { + buildFailureMessage: jasmine.createSpy('buildFailureMessage') + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ matchersUtil: matchersUtil, @@ -81,18 +81,18 @@ describe('Expectation', function() { it('reports a passing result to the spec when the comparison passes', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: true }; - } - }; - } - }, - matchersUtil = { - buildFailureMessage: jasmine.createSpy('buildFailureMessage') - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { pass: true }; + } + }; + } + }; + const matchersUtil = { + buildFailureMessage: jasmine.createSpy('buildFailureMessage') + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -114,20 +114,20 @@ describe('Expectation', function() { it('reports a failing result to the spec when the comparison fails', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: false }; - } - }; - } - }, - matchersUtil = { - buildFailureMessage: function() { - return ''; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { pass: false }; + } + }; + } + }; + const matchersUtil = { + buildFailureMessage: function() { + return ''; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -149,18 +149,18 @@ describe('Expectation', function() { it('reports a failing result and a custom fail message to the spec when the comparison fails', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: false, - message: 'I am a custom message' - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { + pass: false, + message: 'I am a custom message' + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', @@ -181,20 +181,20 @@ describe('Expectation', function() { it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: false, - message: function() { - return 'I am a custom message'; - } - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { + pass: false, + message: function() { + return 'I am a custom message'; + } + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -215,15 +215,15 @@ describe('Expectation', function() { it('reports a passing result to the spec when the comparison fails for a negative expectation', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: false }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { pass: false }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -244,20 +244,20 @@ describe('Expectation', function() { it('reports a failing result to the spec when the comparison passes for a negative expectation', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: true }; - } - }; - } - }, - matchersUtil = { - buildFailureMessage: function() { - return 'default message'; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { pass: true }; + } + }; + } + }; + const matchersUtil = { + buildFailureMessage: function() { + return 'default message'; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -279,18 +279,18 @@ describe('Expectation', function() { it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: true, - message: 'I am a custom message' - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { + pass: true, + message: 'I am a custom message' + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -311,18 +311,18 @@ describe('Expectation', function() { it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: true }; - }, - negativeCompare: function() { - return { pass: true }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { pass: true }; + }, + negativeCompare: function() { + return { pass: true }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -343,21 +343,21 @@ describe('Expectation', function() { it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: true }; - }, - negativeCompare: function() { - return { - pass: false, - message: "I'm a custom message" - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { pass: true }; + }, + negativeCompare: function() { + return { + pass: false, + message: "I'm a custom message" + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ customMatchers: matchers, @@ -379,19 +379,19 @@ describe('Expectation', function() { it('reports a custom error message to the spec', function() { const customError = new Error('I am a custom error'); const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: false, - message: 'I am a custom message', - error: customError - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { + pass: false, + message: 'I am a custom message', + error: customError + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', @@ -413,19 +413,19 @@ describe('Expectation', function() { it("reports a custom message to the spec when a 'not' comparison fails", function() { const customError = new Error('I am a custom error'); const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: true, - message: 'I am a custom message', - error: customError - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { + pass: true, + message: 'I am a custom message', + error: customError + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', @@ -447,21 +447,21 @@ describe('Expectation', function() { it("reports a custom message func to the spec when a 'not' comparison fails", function() { const customError = new Error('I am a custom error'); const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: true, - message: function() { - return 'I am a custom message'; - }, - error: customError - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'); + toFoo: function() { + return { + compare: function() { + return { + pass: true, + message: function() { + return 'I am a custom message'; + }, + error: customError + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); const expectation = privateUnderTest.Expectation.factory({ actual: 'an actual', @@ -483,26 +483,26 @@ describe('Expectation', function() { describe('#withContext', function() { it('prepends the context to the generated failure message', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: false }; - } - }; - } - }, - matchersUtil = { - buildFailureMessage: function() { - return 'failure message'; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.factory({ - customMatchers: matchers, - matchersUtil: matchersUtil, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + toFoo: function() { + return { + compare: function() { + return { pass: false }; + } + }; + } + }; + const matchersUtil = { + buildFailureMessage: function() { + return 'failure message'; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.factory({ + customMatchers: matchers, + matchersUtil: matchersUtil, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); expectation.withContext('Some context').toFoo('hello'); @@ -516,20 +516,20 @@ describe('Expectation', function() { it('prepends the context to a custom failure message', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: false, message: 'msg' }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.factory({ - customMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + toFoo: function() { + return { + compare: function() { + return { pass: false, message: 'msg' }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.factory({ + customMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); expectation.withContext('Some context').toFoo('hello'); @@ -543,20 +543,20 @@ describe('Expectation', function() { it('indents a multiline failure message', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: false, message: 'a\nmultiline\nmessage' }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.factory({ - customMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + toFoo: function() { + return { + compare: function() { + return { pass: false, message: 'a\nmultiline\nmessage' }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.factory({ + customMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); expectation.withContext('Some context').toFoo('hello'); @@ -568,25 +568,25 @@ describe('Expectation', function() { it('prepends the context to a custom failure message from a function', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: false, - message: function() { - return 'msg'; - } - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.factory({ - customMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + toFoo: function() { + return { + compare: function() { + return { + pass: false, + message: function() { + return 'msg'; + } + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.factory({ + customMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); expectation.withContext('Some context').toFoo('hello'); @@ -600,22 +600,22 @@ describe('Expectation', function() { it('works with #not', function() { const matchers = { - toFoo: function() { - return { - compare: function() { - return { pass: true }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - pp = privateUnderTest.makePrettyPrinter(), - expectation = privateUnderTest.Expectation.factory({ - customMatchers: matchers, - matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }), - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + toFoo: function() { + return { + compare: function() { + return { pass: true }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const pp = privateUnderTest.makePrettyPrinter(); + const expectation = privateUnderTest.Expectation.factory({ + customMatchers: matchers, + matchersUtil: new privateUnderTest.MatchersUtil({ pp: pp }), + actual: 'an actual', + addExpectationResult: addExpectationResult + }); expectation.withContext('Some context').not.toFoo(); @@ -630,26 +630,26 @@ describe('Expectation', function() { it('works with #not and a custom message', function() { const customError = new Error('I am a custom error'); const matchers = { - toFoo: function() { - return { - compare: function() { - return { - pass: true, - message: function() { - return 'I am a custom message'; - }, - error: customError - }; - } - }; - } - }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation = privateUnderTest.Expectation.factory({ - actual: 'an actual', - customMatchers: matchers, - addExpectationResult: addExpectationResult - }); + toFoo: function() { + return { + compare: function() { + return { + pass: true, + message: function() { + return 'I am a custom message'; + }, + error: customError + }; + } + }; + } + }; + const addExpectationResult = jasmine.createSpy('addExpectationResult'); + const expectation = privateUnderTest.Expectation.factory({ + actual: 'an actual', + customMatchers: matchers, + addExpectationResult: addExpectationResult + }); expectation.withContext('Some context').not.toFoo('hello'); diff --git a/spec/core/JsApiReporterSpec.js b/spec/core/JsApiReporterSpec.js index d2af65ce..5b3502ef 100644 --- a/spec/core/JsApiReporterSpec.js +++ b/spec/core/JsApiReporterSpec.js @@ -137,20 +137,20 @@ describe('JsApiReporter', function() { describe('#executionTime', function() { it('should start the timer when jasmine starts', function() { - const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new privateUnderTest.JsApiReporter({ - timer: timerSpy - }); + const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']); + const reporter = new privateUnderTest.JsApiReporter({ + timer: timerSpy + }); reporter.jasmineStarted(); expect(timerSpy.start).toHaveBeenCalled(); }); it('should return the time it took the specs to run, in ms', function() { - const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new privateUnderTest.JsApiReporter({ - timer: timerSpy - }); + const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']); + const reporter = new privateUnderTest.JsApiReporter({ + timer: timerSpy + }); timerSpy.elapsed.and.returnValue(1000); reporter.jasmineDone(); @@ -159,10 +159,10 @@ describe('JsApiReporter', function() { describe("when the specs haven't finished being run", function() { it('should return undefined', function() { - const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), - reporter = new privateUnderTest.JsApiReporter({ - timer: timerSpy - }); + const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']); + const reporter = new privateUnderTest.JsApiReporter({ + timer: timerSpy + }); expect(reporter.executionTime()).toBeUndefined(); }); diff --git a/spec/core/MockDateSpec.js b/spec/core/MockDateSpec.js index e394ac8e..f45bb16a 100644 --- a/spec/core/MockDateSpec.js +++ b/spec/core/MockDateSpec.js @@ -1,7 +1,7 @@ describe('FakeDate', function() { it('does not fail if no global date is found', function() { - const fakeGlobal = {}, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + const fakeGlobal = {}; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); expect(function() { mockDate.install(); @@ -12,14 +12,14 @@ describe('FakeDate', function() { it('replaces the global Date when it is installed', function() { const globalDate = jasmine - .createSpy('global Date') - .and.callFake(function() { - return { - getTime: function() {} - }; - }), - fakeGlobal = { Date: globalDate }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() {} + }; + }); + const fakeGlobal = { Date: globalDate }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); expect(fakeGlobal.Date).toEqual(globalDate); mockDate.install(); @@ -29,14 +29,14 @@ describe('FakeDate', function() { it('replaces the global Date on uninstall', function() { const globalDate = jasmine - .createSpy('global Date') - .and.callFake(function() { - return { - getTime: function() {} - }; - }), - fakeGlobal = { Date: globalDate }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() {} + }; + }); + const fakeGlobal = { Date: globalDate }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); mockDate.uninstall(); @@ -46,16 +46,16 @@ describe('FakeDate', function() { it('takes the current time as the base when installing without parameters', function() { const globalDate = jasmine - .createSpy('global Date') - .and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), - fakeGlobal = { Date: globalDate }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }); + const fakeGlobal = { Date: globalDate }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -65,9 +65,9 @@ describe('FakeDate', function() { }); it('can accept a date as time base when installing', function() { - const fakeGlobal = { Date: Date }, - mockDate = new privateUnderTest.MockDate(fakeGlobal), - baseDate = new Date(); + const fakeGlobal = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); + const baseDate = new Date(); spyOn(baseDate, 'getTime').and.returnValue(123); mockDate.install(baseDate); @@ -76,8 +76,8 @@ describe('FakeDate', function() { }); it('makes real dates', function() { - const fakeGlobal = { Date: Date }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + const fakeGlobal = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date)); @@ -86,15 +86,15 @@ describe('FakeDate', function() { it('fakes current time when using Date.now()', function() { const globalDate = jasmine - .createSpy('global Date') - .and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), - fakeGlobal = { Date: globalDate }; + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }); + const fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; const mockDate = new privateUnderTest.MockDate(fakeGlobal); @@ -106,15 +106,15 @@ describe('FakeDate', function() { it('makes time passes using tick', function() { const globalDate = jasmine - .createSpy('global Date') - .and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), - fakeGlobal = { Date: globalDate }; + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }); + const fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; const mockDate = new privateUnderTest.MockDate(fakeGlobal); @@ -132,15 +132,15 @@ describe('FakeDate', function() { it('allows to increase 0 milliseconds using tick', function() { const globalDate = jasmine - .createSpy('global Date') - .and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), - fakeGlobal = { Date: globalDate }; + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }); + const fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; const mockDate = new privateUnderTest.MockDate(fakeGlobal); @@ -155,8 +155,8 @@ describe('FakeDate', function() { }); it('allows creation of a Date in a different time than the mocked time', function() { - const fakeGlobal = { Date: Date }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + const fakeGlobal = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -167,8 +167,8 @@ describe('FakeDate', function() { }); it("allows creation of a Date that isn't fully specified", function() { - const fakeGlobal = { Date: Date }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + const fakeGlobal = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -177,9 +177,9 @@ describe('FakeDate', function() { }); it('allows creation of a Date with millis', function() { - const fakeGlobal = { Date: Date }, - mockDate = new privateUnderTest.MockDate(fakeGlobal), - now = new Date(2014, 3, 15).getTime(); + const fakeGlobal = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); + const now = new Date(2014, 3, 15).getTime(); mockDate.install(); @@ -188,8 +188,8 @@ describe('FakeDate', function() { }); it('copies all Date properties to the mocked date', function() { - const fakeGlobal = { Date: Date }, - mockDate = new privateUnderTest.MockDate(fakeGlobal); + const fakeGlobal = { Date: Date }; + const mockDate = new privateUnderTest.MockDate(fakeGlobal); mockDate.install(); diff --git a/spec/core/PrettyPrintSpec.js b/spec/core/PrettyPrintSpec.js index f737cb30..27cf7a04 100644 --- a/spec/core/PrettyPrintSpec.js +++ b/spec/core/PrettyPrintSpec.js @@ -227,26 +227,26 @@ describe('PrettyPrinter', function() { it('should not serialize more objects after hitting MAX_PRETTY_PRINT_CHARS', function() { const a = { - jasmineToString: function() { - return 'object a'; - } - }, - b = { - jasmineToString: function() { - return 'object b'; - } - }, - c = { - jasmineToString: jasmine - .createSpy('c jasmineToString') - .and.returnValue('') - }, - d = { - jasmineToString: jasmine - .createSpy('d jasmineToString') - .and.returnValue('') - }, - pp = privateUnderTest.makePrettyPrinter(); + jasmineToString: function() { + return 'object a'; + } + }; + const b = { + jasmineToString: function() { + return 'object b'; + } + }; + const c = { + jasmineToString: jasmine + .createSpy('c jasmineToString') + .and.returnValue('') + }; + const d = { + jasmineToString: jasmine + .createSpy('d jasmineToString') + .and.returnValue('') + }; + const pp = privateUnderTest.makePrettyPrinter(); withMaxChars(30, function() { pp([{ a: a, b: b, c: c }, d]); @@ -388,10 +388,10 @@ describe('PrettyPrinter', function() { it('should stringify spyOn toString properly', function() { const TestObject = { - someFunction: function() {} - }, - env = new privateUnderTest.Env(), - pp = privateUnderTest.makePrettyPrinter(); + someFunction: function() {} + }; + const env = new privateUnderTest.Env(); + const pp = privateUnderTest.makePrettyPrinter(); const spyRegistry = new privateUnderTest.SpyRegistry({ currentSpies: function() { @@ -535,30 +535,30 @@ describe('PrettyPrinter', function() { describe('Custom object formatters', function() { it('should use the first custom object formatter that does not return undefined', function() { const customObjectFormatters = [ - function() { - return undefined; - }, - function(obj) { - return '2nd: ' + obj.foo; - }, - function(obj) { - return '3rd: ' + obj.foo; - } - ], - pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), - obj = { foo: 'bar' }; + function() { + return undefined; + }, + function(obj) { + return '2nd: ' + obj.foo; + }, + function(obj) { + return '3rd: ' + obj.foo; + } + ]; + const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters); + const obj = { foo: 'bar' }; expect(pp(obj)).toEqual('2nd: bar'); }); it('should fall back to built in logic if all custom object formatters return undefined', function() { const customObjectFormatters = [ - function() { - return undefined; - } - ], - pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), - obj = { foo: 'bar' }; + function() { + return undefined; + } + ]; + const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters); + const obj = { foo: 'bar' }; expect(pp(obj)).toEqual("Object({ foo: 'bar' })"); }); @@ -567,30 +567,30 @@ describe('PrettyPrinter', function() { describe('#customFormat_', function() { it('should use the first custom object formatter that does not return undefined', function() { const customObjectFormatters = [ - function() { - return undefined; - }, - function(obj) { - return '2nd: ' + obj.foo; - }, - function(obj) { - return '3rd: ' + obj.foo; - } - ], - pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), - obj = { foo: 'bar' }; + function() { + return undefined; + }, + function(obj) { + return '2nd: ' + obj.foo; + }, + function(obj) { + return '3rd: ' + obj.foo; + } + ]; + const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters); + const obj = { foo: 'bar' }; expect(pp.customFormat_(obj)).toEqual('2nd: bar'); }); it('should return undefined if all custom object formatters return undefined', function() { const customObjectFormatters = [ - function() { - return undefined; - } - ], - pp = privateUnderTest.makePrettyPrinter(customObjectFormatters), - obj = { foo: 'bar' }; + function() { + return undefined; + } + ]; + const pp = privateUnderTest.makePrettyPrinter(customObjectFormatters); + const obj = { foo: 'bar' }; expect(pp.customFormat_(obj)).toBeUndefined(); }); diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index bfc22490..efe62168 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -16,12 +16,12 @@ describe('QueueRunner', function() { }); it("runs all the functions it's passed", function() { - const calls = [], - queueableFn1 = { fn: jasmine.createSpy('fn1') }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2] - }); + const calls = []; + const queueableFn1 = { fn: jasmine.createSpy('fn1') }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2] + }); queueableFn1.fn.and.callFake(function() { calls.push('fn1'); }); @@ -39,14 +39,14 @@ describe('QueueRunner', function() { const queueableFn2 = { fn: jasmine.createSpy('fn2') }; let asyncContext; const queueableFn3 = { - fn: function(done) { - asyncContext = this; - done(); - } - }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2, queueableFn3] - }); + fn: function(done) { + asyncContext = this; + done(); + } + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2, queueableFn3] + }); queueRunner.execute(); @@ -69,32 +69,32 @@ describe('QueueRunner', function() { //TODO: it would be nice if spy arity could match the fake, so we could do something like: //createSpy('asyncfn').and.callFake(function(done) {}); - const onComplete = jasmine.createSpy('onComplete'), - beforeCallback = jasmine.createSpy('beforeCallback'), - fnCallback = jasmine.createSpy('fnCallback'), - afterCallback = jasmine.createSpy('afterCallback'), - queueableFn1 = { - fn: function(done) { - beforeCallback(); - setTimeout(done, 100); - } - }, - queueableFn2 = { - fn: function(done) { - fnCallback(); - setTimeout(done, 100); - } - }, - queueableFn3 = { - fn: function(done) { - afterCallback(); - setTimeout(done, 100); - } - }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2, queueableFn3], - onComplete: onComplete - }); + const onComplete = jasmine.createSpy('onComplete'); + const beforeCallback = jasmine.createSpy('beforeCallback'); + const fnCallback = jasmine.createSpy('fnCallback'); + const afterCallback = jasmine.createSpy('afterCallback'); + const queueableFn1 = { + fn: function(done) { + beforeCallback(); + setTimeout(done, 100); + } + }; + const queueableFn2 = { + fn: function(done) { + fnCallback(); + setTimeout(done, 100); + } + }; + const queueableFn3 = { + fn: function(done) { + afterCallback(); + setTimeout(done, 100); + } + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2, queueableFn3], + onComplete: onComplete + }); queueRunner.execute(); @@ -121,18 +121,18 @@ describe('QueueRunner', function() { it('explicitly fails an async function with a provided fail function and moves to the next function', function() { const queueableFn1 = { - fn: function(done) { - setTimeout(function() { - done.fail('foo'); - }, 100); - } - }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - failFn = jasmine.createSpy('fail'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2], - fail: failFn - }); + fn: function(done) { + setTimeout(function() { + done.fail('foo'); + }, 100); + } + }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + const failFn = jasmine.createSpy('fail'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2], + fail: failFn + }); queueRunner.execute(); @@ -147,20 +147,20 @@ describe('QueueRunner', function() { describe('When next is called with an argument', function() { it('explicitly fails and moves to the next function', function() { - const err = 'anything except undefined', - queueableFn1 = { - fn: function(done) { - setTimeout(function() { - done(err); - }, 100); - } - }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - failFn = jasmine.createSpy('fail'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2], - fail: failFn - }); + const err = 'anything except undefined'; + const queueableFn1 = { + fn: function(done) { + setTimeout(function() { + done(err); + }, 100); + } + }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + const failFn = jasmine.createSpy('fail'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2], + fail: failFn + }); queueRunner.execute(); @@ -181,23 +181,23 @@ describe('QueueRunner', function() { // except on a major release and with a deprecation warning in // advance. it('explicitly fails and moves to the next function', function(done) { - const err = new Error('foo'), - queueableFn1 = { - fn: function() { - return Promise.resolve(err); - } - }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - failFn = jasmine.createSpy('fail'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2], - fail: failFn, - onComplete: function() { - expect(failFn).toHaveBeenCalledWith(err); - expect(queueableFn2.fn).toHaveBeenCalled(); - done(); - } - }); + const err = new Error('foo'); + const queueableFn1 = { + fn: function() { + return Promise.resolve(err); + } + }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + const failFn = jasmine.createSpy('fail'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2], + fail: failFn, + onComplete: function() { + expect(failFn).toHaveBeenCalledWith(err); + expect(queueableFn2.fn).toHaveBeenCalled(); + done(); + } + }); queueRunner.execute(); }); @@ -206,19 +206,19 @@ describe('QueueRunner', function() { describe('and the argument is not an Error', function() { it('does not report a failure', function(done) { const queueableFn1 = { - fn: function() { - return Promise.resolve('not an error'); - } - }, - failFn = jasmine.createSpy('fail'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1], - fail: failFn, - onComplete: function() { - expect(failFn).not.toHaveBeenCalled(); - done(); - } - }); + fn: function() { + return Promise.resolve('not an error'); + } + }; + const failFn = jasmine.createSpy('fail'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1], + fail: failFn, + onComplete: function() { + expect(failFn).not.toHaveBeenCalled(); + done(); + } + }); queueRunner.execute(); }); @@ -227,20 +227,20 @@ describe('QueueRunner', function() { }); it('does not cause an explicit fail if execution is being stopped', function() { - const err = new privateUnderTest.StopExecutionError('foo'), - queueableFn1 = { - fn: function(done) { - setTimeout(function() { - done(err); - }, 100); - } - }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - failFn = jasmine.createSpy('fail'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2], - fail: failFn - }); + const err = new privateUnderTest.StopExecutionError('foo'); + const queueableFn1 = { + fn: function(done) { + setTimeout(function() { + done(err); + }, 100); + } + }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + const failFn = jasmine.createSpy('fail'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2], + fail: failFn + }); queueRunner.execute(); @@ -254,16 +254,20 @@ describe('QueueRunner', function() { }); it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() { - const timeout = 3, - beforeFn = { fn: function(done) {}, type: 'before', timeout: timeout }, - queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' }, - onComplete = jasmine.createSpy('onComplete'), - onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [beforeFn, queueableFn], - onComplete: onComplete, - onException: onException - }); + const timeout = 3; + const beforeFn = { + fn: function(done) {}, + type: 'before', + timeout: timeout + }; + const queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' }; + const onComplete = jasmine.createSpy('onComplete'); + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [beforeFn, queueableFn], + onComplete: onComplete, + onException: onException + }); queueRunner.execute(); expect(queueableFn.fn).not.toHaveBeenCalled(); @@ -302,15 +306,15 @@ describe('QueueRunner', function() { }); it('by default does not set a timeout for asynchronous functions', function() { - const beforeFn = { fn: function(done) {} }, - queueableFn = { fn: jasmine.createSpy('fn') }, - onComplete = jasmine.createSpy('onComplete'), - onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [beforeFn, queueableFn], - onComplete: onComplete, - onException: onException - }); + const beforeFn = { fn: function(done) {} }; + const queueableFn = { fn: jasmine.createSpy('fn') }; + const onComplete = jasmine.createSpy('onComplete'); + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [beforeFn, queueableFn], + onComplete: onComplete, + onException: onException + }); queueRunner.execute(); expect(queueableFn.fn).not.toHaveBeenCalled(); @@ -324,17 +328,17 @@ describe('QueueRunner', function() { it('clears the timeout when an async function throws an exception, to prevent additional exception reporting', function() { const queueableFn = { - fn: function(done) { - throw new Error('error!'); - } - }, - onComplete = jasmine.createSpy('onComplete'), - onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onComplete: onComplete, - onException: onException - }); + fn: function(done) { + throw new Error('error!'); + } + }; + const onComplete = jasmine.createSpy('onComplete'); + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn], + onComplete: onComplete, + onException: onException + }); queueRunner.execute(); @@ -347,17 +351,17 @@ describe('QueueRunner', function() { it('clears the timeout when the done callback is called', function() { const queueableFn = { - fn: function(done) { - done(); - } - }, - onComplete = jasmine.createSpy('onComplete'), - onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onComplete: onComplete, - onException: onException - }); + fn: function(done) { + done(); + } + }; + const onComplete = jasmine.createSpy('onComplete'); + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn], + onComplete: onComplete, + onException: onException + }); queueRunner.execute(); @@ -370,17 +374,17 @@ describe('QueueRunner', function() { it('only moves to the next spec the first time you call done', function() { const queueableFn = { - fn: function(done) { - done(); - done(); - } - }, - nextQueueableFn = { fn: jasmine.createSpy('nextFn') }, - onMultipleDone = jasmine.createSpy('onMultipleDone'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn], - onMultipleDone: onMultipleDone - }); + fn: function(done) { + done(); + done(); + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFn') }; + const onMultipleDone = jasmine.createSpy('onMultipleDone'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn], + onMultipleDone: onMultipleDone + }); queueRunner.execute(); jasmine.clock().tick(1); @@ -390,15 +394,15 @@ describe('QueueRunner', function() { it('does not move to the next spec if done is called after an exception has ended the spec', function() { const queueableFn = { - fn: function(done) { - setTimeout(done, 1); - throw new Error('error!'); - } - }, - nextQueueableFn = { fn: jasmine.createSpy('nextFn') }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn] - }); + fn: function(done) { + setTimeout(done, 1); + throw new Error('error!'); + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFn') }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn] + }); queueRunner.execute(); jasmine.clock().tick(1); expect(nextQueueableFn.fn.calls.count()).toEqual(1); @@ -422,28 +426,26 @@ describe('QueueRunner', function() { it('continues running functions when an exception is thrown in async code without timing out', function() { const queueableFn = { - fn: function(done) { - throwAsync(); - }, - timeout: 1 + fn: function(done) { + throwAsync(); }, - nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - onException = jasmine.createSpy('onException'), - globalErrors = { - pushListener: jasmine.createSpy('pushListener'), - popListener: jasmine.createSpy('popListener') - }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn], - onException: onException, - globalErrors: globalErrors - }), - throwAsync = function() { - globalErrors.pushListener.calls - .mostRecent() - .args[0](new Error('foo')); - jasmine.clock().tick(2); - }; + timeout: 1 + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }; + const onException = jasmine.createSpy('onException'); + const globalErrors = { + pushListener: jasmine.createSpy('pushListener'), + popListener: jasmine.createSpy('popListener') + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn], + onException: onException, + globalErrors: globalErrors + }); + const throwAsync = function() { + globalErrors.pushListener.calls.mostRecent().args[0](new Error('foo')); + jasmine.clock().tick(2); + }; nextQueueableFn.fn.and.callFake(function() { // should remove the same function that was added @@ -473,28 +475,28 @@ describe('QueueRunner', function() { it('handles exceptions thrown while waiting for the stack to clear', function() { const queueableFn = { - fn: function(done) { - done(); - } + fn: function(done) { + done(); + } + }; + const errorListeners = []; + const globalErrors = { + pushListener: function(f) { + errorListeners.push(f); }, - errorListeners = [], - globalErrors = { - pushListener: function(f) { - errorListeners.push(f); - }, - popListener: function() { - errorListeners.pop(); - } - }, - clearStack = jasmine.createSpyObj('clearStack', ['clearStack']), - onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - globalErrors: globalErrors, - clearStack: clearStack, - onException: onException - }), - error = new Error('nope'); + popListener: function() { + errorListeners.pop(); + } + }; + const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']); + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn], + globalErrors: globalErrors, + clearStack: clearStack, + onException: onException + }); + const error = new Error('nope'); queueRunner.execute(); jasmine.clock().tick(); @@ -523,31 +525,31 @@ describe('QueueRunner', function() { }); it('runs the function asynchronously, advancing once the promise is settled', function() { - const onComplete = jasmine.createSpy('onComplete'), - fnCallback = jasmine.createSpy('fnCallback'), - p1 = new StubPromise(), - p2 = new StubPromise(), - queueableFn1 = { - fn: function() { - setTimeout(function() { - p1.resolveHandler(); - }, 100); - return p1; - } - }, - queueableFn2 = { - fn: function() { - fnCallback(); - setTimeout(function() { - p2.resolveHandler(); - }, 100); - return p2; - } - }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2], - onComplete: onComplete - }); + const onComplete = jasmine.createSpy('onComplete'); + const fnCallback = jasmine.createSpy('fnCallback'); + const p1 = new StubPromise(); + const p2 = new StubPromise(); + const queueableFn1 = { + fn: function() { + setTimeout(function() { + p1.resolveHandler(); + }, 100); + return p1; + } + }; + const queueableFn2 = { + fn: function() { + fnCallback(); + setTimeout(function() { + p2.resolveHandler(); + }, 100); + return p2; + } + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2], + onComplete: onComplete + }); queueRunner.execute(); expect(fnCallback).not.toHaveBeenCalled(); @@ -564,21 +566,21 @@ describe('QueueRunner', function() { }); it('handles a rejected promise like an unhandled exception', function() { - const promise = new StubPromise(), - queueableFn1 = { - fn: function() { - setTimeout(function() { - promise.rejectHandler('foo'); - }, 100); - return promise; - } - }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - onExceptionCallback = jasmine.createSpy('on exception callback'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn1, queueableFn2], - onException: onExceptionCallback - }); + const promise = new StubPromise(); + const queueableFn1 = { + fn: function() { + setTimeout(function() { + promise.rejectHandler('foo'); + }, 100); + return promise; + } + }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + const onExceptionCallback = jasmine.createSpy('on exception callback'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn1, queueableFn2], + onException: onExceptionCallback + }); queueRunner.execute(); @@ -593,15 +595,15 @@ describe('QueueRunner', function() { it('issues an error if the function also takes a parameter', function() { const queueableFn = { - fn: function(done) { - return new StubPromise(); - } - }, - onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onException: onException - }); + fn: function(done) { + return new StubPromise(); + } + }; + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn], + onException: onException + }); queueRunner.execute(); @@ -618,11 +620,11 @@ describe('QueueRunner', function() { it('issues a more specific error if the function is `async`', function() { async function fn(done) {} - const onException = jasmine.createSpy('onException'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [{ fn: fn }], - onException: onException - }); + const onException = jasmine.createSpy('onException'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [{ fn: fn }], + onException: onException + }); queueRunner.execute(); @@ -638,11 +640,11 @@ describe('QueueRunner', function() { }); it('passes final errors to exception handlers', function() { - const error = new Error('fake error'), - onExceptionCallback = jasmine.createSpy('on exception callback'), - queueRunner = new privateUnderTest.QueueRunner({ - onException: onExceptionCallback - }); + const error = new Error('fake error'); + const onExceptionCallback = jasmine.createSpy('on exception callback'); + const queueRunner = new privateUnderTest.QueueRunner({ + onException: onExceptionCallback + }); queueRunner.execute(); queueRunner.handleFinalError(error); @@ -652,16 +654,16 @@ describe('QueueRunner', function() { it('calls exception handlers when an exception is thrown in a fn', function() { const queueableFn = { - type: 'queueable', - fn: function() { - throw new Error('fake error'); - } - }, - onExceptionCallback = jasmine.createSpy('on exception callback'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onException: onExceptionCallback - }); + type: 'queueable', + fn: function() { + throw new Error('fake error'); + } + }; + const onExceptionCallback = jasmine.createSpy('on exception callback'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn], + onException: onExceptionCallback + }); queueRunner.execute(); @@ -670,14 +672,14 @@ describe('QueueRunner', function() { it('continues running the functions even after an exception is thrown in an async spec', function() { const queueableFn = { - fn: function(done) { - throw new Error('error'); - } - }, - nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn] - }); + fn: function(done) { + throw new Error('error'); + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn] + }); queueRunner.execute(); expect(nextQueueableFn.fn).toHaveBeenCalled(); @@ -747,21 +749,21 @@ describe('QueueRunner', function() { describe('When configured to complete on first error', function() { it('skips to cleanup functions on the first exception', function() { const queueableFn = { - fn: function() { - throw new Error('error'); - } - }, - nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - cleanupFn = { - fn: jasmine.createSpy('cleanup'), - type: 'specCleanup' - }, - onComplete = jasmine.createSpy('onComplete'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - onComplete: onComplete, - SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy - }); + fn: function() { + throw new Error('error'); + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }; + const cleanupFn = { + fn: jasmine.createSpy('cleanup'), + type: 'specCleanup' + }; + const onComplete = jasmine.createSpy('onComplete'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn, cleanupFn], + onComplete: onComplete, + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy + }); queueRunner.execute(); expect(nextQueueableFn.fn).not.toHaveBeenCalled(); @@ -772,21 +774,21 @@ describe('QueueRunner', function() { }); it('does not skip when a cleanup function throws', function() { - const queueableFn = { fn: function() {} }, - cleanupFn1 = { - fn: function() { - throw new Error('error'); - }, - type: 'afterEach' + const queueableFn = { fn: function() {} }; + const cleanupFn1 = { + fn: function() { + throw new Error('error'); }, - cleanupFn2 = { - fn: jasmine.createSpy('cleanupFn2'), - type: 'afterEach' - }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, cleanupFn1, cleanupFn2], - SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy - }); + type: 'afterEach' + }; + const cleanupFn2 = { + fn: jasmine.createSpy('cleanupFn2'), + type: 'afterEach' + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, cleanupFn1, cleanupFn2], + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy + }); queueRunner.execute(); expect(cleanupFn2.fn).toHaveBeenCalled(); @@ -837,16 +839,19 @@ describe('QueueRunner', function() { it('skips to cleanup functions when next.fail is called', function() { const queueableFn = { - fn: function(done) { - done.fail('nope'); - } - }, - nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy - }); + fn: function(done) { + done.fail('nope'); + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }; + const cleanupFn = { + fn: jasmine.createSpy('cleanup'), + type: 'specCleanup' + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn, cleanupFn], + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy + }); queueRunner.execute(); jasmine.clock().tick(); @@ -856,19 +861,19 @@ describe('QueueRunner', function() { it('skips to cleanup functions when next is called with an Error', function() { const queueableFn = { - fn: function(done) { - done(new Error('nope')); - } - }, - nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - cleanupFn = { - fn: jasmine.createSpy('cleanup'), - type: 'specCleanup' - }, - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy - }); + fn: function(done) { + done(new Error('nope')); + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }; + const cleanupFn = { + fn: jasmine.createSpy('cleanup'), + type: 'specCleanup' + }; + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn, nextQueueableFn, cleanupFn], + SkipPolicy: privateUnderTest.CompleteOnFirstErrorSkipPolicy + }); queueRunner.execute(); jasmine.clock().tick(); @@ -879,12 +884,12 @@ describe('QueueRunner', function() { }); it('calls a provided complete callback when done', function() { - const queueableFn = { fn: jasmine.createSpy('fn') }, - completeCallback = jasmine.createSpy('completeCallback'), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onComplete: completeCallback - }); + const queueableFn = { fn: jasmine.createSpy('fn') }; + const completeCallback = jasmine.createSpy('completeCallback'); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [queueableFn], + onComplete: completeCallback + }); queueRunner.execute(); @@ -902,18 +907,18 @@ describe('QueueRunner', function() { it('calls a provided stack clearing function when done', function() { const asyncFn = { - fn: function(done) { - done(); - } - }, - afterFn = { fn: jasmine.createSpy('afterFn') }, - completeCallback = jasmine.createSpy('completeCallback'), - clearStack = jasmine.createSpyObj('clearStack', ['clearStack']), - queueRunner = new privateUnderTest.QueueRunner({ - queueableFns: [asyncFn, afterFn], - clearStack: clearStack, - onComplete: completeCallback - }); + fn: function(done) { + done(); + } + }; + const afterFn = { fn: jasmine.createSpy('afterFn') }; + const completeCallback = jasmine.createSpy('completeCallback'); + const clearStack = jasmine.createSpyObj('clearStack', ['clearStack']); + const queueRunner = new privateUnderTest.QueueRunner({ + queueableFns: [asyncFn, afterFn], + clearStack: clearStack, + onComplete: completeCallback + }); clearStack.clearStack.and.callFake(function(fn) { fn(); diff --git a/spec/core/ReportDispatcherSpec.js b/spec/core/ReportDispatcherSpec.js index 260aa28b..298794a1 100644 --- a/spec/core/ReportDispatcherSpec.js +++ b/spec/core/ReportDispatcherSpec.js @@ -12,13 +12,13 @@ describe('ReportDispatcher', function() { }); it('dispatches requested methods to added reporters', function() { - const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new privateUnderTest.ReportDispatcher( - ['foo', 'bar'], - runQueue - ), - reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']), - anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); + const runQueue = jasmine.createSpy('runQueue'); + const dispatcher = new privateUnderTest.ReportDispatcher( + ['foo', 'bar'], + runQueue + ); + const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); + const anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); dispatcher.addReporter(reporter); dispatcher.addReporter(anotherReporter); @@ -100,9 +100,9 @@ describe('ReportDispatcher', function() { }); it("does not dispatch to a reporter if the reporter doesn't accept the method", function() { - const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue), - reporter = jasmine.createSpyObj('reporter', ['baz']); + const runQueue = jasmine.createSpy('runQueue'); + const dispatcher = new privateUnderTest.ReportDispatcher(['foo'], runQueue); + const reporter = jasmine.createSpyObj('reporter', ['baz']); dispatcher.addReporter(reporter); @@ -115,12 +115,12 @@ describe('ReportDispatcher', function() { }); it("allows providing a fallback reporter in case there's no other reporter", function() { - const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new privateUnderTest.ReportDispatcher( - ['foo', 'bar'], - runQueue - ), - reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); + const runQueue = jasmine.createSpy('runQueue'); + const dispatcher = new privateUnderTest.ReportDispatcher( + ['foo', 'bar'], + runQueue + ); + const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); dispatcher.provideFallbackReporter(reporter); dispatcher.foo({ an: 'event' }); @@ -138,13 +138,16 @@ describe('ReportDispatcher', function() { }); it('does not call fallback reporting methods when another reporter is provided', function() { - const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new privateUnderTest.ReportDispatcher( - ['foo', 'bar'], - runQueue - ), - reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']), - fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']); + const runQueue = jasmine.createSpy('runQueue'); + const dispatcher = new privateUnderTest.ReportDispatcher( + ['foo', 'bar'], + runQueue + ); + const reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']); + const fallbackReporter = jasmine.createSpyObj('otherReporter', [ + 'foo', + 'bar' + ]); dispatcher.provideFallbackReporter(fallbackReporter); dispatcher.addReporter(reporter); @@ -164,13 +167,13 @@ describe('ReportDispatcher', function() { }); it('allows registered reporters to be cleared', function() { - const runQueue = jasmine.createSpy('runQueue'), - dispatcher = new privateUnderTest.ReportDispatcher( - ['foo', 'bar'], - runQueue - ), - reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']), - reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']); + const runQueue = jasmine.createSpy('runQueue'); + const dispatcher = new privateUnderTest.ReportDispatcher( + ['foo', 'bar'], + runQueue + ); + const reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']); + const reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']); dispatcher.addReporter(reporter1); dispatcher.foo({ an: 'event' }); diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 48b2ecef..bc2d5fa9 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -181,13 +181,13 @@ describe('Spec', function() { }); it('is "pending" if created without a function body', function() { - const startCallback = jasmine.createSpy('startCallback'), - resultCallback = jasmine.createSpy('resultCallback'), - spec = new privateUnderTest.Spec({ - onStart: startCallback, - queueableFn: { fn: null }, - resultCallback: resultCallback - }); + const startCallback = jasmine.createSpy('startCallback'); + const resultCallback = jasmine.createSpy('resultCallback'); + const spec = new privateUnderTest.Spec({ + onStart: startCallback, + queueableFn: { fn: null }, + resultCallback: resultCallback + }); expect(spec.status()) .withContext('status()') @@ -389,12 +389,12 @@ describe('Spec', function() { }); it('does not throw an ExpectationFailed error when handling an error', function() { - const resultCallback = jasmine.createSpy('resultCallback'), - spec = new privateUnderTest.Spec({ - queueableFn: { fn: function() {} }, - resultCallback: resultCallback, - throwOnExpectationFailure: true - }); + const resultCallback = jasmine.createSpy('resultCallback'); + const spec = new privateUnderTest.Spec({ + queueableFn: { fn: function() {} }, + resultCallback: resultCallback, + throwOnExpectationFailure: true + }); spec.handleException('failing exception'); }); diff --git a/spec/core/SpyRegistrySpec.js b/spec/core/SpyRegistrySpec.js index 1d5f772b..86c71239 100644 --- a/spec/core/SpyRegistrySpec.js +++ b/spec/core/SpyRegistrySpec.js @@ -14,8 +14,8 @@ describe('SpyRegistry', function() { }); it('checks that a method name was passed', function() { - const spyRegistry = new privateUnderTest.SpyRegistry(), - target = {}; + const spyRegistry = new privateUnderTest.SpyRegistry(); + const target = {}; expect(function() { spyRegistry.spyOn(target); @@ -30,8 +30,8 @@ describe('SpyRegistry', function() { }); it('checks that the method name is not `null`', function() { - const spyRegistry = new privateUnderTest.SpyRegistry(), - target = {}; + const spyRegistry = new privateUnderTest.SpyRegistry(); + const target = {}; expect(function() { spyRegistry.spyOn(target, null); @@ -39,8 +39,8 @@ describe('SpyRegistry', function() { }); it('checks for the existence of the method', function() { - const spyRegistry = new privateUnderTest.SpyRegistry(), - target = {}; + const spyRegistry = new privateUnderTest.SpyRegistry(); + const target = {}; expect(function() { spyRegistry.spyOn(target, 'pants'); @@ -48,14 +48,14 @@ describe('SpyRegistry', function() { }); it('checks if it has already been spied upon', function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - target = { spiedFunc: function() {} }; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const target = { spiedFunc: function() {} }; spyRegistry.spyOn(target, 'spiedFunc'); @@ -77,13 +77,13 @@ describe('SpyRegistry', function() { } }); - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - } - }), - target = { spiedFunc: scope.myFunc }; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + } + }); + const target = { spiedFunc: scope.myFunc }; expect(function() { spyRegistry.spyOn(scope, 'myFunc'); @@ -158,8 +158,8 @@ describe('SpyRegistry', function() { }); it('checks that a property name was passed', function() { - const spyRegistry = new privateUnderTest.SpyRegistry(), - target = {}; + const spyRegistry = new privateUnderTest.SpyRegistry(); + const target = {}; expect(function() { spyRegistry.spyOnProperty(target); @@ -167,8 +167,8 @@ describe('SpyRegistry', function() { }); it('checks for the existence of the method', function() { - const spyRegistry = new privateUnderTest.SpyRegistry(), - target = {}; + const spyRegistry = new privateUnderTest.SpyRegistry(); + const target = {}; expect(function() { spyRegistry.spyOnProperty(target, 'pants'); @@ -176,8 +176,8 @@ describe('SpyRegistry', function() { }); it('checks for the existence of access type', function() { - const spyRegistry = new privateUnderTest.SpyRegistry(), - target = {}; + const spyRegistry = new privateUnderTest.SpyRegistry(); + const target = {}; Object.defineProperty(target, 'pants', { get: function() { @@ -216,10 +216,10 @@ describe('SpyRegistry', function() { it('overrides the property getter on the object and returns the spy', function() { const spyRegistry = new privateUnderTest.SpyRegistry({ - createSpy: createSpy - }), - target = {}, - returnValue = 1; + createSpy: createSpy + }); + const target = {}; + const returnValue = 1; Object.defineProperty(target, 'spiedProperty', { get: function() { @@ -240,10 +240,10 @@ describe('SpyRegistry', function() { it('overrides the property setter on the object and returns the spy', function() { const spyRegistry = new privateUnderTest.SpyRegistry({ - createSpy: createSpy - }), - target = {}, - returnValue = 1; + createSpy: createSpy + }); + const target = {}; + const returnValue = 1; Object.defineProperty(target, 'spiedProperty', { get: function() { @@ -264,9 +264,9 @@ describe('SpyRegistry', function() { describe('when the property is already spied upon', function() { it('throws an error if respy is not allowed', function() { const spyRegistry = new privateUnderTest.SpyRegistry({ - createSpy: createSpy - }), - target = {}; + createSpy: createSpy + }); + const target = {}; Object.defineProperty(target, 'spiedProp', { get: function() { @@ -284,9 +284,9 @@ describe('SpyRegistry', function() { it('returns the original spy if respy is allowed', function() { const spyRegistry = new privateUnderTest.SpyRegistry({ - createSpy: createSpy - }), - target = {}; + createSpy: createSpy + }); + const target = {}; spyRegistry.allowRespy(true); @@ -564,15 +564,15 @@ describe('SpyRegistry', function() { describe('#clearSpies', function() { it('restores the original functions on the spied-upon objects', function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - originalFunction = function() {}, - target = { spiedFunc: originalFunction }; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const originalFunction = function() {}; + const target = { spiedFunc: originalFunction }; spyRegistry.spyOn(target, 'spiedFunc'); spyRegistry.clearSpies(); @@ -581,15 +581,15 @@ describe('SpyRegistry', function() { }); it('restores the original functions, even when that spy has been replace and re-spied upon', function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - originalFunction = function() {}, - target = { spiedFunc: originalFunction }; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const originalFunction = function() {}; + const target = { spiedFunc: originalFunction }; spyRegistry.spyOn(target, 'spiedFunc'); @@ -605,15 +605,15 @@ describe('SpyRegistry', function() { }); it("does not add a property that the spied-upon object didn't originally have", function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - originalFunction = function() {}, - targetParent = { spiedFunc: originalFunction }; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const originalFunction = function() {}; + const targetParent = { spiedFunc: originalFunction }; const target = Object.create(targetParent); @@ -627,15 +627,15 @@ describe('SpyRegistry', function() { }); it("restores the original function when it's inherited and cannot be deleted", function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - originalFunction = function() {}, - targetParent = { spiedFunc: originalFunction }; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const originalFunction = function() {}; + const targetParent = { spiedFunc: originalFunction }; const target = Object.create(targetParent); @@ -655,15 +655,15 @@ describe('SpyRegistry', function() { function FakeWindow() {} FakeWindow.prototype.onerror = function() {}; - const spies = [], - global = new FakeWindow(), - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy, - global: global - }); + const spies = []; + const global = new FakeWindow(); + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy, + global: global + }); spyRegistry.spyOn(global, 'onerror'); spyRegistry.clearSpies(); @@ -674,15 +674,15 @@ describe('SpyRegistry', function() { describe('spying on properties', function() { it('restores the original properties on the spied-upon objects', function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - originalReturn = 1, - target = {}; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const originalReturn = 1; + const target = {}; Object.defineProperty(target, 'spiedProp', { get: function() { @@ -698,15 +698,15 @@ describe('SpyRegistry', function() { }); it("does not add a property that the spied-upon object didn't originally have", function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy - }), - originalReturn = 1, - targetParent = {}; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy + }); + const originalReturn = 1; + const targetParent = {}; Object.defineProperty(targetParent, 'spiedProp', { get: function() { diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index 0280a658..8e556a71 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -106,8 +106,8 @@ describe('Spies', function() { ]; for (let arity = 0; arity < functions.length; arity++) { - const someFunction = functions[arity], - spy = env.createSpy(someFunction.name, someFunction); + const someFunction = functions[arity]; + const spy = env.createSpy(someFunction.name, someFunction); expect(spy.length).toEqual(arity); } diff --git a/spec/core/SpyStrategySpec.js b/spec/core/SpyStrategySpec.js index 57c35e9d..b5559ebd 100644 --- a/spec/core/SpyStrategySpec.js +++ b/spec/core/SpyStrategySpec.js @@ -12,8 +12,8 @@ describe('SpyStrategy', function() { }); it('stubs an original function, if provided', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.exec(); @@ -21,8 +21,8 @@ describe('SpyStrategy', function() { }); it("allows an original function to be called, passed through the params and returns it's value", function() { - const originalFn = jasmine.createSpy('original').and.returnValue(42), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original').and.returnValue(42); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callThrough(); const returnValue = spyStrategy.exec(null, ['foo']); @@ -33,8 +33,8 @@ describe('SpyStrategy', function() { }); it('can return a specified value when executed', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.returnValue(17); const returnValue = spyStrategy.exec(); @@ -44,8 +44,8 @@ describe('SpyStrategy', function() { }); it('can return specified values in order specified when executed', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.returnValues('value1', 'value2', 'value3'); @@ -57,8 +57,8 @@ describe('SpyStrategy', function() { }); it('allows an exception to be thrown when executed', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError(new TypeError('bar')); @@ -69,8 +69,8 @@ describe('SpyStrategy', function() { }); it('allows a string to be thrown, wrapping it into an exception when executed', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError('bar'); @@ -81,8 +81,8 @@ describe('SpyStrategy', function() { }); it('allows a non-Error to be thrown when executed', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError({ code: 'ESRCH' }); @@ -93,9 +93,9 @@ describe('SpyStrategy', function() { }); it('allows a fake function to be called instead', function() { - const originalFn = jasmine.createSpy('original'), - fakeFn = jasmine.createSpy('fake').and.returnValue(67), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const fakeFn = jasmine.createSpy('fake').and.returnValue(67); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); const returnValue = spyStrategy.exec(); @@ -105,11 +105,11 @@ describe('SpyStrategy', function() { }); it('allows a fake async function to be called instead', function(done) { - const originalFn = jasmine.createSpy('original'), - fakeFn = jasmine.createSpy('fake').and.callFake(async () => { - return 67; - }), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const fakeFn = jasmine.createSpy('fake').and.callFake(async () => { + return 67; + }); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); spyStrategy @@ -127,10 +127,10 @@ describe('SpyStrategy', function() { describe('#resolveTo', function() { it('allows a resolved promise to be returned', function(done) { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn - }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn + }); spyStrategy.resolveTo(37); spyStrategy @@ -143,10 +143,10 @@ describe('SpyStrategy', function() { }); it('allows an empty resolved promise to be returned', function(done) { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn - }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn + }); spyStrategy.resolveTo(); spyStrategy @@ -161,10 +161,10 @@ describe('SpyStrategy', function() { describe('#rejectWith', function() { it('allows a rejected promise to be returned', function(done) { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn - }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn + }); spyStrategy.rejectWith(new Error('oops')); spyStrategy @@ -178,10 +178,10 @@ describe('SpyStrategy', function() { }); it('allows an empty rejected promise to be returned', function(done) { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn - }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn + }); spyStrategy.rejectWith(); spyStrategy @@ -195,10 +195,10 @@ describe('SpyStrategy', function() { }); it('allows a non-Error to be rejected', function(done) { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn - }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn + }); spyStrategy.rejectWith('oops'); spyStrategy @@ -214,18 +214,18 @@ describe('SpyStrategy', function() { it('allows a custom strategy to be used', function() { const plan = jasmine - .createSpy('custom strategy') - .and.returnValue('custom strategy result'), - customStrategy = jasmine - .createSpy('custom strategy') - .and.returnValue(plan), - originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn, - customStrategies: { - doSomething: customStrategy - } - }); + .createSpy('custom strategy') + .and.returnValue('custom strategy result'); + const customStrategy = jasmine + .createSpy('custom strategy') + .and.returnValue(plan); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn, + customStrategies: { + doSomething: customStrategy + } + }); spyStrategy.doSomething(1, 2, 3); expect(customStrategy).toHaveBeenCalledWith(1, 2, 3); @@ -236,15 +236,15 @@ describe('SpyStrategy', function() { }); it("throws an error if a custom strategy doesn't return a function", function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ - fn: originalFn, - customStrategies: { - doSomething: function() { - return 'not a function'; - } + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ + fn: originalFn, + customStrategies: { + doSomething: function() { + return 'not a function'; } - }); + } + }); expect(function() { spyStrategy.doSomething(1, 2, 3); @@ -263,8 +263,8 @@ describe('SpyStrategy', function() { }); it('throws an error when a non-function is passed to callFake strategy', function() { - const originalFn = jasmine.createSpy('original'), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); expect(function() { spyStrategy.callFake('not a function'); @@ -275,9 +275,9 @@ describe('SpyStrategy', function() { it('allows generator functions to be passed to callFake strategy', function() { const generator = function*() { - yield 'ok'; - }, - spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} }); + yield 'ok'; + }; + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: function() {} }); spyStrategy.callFake(generator); @@ -285,9 +285,9 @@ describe('SpyStrategy', function() { }); it('allows a return to plan stubbing after another strategy', function() { - const originalFn = jasmine.createSpy('original'), - fakeFn = jasmine.createSpy('fake').and.returnValue(67), - spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); + const originalFn = jasmine.createSpy('original'); + const fakeFn = jasmine.createSpy('fake').and.returnValue(67); + const spyStrategy = new privateUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); let returnValue = spyStrategy.exec(); @@ -302,9 +302,9 @@ describe('SpyStrategy', function() { }); it('returns the spy after changing the strategy', function() { - const spy = {}, - spyFn = jasmine.createSpy('spyFn').and.returnValue(spy), - spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn }); + const spy = {}; + const spyFn = jasmine.createSpy('spyFn').and.returnValue(spy); + const spyStrategy = new privateUnderTest.SpyStrategy({ getSpy: spyFn }); expect(spyStrategy.callThrough()).toBe(spy); expect(spyStrategy.returnValue()).toBe(spy); diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index dc771bde..5738873a 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -30,26 +30,26 @@ describe('Suite', function() { it('returns its full name when it has parent suites', function() { const parentSuite = new privateUnderTest.Suite({ - env: env, - description: 'I am a parent suite', - parentSuite: jasmine.createSpy('pretend top level suite') - }), - suite = new privateUnderTest.Suite({ - env: env, - description: 'I am a suite', - parentSuite: parentSuite - }); + env: env, + description: 'I am a parent suite', + parentSuite: jasmine.createSpy('pretend top level suite') + }); + const suite = new privateUnderTest.Suite({ + env: env, + description: 'I am a suite', + parentSuite: parentSuite + }); expect(suite.getFullName()).toEqual('I am a parent suite I am a suite'); }); it('adds beforeEach functions in order of needed execution', function() { const suite = new privateUnderTest.Suite({ - env: env, - description: 'I am a suite' - }), - outerBefore = { fn: 'outerBeforeEach' }, - innerBefore = { fn: 'insideBeforeEach' }; + env: env, + description: 'I am a suite' + }); + const outerBefore = { fn: 'outerBeforeEach' }; + const innerBefore = { fn: 'insideBeforeEach' }; suite.beforeEach(outerBefore); suite.beforeEach(innerBefore); @@ -62,11 +62,11 @@ describe('Suite', function() { it('adds beforeAll functions in order of needed execution', function() { const suite = new privateUnderTest.Suite({ - env: env, - description: 'I am a suite' - }), - outerBefore = { fn: 'outerBeforeAll' }, - innerBefore = { fn: 'insideBeforeAll' }; + env: env, + description: 'I am a suite' + }); + const outerBefore = { fn: 'outerBeforeAll' }; + const innerBefore = { fn: 'insideBeforeAll' }; suite.beforeAll(outerBefore); suite.beforeAll(innerBefore); @@ -79,11 +79,11 @@ describe('Suite', function() { it('adds afterEach functions in order of needed execution', function() { const suite = new privateUnderTest.Suite({ - env: env, - description: 'I am a suite' - }), - outerAfter = { fn: 'outerAfterEach' }, - innerAfter = { fn: 'insideAfterEach' }; + env: env, + description: 'I am a suite' + }); + const outerAfter = { fn: 'outerAfterEach' }; + const innerAfter = { fn: 'insideAfterEach' }; suite.afterEach(outerAfter); suite.afterEach(innerAfter); @@ -96,11 +96,11 @@ describe('Suite', function() { it('adds afterAll functions in order of needed execution', function() { const suite = new privateUnderTest.Suite({ - env: env, - description: 'I am a suite' - }), - outerAfter = { fn: 'outerAfterAll' }, - innerAfter = { fn: 'insideAfterAl' }; + env: env, + description: 'I am a suite' + }); + const outerAfter = { fn: 'outerAfterAll' }; + const innerAfter = { fn: 'insideAfterAl' }; suite.afterAll(outerAfter); suite.afterAll(innerAfter); diff --git a/spec/core/TimerSpec.js b/spec/core/TimerSpec.js index 7d23d10a..e51bc8c1 100644 --- a/spec/core/TimerSpec.js +++ b/spec/core/TimerSpec.js @@ -1,7 +1,7 @@ describe('Timer', function() { it('reports the time elapsed', function() { - const fakeNow = jasmine.createSpy('fake Date.now'), - timer = new jasmineUnderTest.Timer({ now: fakeNow }); + const fakeNow = jasmine.createSpy('fake Date.now'); + const timer = new jasmineUnderTest.Timer({ now: fakeNow }); fakeNow.and.returnValue(100); timer.start(); diff --git a/spec/core/TreeProcessorSpec.js b/spec/core/TreeProcessorSpec.js index 8a750c9b..bf192568 100644 --- a/spec/core/TreeProcessorSpec.js +++ b/spec/core/TreeProcessorSpec.js @@ -1,6 +1,6 @@ describe('TreeProcessor', function() { - let nodeNumber = 0, - leafNumber = 0; + let nodeNumber = 0; + let leafNumber = 0; function Node(attrs) { attrs = attrs || {}; @@ -24,11 +24,11 @@ describe('TreeProcessor', function() { } it('processes a single leaf', function() { - const leaf = new Leaf(), - processor = new privateUnderTest.TreeProcessor({ - tree: leaf, - runnableIds: [leaf.id] - }); + const leaf = new Leaf(); + const processor = new privateUnderTest.TreeProcessor({ + tree: leaf, + runnableIds: [leaf.id] + }); const result = processor.processTree(); @@ -36,11 +36,11 @@ describe('TreeProcessor', function() { }); it('processes a single pending leaf', function() { - const leaf = new Leaf({ markedPending: true }), - processor = new privateUnderTest.TreeProcessor({ - tree: leaf, - runnableIds: [leaf.id] - }); + const leaf = new Leaf({ markedPending: true }); + const processor = new privateUnderTest.TreeProcessor({ + tree: leaf, + runnableIds: [leaf.id] + }); const result = processor.processTree(); @@ -48,11 +48,11 @@ describe('TreeProcessor', function() { }); it('processes a single non-specified leaf', function() { - const leaf = new Leaf(), - processor = new privateUnderTest.TreeProcessor({ - tree: leaf, - runnableIds: [] - }); + const leaf = new Leaf(); + const processor = new privateUnderTest.TreeProcessor({ + tree: leaf, + runnableIds: [] + }); const result = processor.processTree(); @@ -60,14 +60,14 @@ describe('TreeProcessor', function() { }); it('processes a single excluded leaf', function() { - const leaf = new Leaf(), - processor = new privateUnderTest.TreeProcessor({ - tree: leaf, - runnableIds: [leaf.id], - excludeNode: function() { - return true; - } - }); + const leaf = new Leaf(); + const processor = new privateUnderTest.TreeProcessor({ + tree: leaf, + runnableIds: [leaf.id], + excludeNode: function() { + return true; + } + }); const result = processor.processTree(); @@ -75,12 +75,12 @@ describe('TreeProcessor', function() { }); it('processes a tree with a single leaf with the root specified', function() { - const leaf = new Leaf(), - parent = new Node({ children: [leaf] }), - processor = new privateUnderTest.TreeProcessor({ - tree: parent, - runnableIds: [parent.id] - }); + const leaf = new Leaf(); + const parent = new Node({ children: [leaf] }); + const processor = new privateUnderTest.TreeProcessor({ + tree: parent, + runnableIds: [parent.id] + }); const result = processor.processTree(); @@ -90,12 +90,12 @@ describe('TreeProcessor', function() { }); it('processes a tree with a single pending leaf, with the root specified', function() { - const leaf = new Leaf({ markedPending: true }), - parent = new Node({ children: [leaf] }), - processor = new privateUnderTest.TreeProcessor({ - tree: parent, - runnableIds: [parent.id] - }); + const leaf = new Leaf({ markedPending: true }); + const parent = new Node({ children: [leaf] }); + const processor = new privateUnderTest.TreeProcessor({ + tree: parent, + runnableIds: [parent.id] + }); const result = processor.processTree(); @@ -139,24 +139,24 @@ describe('TreeProcessor', function() { }); it('processes a complicated tree with the root specified', function() { - const pendingLeaf = new Leaf({ markedPending: true }), - executableLeaf = new Leaf({ markedPending: false }), - parent = new Node({ children: [pendingLeaf, executableLeaf] }), - childless = new Node(), - childOfPending = new Leaf({ markedPending: true }), - pendingNode = new Node({ - markedPending: true, - children: [childOfPending] - }), - parentOfPendings = new Node({ - markedPending: false, - children: [childless, pendingNode] - }), - root = new Node({ children: [parent, parentOfPendings] }), - processor = new privateUnderTest.TreeProcessor({ - tree: root, - runnableIds: [root.id] - }); + const pendingLeaf = new Leaf({ markedPending: true }); + const executableLeaf = new Leaf({ markedPending: false }); + const parent = new Node({ children: [pendingLeaf, executableLeaf] }); + const childless = new Node(); + const childOfPending = new Leaf({ markedPending: true }); + const pendingNode = new Node({ + markedPending: true, + children: [childOfPending] + }); + const parentOfPendings = new Node({ + markedPending: false, + children: [childless, pendingNode] + }); + const root = new Node({ children: [parent, parentOfPendings] }); + const processor = new privateUnderTest.TreeProcessor({ + tree: root, + runnableIds: [root.id] + }); const result = processor.processTree(); diff --git a/spec/core/UserContextSpec.js b/spec/core/UserContextSpec.js index 71836550..3cabeb33 100644 --- a/spec/core/UserContextSpec.js +++ b/spec/core/UserContextSpec.js @@ -1,7 +1,7 @@ describe('UserContext', function() { it('Behaves just like an plain object', function() { - const context = new privateUnderTest.UserContext(), - properties = []; + const context = new privateUnderTest.UserContext(); + const properties = []; for (const prop in context) { if (obj.hasOwnProperty(prop)) { diff --git a/spec/core/UtilSpec.js b/spec/core/UtilSpec.js index 0ab7d919..c605fe7a 100644 --- a/spec/core/UtilSpec.js +++ b/spec/core/UtilSpec.js @@ -142,17 +142,17 @@ describe('util', function() { describe('getPropertyDescriptor', function() { it('get property descriptor from object', function() { - const obj = { prop: 1 }, - actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop'), - expected = Object.getOwnPropertyDescriptor(obj, 'prop'); + const obj = { prop: 1 }; + const actual = privateUnderTest.util.getPropertyDescriptor(obj, 'prop'); + const expected = Object.getOwnPropertyDescriptor(obj, 'prop'); expect(actual).toEqual(expected); }); it('get property descriptor from object property', function() { - const proto = { prop: 1 }, - actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop'), - expected = Object.getOwnPropertyDescriptor(proto, 'prop'); + const proto = { prop: 1 }; + const actual = privateUnderTest.util.getPropertyDescriptor(proto, 'prop'); + const expected = Object.getOwnPropertyDescriptor(proto, 'prop'); expect(actual).toEqual(expected); }); diff --git a/spec/core/asymmetric_equality/AnySpec.js b/spec/core/asymmetric_equality/AnySpec.js index d4382b60..a7dc144d 100644 --- a/spec/core/asymmetric_equality/AnySpec.js +++ b/spec/core/asymmetric_equality/AnySpec.js @@ -54,8 +54,8 @@ describe('Any', function() { }); it('matches another constructed object', function() { - const Thing = function() {}, - any = new privateUnderTest.Any(Thing); + const Thing = function() {}; + const any = new privateUnderTest.Any(Thing); expect(any.asymmetricMatch(new Thing())).toBe(true); }); diff --git a/spec/core/asymmetric_equality/ArrayContainingSpec.js b/spec/core/asymmetric_equality/ArrayContainingSpec.js index 2c5dccd9..00aadb88 100644 --- a/spec/core/asymmetric_equality/ArrayContainingSpec.js +++ b/spec/core/asymmetric_equality/ArrayContainingSpec.js @@ -42,9 +42,9 @@ describe('ArrayContaining', function() { }); it('jasmineToStrings itself', function() { - const sample = [], - matcher = new privateUnderTest.ArrayContaining(sample), - pp = jasmine.createSpy('pp').and.returnValue('sample'); + const sample = []; + const matcher = new privateUnderTest.ArrayContaining(sample); + const pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(matcher.jasmineToString(pp)).toEqual( '' diff --git a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js index 644f005d..ccd1780a 100644 --- a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +++ b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js @@ -32,9 +32,9 @@ describe('ArrayWithExactContents', function() { }); it('jasmineToStrings itself', function() { - const sample = [], - matcher = new privateUnderTest.ArrayWithExactContents(sample), - pp = jasmine.createSpy('pp').and.returnValue('sample'); + const sample = []; + const matcher = new privateUnderTest.ArrayWithExactContents(sample); + const pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(matcher.jasmineToString(pp)).toEqual( '' diff --git a/spec/core/asymmetric_equality/MapContainingSpec.js b/spec/core/asymmetric_equality/MapContainingSpec.js index c5cc0581..35bf6a7c 100644 --- a/spec/core/asymmetric_equality/MapContainingSpec.js +++ b/spec/core/asymmetric_equality/MapContainingSpec.js @@ -151,9 +151,9 @@ describe('MapContaining', function() { }); it('defines a `jasmineToString` method', function() { - const sample = new Map(), - containing = new privateUnderTest.MapContaining(sample), - pp = jasmine.createSpy('pp').and.returnValue('sample'); + const sample = new Map(); + const containing = new privateUnderTest.MapContaining(sample); + const pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(containing.jasmineToString(pp)).toEqual( '' diff --git a/spec/core/asymmetric_equality/ObjectContainingSpec.js b/spec/core/asymmetric_equality/ObjectContainingSpec.js index 70327473..192161b7 100644 --- a/spec/core/asymmetric_equality/ObjectContainingSpec.js +++ b/spec/core/asymmetric_equality/ObjectContainingSpec.js @@ -53,9 +53,9 @@ describe('ObjectContaining', function() { }); it("jasmineToString's itself", function() { - const sample = {}, - matcher = new privateUnderTest.ObjectContaining(sample), - pp = jasmine.createSpy('pp').and.returnValue('sample'); + const sample = {}; + const matcher = new privateUnderTest.ObjectContaining(sample); + const pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(matcher.jasmineToString(pp)).toEqual( '' @@ -144,9 +144,9 @@ describe('ObjectContaining', function() { describe('valuesForDiff_', function() { describe('when other is not an object', function() { it('sets self to jasmineToString()', function() { - const containing = new privateUnderTest.ObjectContaining({}), - pp = privateUnderTest.makePrettyPrinter(), - result = containing.valuesForDiff_('a', pp); + const containing = new privateUnderTest.ObjectContaining({}); + const pp = privateUnderTest.makePrettyPrinter(); + const result = containing.valuesForDiff_('a', pp); expect(result).toEqual({ self: '', @@ -157,10 +157,10 @@ describe('ObjectContaining', function() { describe('when other is an object', function() { it('includes keys that are present in both other and sample', function() { - const sample = { a: 1, b: 2 }, - other = { a: 3, b: 4 }, - containing = new privateUnderTest.ObjectContaining(sample), - result = containing.valuesForDiff_(other); + const sample = { a: 1, b: 2 }; + const other = { a: 3, b: 4 }; + const containing = new privateUnderTest.ObjectContaining(sample); + const result = containing.valuesForDiff_(other); expect(result.self).not.toBeInstanceOf( privateUnderTest.ObjectContaining @@ -172,10 +172,10 @@ describe('ObjectContaining', function() { }); it('includes keys that are present only in sample', function() { - const sample = { a: 1, b: 2 }, - other = { a: 3 }, - containing = new privateUnderTest.ObjectContaining(sample), - result = containing.valuesForDiff_(other); + const sample = { a: 1, b: 2 }; + const other = { a: 3 }; + const containing = new privateUnderTest.ObjectContaining(sample); + const result = containing.valuesForDiff_(other); expect(result.self).not.toBeInstanceOf( privateUnderTest.ObjectContaining @@ -190,10 +190,10 @@ describe('ObjectContaining', function() { }); it('omits keys that are present only in other', function() { - const sample = { a: 1, b: 2 }, - other = { a: 3, b: 4, c: 5 }, - containing = new privateUnderTest.ObjectContaining(sample), - result = containing.valuesForDiff_(other); + const sample = { a: 1, b: 2 }; + const other = { a: 3, b: 4, c: 5 }; + const containing = new privateUnderTest.ObjectContaining(sample); + const result = containing.valuesForDiff_(other); expect(result.self).not.toBeInstanceOf( privateUnderTest.ObjectContaining diff --git a/spec/core/asymmetric_equality/SetContainingSpec.js b/spec/core/asymmetric_equality/SetContainingSpec.js index 6e48acfa..911922dc 100644 --- a/spec/core/asymmetric_equality/SetContainingSpec.js +++ b/spec/core/asymmetric_equality/SetContainingSpec.js @@ -103,9 +103,9 @@ describe('SetContaining', function() { }); it('defines a `jasmineToString` method', function() { - const sample = new Set(), - containing = new privateUnderTest.SetContaining(sample), - pp = jasmine.createSpy('pp').and.returnValue('sample'); + const sample = new Set(); + const containing = new privateUnderTest.SetContaining(sample); + const pp = jasmine.createSpy('pp').and.returnValue('sample'); expect(containing.jasmineToString(pp)).toEqual( '' diff --git a/spec/core/baseSpec.js b/spec/core/baseSpec.js index 788ae76e..47fe7d84 100644 --- a/spec/core/baseSpec.js +++ b/spec/core/baseSpec.js @@ -145,8 +145,8 @@ describe('base helpers', function() { }); it('is consistent with setTimeout in this environment', function(done) { - const f1 = jasmine.createSpy('setTimeout callback for ' + max), - f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1)); + const f1 = jasmine.createSpy('setTimeout callback for ' + max); + const f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1)); // Suppress printing of TimeoutOverflowWarning in node if (typeof process !== 'undefined' && process.emitWarning) { diff --git a/spec/core/integration/CustomAsyncMatchersSpec.js b/spec/core/integration/CustomAsyncMatchersSpec.js index 3b930e41..55df7811 100644 --- a/spec/core/integration/CustomAsyncMatchersSpec.js +++ b/spec/core/integration/CustomAsyncMatchersSpec.js @@ -86,16 +86,16 @@ describe('Custom Async Matchers (Integration)', function() { it('passes the jasmine utility to the matcher factory', async function() { const matcherFactory = function() { - return { - compare: function() { - return Promise.resolve({ pass: true }); - } - }; - }, - matcherFactorySpy = jasmine.createSpy( - 'matcherFactorySpy', - matcherFactory - ); + return { + compare: function() { + return Promise.resolve({ pass: true }); + } + }; + }; + const matcherFactorySpy = jasmine.createSpy( + 'matcherFactorySpy', + matcherFactory + ); env.it('spec with expectation', function() { env.addAsyncMatchers({ @@ -117,19 +117,19 @@ describe('Custom Async Matchers (Integration)', function() { it('provides custom equality testers to the matcher factory via matchersUtil', async function() { const matcherFactory = function(matchersUtil) { - return { - compare: function(actual, expected) { - return Promise.resolve({ - pass: matchersUtil.equals(actual[0], expected) - }); - } - }; - }, - customEqualityFn = jasmine - .createSpy('customEqualityFn') - .and.callFake(function(a, b) { - return a.toString() === b; - }); + return { + compare: function(actual, expected) { + return Promise.resolve({ + pass: matchersUtil.equals(actual[0], expected) + }); + } + }; + }; + const customEqualityFn = jasmine + .createSpy('customEqualityFn') + .and.callFake(function(a, b) { + return a.toString() === b; + }); env.it('spec with expectation', function() { env.addCustomEqualityTester(customEqualityFn); diff --git a/spec/core/integration/CustomMatchersSpec.js b/spec/core/integration/CustomMatchersSpec.js index 081b245b..6f6dbe2b 100644 --- a/spec/core/integration/CustomMatchersSpec.js +++ b/spec/core/integration/CustomMatchersSpec.js @@ -210,15 +210,15 @@ describe('Custom Matchers (Integration)', function() { it('passes the jasmine utility to the matcher factory', async function() { const matcherFactory = function() { - return { - compare: function() { - return { pass: true }; - } - }; - }, - matcherFactorySpy = jasmine - .createSpy('matcherFactorySpy') - .and.callFake(matcherFactory); + return { + compare: function() { + return { pass: true }; + } + }; + }; + const matcherFactorySpy = jasmine + .createSpy('matcherFactorySpy') + .and.callFake(matcherFactory); env.it('spec with expectation', function() { env.addMatchers({ @@ -236,17 +236,17 @@ describe('Custom Matchers (Integration)', function() { it('provides custom equality testers to the matcher factory via matchersUtil', async function() { const matcherFactory = function(matchersUtil) { - return { - compare: function(actual, expected) { - return { pass: matchersUtil.equals(actual[0], expected) }; - } - }; - }, - customEqualityFn = jasmine - .createSpy('customEqualityFn') - .and.callFake(function(a, b) { - return a.toString() === b; - }); + return { + compare: function(actual, expected) { + return { pass: matchersUtil.equals(actual[0], expected) }; + } + }; + }; + const customEqualityFn = jasmine + .createSpy('customEqualityFn') + .and.callFake(function(a, b) { + return a.toString() === b; + }); env.it('spec with expectation', function() { env.addCustomEqualityTester(customEqualityFn); diff --git a/spec/core/integration/CustomSpyStrategiesSpec.js b/spec/core/integration/CustomSpyStrategiesSpec.js index 66422116..f46dcd49 100644 --- a/spec/core/integration/CustomSpyStrategiesSpec.js +++ b/spec/core/integration/CustomSpyStrategiesSpec.js @@ -82,11 +82,11 @@ describe('Custom Spy Strategies (Integration)', function() { }); it('allows multiple custom strategies to be used', async function() { - const plan1 = jasmine.createSpy('plan 1').and.returnValue(42), - strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1), - plan2 = jasmine.createSpy('plan 2').and.returnValue(24), - strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2), - specDone = jasmine.createSpy('specDone'); + const plan1 = jasmine.createSpy('plan 1').and.returnValue(42); + const strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1); + const plan2 = jasmine.createSpy('plan 2').and.returnValue(24); + const strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2); + const specDone = jasmine.createSpy('specDone'); env.beforeEach(function() { env.addSpyStrategy('frobnicate', strategy1); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index c1886772..8689c3cf 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -246,8 +246,8 @@ describe('Env integration', function() { }); it('calls associated beforeAlls/afterAlls only once per suite', async function() { - const before = jasmine.createSpy('beforeAll'), - after = jasmine.createSpy('afterAll'); + const before = jasmine.createSpy('beforeAll'); + const after = jasmine.createSpy('afterAll'); env.describe('with beforeAll and afterAll', function() { env.it('spec', function() { @@ -272,8 +272,8 @@ describe('Env integration', function() { }); it('calls associated beforeAlls/afterAlls only once per suite for async', async function() { - const before = jasmine.createSpy('beforeAll'), - after = jasmine.createSpy('afterAll'); + const before = jasmine.createSpy('beforeAll'); + const after = jasmine.createSpy('afterAll'); env.describe('with beforeAll and afterAll', function() { env.it('spec', function() { @@ -675,8 +675,8 @@ describe('Env integration', function() { }); it('reports when afterAll throws an exception', async function() { - const error = new Error('After All Exception'), - reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); + const error = new Error('After All Exception'); + const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); env.addReporter(reporter); @@ -719,8 +719,8 @@ describe('Env integration', function() { }); it('reports when an async afterAll throws an exception', async function() { - const error = new Error('After All Exception'), - reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); + const error = new Error('After All Exception'); + const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); env.addReporter(reporter); @@ -838,8 +838,8 @@ describe('Env integration', function() { }); it('Allows specifying which specs and suites to run', async function() { - const calls = [], - suiteCallback = jasmine.createSpy('suite callback'); + const calls = []; + const suiteCallback = jasmine.createSpy('suite callback'); let firstSpec; let secondSuite; @@ -892,8 +892,8 @@ describe('Env integration', function() { }); it('Allows filtering out specs and suites to run programmatically', async function() { - const calls = [], - suiteCallback = jasmine.createSpy('suite callback'); + const calls = []; + const suiteCallback = jasmine.createSpy('suite callback'); env.addReporter({ suiteDone: suiteCallback }); @@ -1026,16 +1026,16 @@ describe('Env integration', function() { }); it('removes all spies added in a spec after the spec is complete', async function() { - const originalFoo = function() {}, - testObj = { - foo: originalFoo - }, - firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() { - env.spyOn(testObj, 'foo'); - }), - secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() { - expect(testObj.foo).toBe(originalFoo); - }); + const originalFoo = function() {}; + const testObj = { + foo: originalFoo + }; + const firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() { + env.spyOn(testObj, 'foo'); + }); + const secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() { + expect(testObj.foo).toBe(originalFoo); + }); env.describe('test suite', function() { env.it('spec 0', firstSpec); env.it('spec 1', secondSpec); @@ -1049,10 +1049,10 @@ describe('Env integration', function() { }); it('removes all spies added in a suite after the suite is complete', async function() { - const originalFoo = function() {}, - testObj = { - foo: originalFoo - }; + const originalFoo = function() {}; + const testObj = { + foo: originalFoo + }; env.describe('test suite', function() { env.beforeAll(function() { @@ -1078,10 +1078,10 @@ describe('Env integration', function() { }); it('removes a spy from the top suite after the run is complete', async function() { - const originalFoo = function() {}, - testObj = { - foo: originalFoo - }; + const originalFoo = function() {}; + const testObj = { + foo: originalFoo + }; env.beforeAll(function() { env.spyOn(testObj, 'foo'); @@ -1098,16 +1098,16 @@ describe('Env integration', function() { it('Mock clock can be installed and used in tests', async function() { const globalSetTimeout = jasmine - .createSpy('globalSetTimeout') - .and.callFake(function(cb, t) { - return setTimeout(cb, t); - }), - delayedFunctionForGlobalClock = jasmine.createSpy( - 'delayedFunctionForGlobalClock' - ), - delayedFunctionForMockClock = jasmine.createSpy( - 'delayedFunctionForMockClock' - ); + .createSpy('globalSetTimeout') + .and.callFake(function(cb, t) { + return setTimeout(cb, t); + }); + const delayedFunctionForGlobalClock = jasmine.createSpy( + 'delayedFunctionForGlobalClock' + ); + const delayedFunctionForMockClock = jasmine.createSpy( + 'delayedFunctionForMockClock' + ); env.cleanup_(); env = new privateUnderTest.Env({ @@ -1255,8 +1255,8 @@ describe('Env integration', function() { it('should not use the mock clock for asynchronous timeouts', async function() { createMockedEnv(); - const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']), - clock = env.clock; + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const clock = env.clock; reporter.specDone.and.callFake(function() { realSetTimeout(function() { @@ -2121,8 +2121,8 @@ describe('Env integration', function() { await env.execute(); - const firstSpecResult = reporter.specDone.calls.first().args[0], - secondSpecResult = reporter.specDone.calls.mostRecent().args[0]; + const firstSpecResult = reporter.specDone.calls.first().args[0]; + const secondSpecResult = reporter.specDone.calls.mostRecent().args[0]; expect(firstSpecResult.status).toEqual('passed'); expect(secondSpecResult.status).toEqual('failed'); @@ -2158,9 +2158,9 @@ describe('Env integration', function() { await env.execute(); - const firstSpecResult = reporter.specDone.calls.first().args[0], - secondSpecResult = reporter.specDone.calls.argsFor(0)[0], - thirdSpecResult = reporter.specDone.calls.mostRecent().args[0]; + const firstSpecResult = reporter.specDone.calls.first().args[0]; + const secondSpecResult = reporter.specDone.calls.argsFor(0)[0]; + const thirdSpecResult = reporter.specDone.calls.mostRecent().args[0]; expect(firstSpecResult.status).toEqual('passed'); expect(secondSpecResult.status).toEqual('passed'); @@ -2188,8 +2188,8 @@ describe('Env integration', function() { await env.execute(); - const firstSpecResult = reporter.specDone.calls.first().args[0], - secondSpecResult = reporter.specDone.calls.mostRecent().args[0]; + const firstSpecResult = reporter.specDone.calls.first().args[0]; + const secondSpecResult = reporter.specDone.calls.mostRecent().args[0]; expect(firstSpecResult.status).toEqual('passed'); expect(secondSpecResult.status).toEqual('failed'); @@ -2240,9 +2240,9 @@ describe('Env integration', function() { await env.execute(); - const firstSpecResult = reporter.specDone.calls.first().args[0], - secondSpecResult = reporter.specDone.calls.argsFor(1)[0], - thirdSpecResult = reporter.specDone.calls.mostRecent().args[0]; + const firstSpecResult = reporter.specDone.calls.first().args[0]; + const secondSpecResult = reporter.specDone.calls.argsFor(1)[0]; + const thirdSpecResult = reporter.specDone.calls.mostRecent().args[0]; expect(firstSpecResult.status).toEqual('passed'); expect(secondSpecResult.status).toEqual('passed'); @@ -2410,8 +2410,11 @@ describe('Env integration', function() { }); it('reports test properties on specs', async function() { - const env = new privateUnderTest.Env(), - reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']); + const env = new privateUnderTest.Env(); + const reporter = jasmine.createSpyObj('reporter', [ + 'suiteDone', + 'specDone' + ]); reporter.specDone.and.callFake(function(e) { expect(e.properties).toEqual({ @@ -2464,12 +2467,12 @@ describe('Env integration', function() { }); it('reports test properties on suites', async function() { - const env = new privateUnderTest.Env(), - reporter = jasmine.createSpyObj('reporter', [ - 'jasmineDone', - 'suiteDone', - 'specDone' - ]); + const env = new privateUnderTest.Env(); + const reporter = jasmine.createSpyObj('reporter', [ + 'jasmineDone', + 'suiteDone', + 'specDone' + ]); reporter.suiteDone.and.callFake(function(e) { expect(e.properties).toEqual({ b: 'Sweet' }); @@ -2937,15 +2940,15 @@ describe('Env integration', function() { }); it('should report deprecation stack with an error object', async function() { - const exceptionFormatter = new privateUnderTest.ExceptionFormatter(), - reporter = jasmine.createSpyObj('reporter', [ - 'jasmineDone', - 'suiteDone', - 'specDone' - ]), - topLevelError = new Error('top level deprecation'), - suiteLevelError = new Error('suite level deprecation'), - specLevelError = new Error('spec level deprecation'); + const exceptionFormatter = new privateUnderTest.ExceptionFormatter(); + const reporter = jasmine.createSpyObj('reporter', [ + 'jasmineDone', + 'suiteDone', + 'specDone' + ]); + const topLevelError = new Error('top level deprecation'); + const suiteLevelError = new Error('suite level deprecation'); + const specLevelError = new Error('spec level deprecation'); // prevent deprecation from being displayed spyOn(console, 'error'); @@ -3004,9 +3007,9 @@ describe('Env integration', function() { }); it('supports async matchers', async function() { - const specDone = jasmine.createSpy('specDone'), - suiteDone = jasmine.createSpy('suiteDone'), - jasmineDone = jasmine.createSpy('jasmineDone'); + const specDone = jasmine.createSpy('specDone'); + const suiteDone = jasmine.createSpy('suiteDone'); + const jasmineDone = jasmine.createSpy('jasmineDone'); env.addReporter({ specDone: specDone, diff --git a/spec/core/integration/MatchersSpec.js b/spec/core/integration/MatchersSpec.js index f1987b69..f49d35f5 100755 --- a/spec/core/integration/MatchersSpec.js +++ b/spec/core/integration/MatchersSpec.js @@ -560,16 +560,16 @@ describe('Matchers (Integration)', function() { describe('toHaveBeenCalledBefore', function() { verifyPasses(function(env) { - const a = env.createSpy('a'), - b = env.createSpy('b'); + const a = env.createSpy('a'); + const b = env.createSpy('b'); a(); b(); env.expect(a).toHaveBeenCalledBefore(b); }); verifyFails(function(env) { - const a = env.createSpy('a'), - b = env.createSpy('b'); + const a = env.createSpy('a'); + const b = env.createSpy('b'); b(); a(); env.expect(a).toHaveBeenCalledBefore(b); diff --git a/spec/core/integration/SpecRunningSpec.js b/spec/core/integration/SpecRunningSpec.js index 355d0407..e0b9c54b 100644 --- a/spec/core/integration/SpecRunningSpec.js +++ b/spec/core/integration/SpecRunningSpec.js @@ -517,8 +517,8 @@ describe('spec running', function() { }); it('should allow top level suites to be disabled', async function() { - const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'), - otherSpec = jasmine.createSpy('otherSpec'); + const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'); + const otherSpec = jasmine.createSpy('otherSpec'); env.xdescribe('A disabled suite', function() { env.it('spec inside a disabled suite', specInADisabledSuite); @@ -551,8 +551,8 @@ describe('spec running', function() { }); it('should recover gracefully when there are errors in describe functions', async function() { - const specs = [], - reporter = jasmine.createSpyObj(['specDone', 'suiteDone']); + const specs = []; + const reporter = jasmine.createSpyObj(['specDone', 'suiteDone']); reporter.specDone.and.callFake(function(result) { specs.push(result.fullName); diff --git a/spec/core/matchers/DiffBuilderSpec.js b/spec/core/matchers/DiffBuilderSpec.js index f5bf1fa5..03f21fcb 100644 --- a/spec/core/matchers/DiffBuilderSpec.js +++ b/spec/core/matchers/DiffBuilderSpec.js @@ -66,11 +66,11 @@ describe('DiffBuilder', function() { it('uses the injected pretty-printer', function() { const prettyPrinter = function(val) { - return '|' + val + '|'; - }, - diffBuilder = new privateUnderTest.DiffBuilder({ - prettyPrinter: prettyPrinter - }); + return '|' + val + '|'; + }; + const diffBuilder = new privateUnderTest.DiffBuilder({ + prettyPrinter: prettyPrinter + }); prettyPrinter.customFormat_ = function() {}; diffBuilder.setRoots({ foo: 'actual' }, { foo: 'expected' }); @@ -84,11 +84,11 @@ describe('DiffBuilder', function() { }); it('passes the injected pretty-printer to the diff formatter', function() { - const diffFormatter = jasmine.createSpy('diffFormatter'), - prettyPrinter = function() {}, - diffBuilder = new privateUnderTest.DiffBuilder({ - prettyPrinter: prettyPrinter - }); + const diffFormatter = jasmine.createSpy('diffFormatter'); + const prettyPrinter = function() {}; + const diffBuilder = new privateUnderTest.DiffBuilder({ + prettyPrinter: prettyPrinter + }); prettyPrinter.customFormat_ = function() {}; diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' }); @@ -219,13 +219,13 @@ describe('DiffBuilder', function() { }); it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() { - const prettyPrinter = privateUnderTest.makePrettyPrinter([]), - diffBuilder = new privateUnderTest.DiffBuilder({ - prettyPrinter: prettyPrinter - }), - expectedMsg = - 'Expected $.foo = 1 to equal 2.\n' + - 'Expected $.baz = undefined to equal 3.'; + const prettyPrinter = privateUnderTest.makePrettyPrinter([]); + const diffBuilder = new privateUnderTest.DiffBuilder({ + prettyPrinter: prettyPrinter + }); + const expectedMsg = + 'Expected $.foo = 1 to equal 2.\n' + + 'Expected $.baz = undefined to equal 3.'; diffBuilder.setRoots( { foo: 1, bar: 2 }, @@ -243,13 +243,13 @@ describe('DiffBuilder', function() { }); it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() { - const prettyPrinter = privateUnderTest.makePrettyPrinter([]), - diffBuilder = new privateUnderTest.DiffBuilder({ - prettyPrinter: prettyPrinter - }), - expectedMsg = - 'Expected $.x.foo = 1 to equal 2.\n' + - 'Expected $.x.baz = undefined to equal 3.'; + const prettyPrinter = privateUnderTest.makePrettyPrinter([]); + const diffBuilder = new privateUnderTest.DiffBuilder({ + prettyPrinter: prettyPrinter + }); + const expectedMsg = + 'Expected $.x.foo = 1 to equal 2.\n' + + 'Expected $.x.baz = undefined to equal 3.'; diffBuilder.setRoots( { x: { foo: 1, bar: 2 } }, diff --git a/spec/core/matchers/async/toBePendingSpec.js b/spec/core/matchers/async/toBePendingSpec.js index 4445677e..d3467df1 100644 --- a/spec/core/matchers/async/toBePendingSpec.js +++ b/spec/core/matchers/async/toBePendingSpec.js @@ -1,8 +1,8 @@ describe('toBePending', function() { it('passes if the actual promise is pending', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), - actual = new Promise(function() {}); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil); + const actual = new Promise(function() {}); return matcher.compare(actual).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -10,9 +10,9 @@ describe('toBePending', function() { }); it('fails if the actual promise is resolved', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), - actual = Promise.resolve(); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil); + const actual = Promise.resolve(); return matcher.compare(actual).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: false })); @@ -20,9 +20,9 @@ describe('toBePending', function() { }); it('fails if the actual promise is rejected', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), - actual = Promise.reject(new Error('promise was rejected')); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil); + const actual = Promise.reject(new Error('promise was rejected')); return matcher.compare(actual).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: false })); @@ -30,9 +30,9 @@ describe('toBePending', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil), - actual = 'not a promise'; + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBePending(matchersUtil); + const actual = 'not a promise'; function f() { return matcher.compare(actual); diff --git a/spec/core/matchers/async/toBeRejectedSpec.js b/spec/core/matchers/async/toBeRejectedSpec.js index fc52c67c..c0061669 100644 --- a/spec/core/matchers/async/toBeRejectedSpec.js +++ b/spec/core/matchers/async/toBeRejectedSpec.js @@ -1,8 +1,8 @@ describe('toBeRejected', function() { it('passes if the actual is rejected', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil), - actual = Promise.reject('AsyncExpectationSpec rejection'); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil); + const actual = Promise.reject('AsyncExpectationSpec rejection'); return matcher.compare(actual).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -10,9 +10,9 @@ describe('toBeRejected', function() { }); it('fails if the actual is resolved', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil), - actual = Promise.resolve(); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil); + const actual = Promise.resolve(); return matcher.compare(actual).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: false })); @@ -20,9 +20,9 @@ describe('toBeRejected', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil), - actual = 'not a promise'; + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil); + const actual = 'not a promise'; function f() { return matcher.compare(actual); diff --git a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js index da6967ec..08c0ac0e 100644 --- a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js @@ -1,12 +1,12 @@ describe('#toBeRejectedWithError', function() { it('passes when Error type matches', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new TypeError('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new TypeError('foo')); return matcher.compare(actual, TypeError).then(function(result) { expect(result).toEqual( @@ -21,12 +21,12 @@ describe('#toBeRejectedWithError', function() { it('passes when Error type and message matches', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new TypeError('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new TypeError('foo')); return matcher.compare(actual, TypeError, 'foo').then(function(result) { expect(result).toEqual( @@ -41,12 +41,12 @@ describe('#toBeRejectedWithError', function() { it('passes when Error matches and is exactly Error', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error()); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error()); return matcher.compare(actual, Error).then(function(result) { expect(result).toEqual( @@ -61,12 +61,12 @@ describe('#toBeRejectedWithError', function() { it('passes when Error message matches a string', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error('foo')); return matcher.compare(actual, 'foo').then(function(result) { expect(result).toEqual( @@ -81,12 +81,12 @@ describe('#toBeRejectedWithError', function() { it('passes when Error message matches a RegExp', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error('foo')); return matcher.compare(actual, /foo/).then(function(result) { expect(result).toEqual( @@ -101,12 +101,12 @@ describe('#toBeRejectedWithError', function() { it('passes when Error message is empty', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error()); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error()); return matcher.compare(actual, '').then(function(result) { expect(result).toEqual( @@ -121,12 +121,12 @@ describe('#toBeRejectedWithError', function() { it('passes when no arguments', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error()); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error()); return matcher.compare(actual, void 0).then(function(result) { expect(result).toEqual( @@ -141,12 +141,12 @@ describe('#toBeRejectedWithError', function() { it('fails when resolved', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.resolve(new Error('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.resolve(new Error('foo')); return matcher.compare(actual, 'foo').then(function(result) { expect(result).toEqual( @@ -160,12 +160,12 @@ describe('#toBeRejectedWithError', function() { it('fails when rejected with non Error type', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject('foo'); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject('foo'); return matcher.compare(actual, 'foo').then(function(result) { expect(result).toEqual( @@ -180,12 +180,12 @@ describe('#toBeRejectedWithError', function() { it('fails when Error type mismatches', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error('foo')); return matcher.compare(actual, TypeError, 'foo').then(function(result) { expect(result).toEqual( @@ -200,12 +200,12 @@ describe('#toBeRejectedWithError', function() { it('fails when Error message mismatches', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = Promise.reject(new Error('foo')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = Promise.reject(new Error('foo')); return matcher.compare(actual, 'bar').then(function(result) { expect(result).toEqual( @@ -220,12 +220,12 @@ describe('#toBeRejectedWithError', function() { it('fails if actual is not a promise', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( - matchersUtil - ), - actual = 'not a promise'; + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError( + matchersUtil + ); + const actual = 'not a promise'; function f() { return matcher.compare(actual); diff --git a/spec/core/matchers/async/toBeRejectedWithMatchingSpec.js b/spec/core/matchers/async/toBeRejectedWithMatchingSpec.js index 1805cea2..b8d04906 100644 --- a/spec/core/matchers/async/toBeRejectedWithMatchingSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithMatchingSpec.js @@ -1,8 +1,8 @@ describe('#toBeRejectedWithMatching', function() { it('passes if the promise is rejected with something matching the predicate', function() { - const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(), - actual = Promise.reject(new Error('nope')), - predicate = value => value.message === 'nope'; + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(); + const actual = Promise.reject(new Error('nope')); + const predicate = value => value.message === 'nope'; return matcher.compare(actual, predicate).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -10,9 +10,9 @@ describe('#toBeRejectedWithMatching', function() { }); it('fails if the promise resolves', function() { - const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(), - actual = Promise.resolve(), - predicate = () => true; + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(); + const actual = Promise.resolve(); + const predicate = () => true; return matcher.compare(actual, predicate).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: false })); @@ -20,9 +20,9 @@ describe('#toBeRejectedWithMatching', function() { }); it('fails if the promise is rejected with something not matching the predicate', function() { - const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(), - actual = Promise.reject('A Bad Apple'), - predicate = value => value === 'A Good Orange'; + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(); + const actual = Promise.reject('A Bad Apple'); + const predicate = value => value === 'A Good Orange'; return matcher.compare(actual, predicate).then(function(result) { expect(result).toEqual( @@ -36,9 +36,9 @@ describe('#toBeRejectedWithMatching', function() { }); it('should build its error correctly when negated', function() { - const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(), - actual = Promise.reject(true), - predicate = () => true; + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(); + const actual = Promise.reject(true); + const predicate = () => true; return matcher.compare(actual, predicate).then(function(result) { expect(result).toEqual( @@ -52,8 +52,8 @@ describe('#toBeRejectedWithMatching', function() { }); it('fails if actual is not a promise', function() { - const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(), - actual = 'not a promise'; + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(); + const actual = 'not a promise'; function f() { return matcher.compare(actual); @@ -65,9 +65,9 @@ describe('#toBeRejectedWithMatching', function() { }); it('fails if predicate is not a function', function() { - const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(), - actual = Promise.resolve(), - predicate = 'not a function'; + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithMatching(); + const actual = Promise.resolve(); + const predicate = 'not a function'; function f() { return matcher.compare(actual, predicate); diff --git a/spec/core/matchers/async/toBeRejectedWithSpec.js b/spec/core/matchers/async/toBeRejectedWithSpec.js index 20a7d97b..cff96419 100644 --- a/spec/core/matchers/async/toBeRejectedWithSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithSpec.js @@ -1,8 +1,10 @@ describe('#toBeRejectedWith', function() { it('should return true if the promise is rejected with the expected value', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), - actual = Promise.reject({ error: 'PEBCAK' }); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith( + matchersUtil + ); + const actual = Promise.reject({ error: 'PEBCAK' }); return matcher.compare(actual, { error: 'PEBCAK' }).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -10,9 +12,11 @@ describe('#toBeRejectedWith', function() { }); it('should fail if the promise resolves', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), - actual = Promise.resolve(); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith( + matchersUtil + ); + const actual = Promise.resolve(); return matcher.compare(actual, '').then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: false })); @@ -21,10 +25,12 @@ describe('#toBeRejectedWith', function() { it('should fail if the promise is rejected with a different value', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), - actual = Promise.reject('A Bad Apple'); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith( + matchersUtil + ); + const actual = Promise.reject('A Bad Apple'); return matcher.compare(actual, 'Some Cool Thing').then(function(result) { expect(result).toEqual( @@ -39,10 +45,12 @@ describe('#toBeRejectedWith', function() { it('should build its error correctly when negated', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), - actual = Promise.reject(true); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith( + matchersUtil + ); + const actual = Promise.reject(true); return matcher.compare(actual, true).then(function(result) { expect(result).toEqual( @@ -56,15 +64,17 @@ describe('#toBeRejectedWith', function() { it('should support custom equality testers', function() { const customEqualityTesters = [ - function() { - return true; - } - ], - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: customEqualityTesters - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), - actual = Promise.reject('actual'); + function() { + return true; + } + ]; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: customEqualityTesters + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith( + matchersUtil + ); + const actual = Promise.reject('actual'); return matcher.compare(actual, 'expected').then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -73,10 +83,12 @@ describe('#toBeRejectedWith', function() { it('fails if actual is not a promise', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), - actual = 'not a promise'; + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeRejectedWith( + matchersUtil + ); + const actual = 'not a promise'; function f() { return matcher.compare(actual); diff --git a/spec/core/matchers/async/toBeResolvedSpec.js b/spec/core/matchers/async/toBeResolvedSpec.js index 5d34af95..3f107216 100644 --- a/spec/core/matchers/async/toBeResolvedSpec.js +++ b/spec/core/matchers/async/toBeResolvedSpec.js @@ -1,8 +1,8 @@ describe('toBeResolved', function() { it('passes if the actual is resolved', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil), - actual = Promise.resolve(); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil); + const actual = Promise.resolve(); return matcher.compare(actual).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -11,10 +11,10 @@ describe('toBeResolved', function() { it('fails if the actual is rejected', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter([]) - }), - matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil), - actual = Promise.reject(new Error('AsyncExpectationSpec rejection')); + pp: privateUnderTest.makePrettyPrinter([]) + }); + const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil); + const actual = Promise.reject(new Error('AsyncExpectationSpec rejection')); return matcher.compare(actual).then(function(result) { expect(result).toEqual({ @@ -27,9 +27,9 @@ describe('toBeResolved', function() { }); it('fails if actual is not a promise', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil), - actual = 'not a promise'; + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeResolved(matchersUtil); + const actual = 'not a promise'; function f() { return matcher.compare(actual); diff --git a/spec/core/matchers/async/toBeResolvedToSpec.js b/spec/core/matchers/async/toBeResolvedToSpec.js index e0f1f57d..3b651d87 100644 --- a/spec/core/matchers/async/toBeResolvedToSpec.js +++ b/spec/core/matchers/async/toBeResolvedToSpec.js @@ -1,8 +1,8 @@ describe('#toBeResolvedTo', function() { it('passes if the promise is resolved to the expected value', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), - actual = Promise.resolve({ foo: 42 }); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil); + const actual = Promise.resolve({ foo: 42 }); return matcher.compare(actual, { foo: 42 }).then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -11,10 +11,10 @@ describe('#toBeResolvedTo', function() { it('fails if the promise is rejected', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), - actual = Promise.reject(new Error('AsyncExpectationSpec error')); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil); + const actual = Promise.reject(new Error('AsyncExpectationSpec error')); return matcher.compare(actual, '').then(function(result) { expect(result).toEqual( @@ -30,10 +30,10 @@ describe('#toBeResolvedTo', function() { it('fails if the promise is resolved to a different value', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), - actual = Promise.resolve({ foo: 17 }); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil); + const actual = Promise.resolve({ foo: 17 }); return matcher.compare(actual, { foo: 42 }).then(function(result) { expect(result).toEqual( @@ -48,10 +48,10 @@ describe('#toBeResolvedTo', function() { it('builds its message correctly when negated', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), - actual = Promise.resolve(true); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil); + const actual = Promise.resolve(true); return matcher.compare(actual, true).then(function(result) { expect(result).toEqual( @@ -65,16 +65,16 @@ describe('#toBeResolvedTo', function() { it('supports custom equality testers', function() { const customEqualityTesters = [ - function() { - return true; - } - ], - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: customEqualityTesters, - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), - actual = Promise.resolve('actual'); + function() { + return true; + } + ]; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: customEqualityTesters, + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil); + const actual = Promise.resolve('actual'); return matcher.compare(actual, 'expected').then(function(result) { expect(result).toEqual(jasmine.objectContaining({ pass: true })); @@ -83,10 +83,10 @@ describe('#toBeResolvedTo', function() { it('fails if actual is not a promise', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), - actual = 'not a promise'; + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil); + const actual = 'not a promise'; function f() { return matcher.compare(actual); diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index 8558a38a..f8db047d 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -1,7 +1,7 @@ describe('matchersUtil', function() { it('exposes the injected pretty-printer as .pp', function() { - const pp = function() {}, - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const pp = function() {}; + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); expect(matchersUtil.pp).toBe(pp); }); @@ -86,8 +86,8 @@ describe('matchersUtil', function() { }); it('passes for Arrays that are equivalent, with elements added by changing length', function() { - const foo = [], - matchersUtil = new privateUnderTest.MatchersUtil(); + const foo = []; + const matchersUtil = new privateUnderTest.MatchersUtil(); foo.length = 1; expect(matchersUtil.equals(foo, [undefined])).toBe(true); @@ -104,9 +104,9 @@ describe('matchersUtil', function() { }); it('fails for Arrays whose contents are equivalent, but have differing properties', function() { - const one = [1, 2, 3], - two = [1, 2, 3], - matchersUtil = new privateUnderTest.MatchersUtil(); + const one = [1, 2, 3]; + const two = [1, 2, 3]; + const matchersUtil = new privateUnderTest.MatchersUtil(); one.foo = 'bar'; two.foo = 'baz'; @@ -115,9 +115,9 @@ describe('matchersUtil', function() { }); it('passes for Arrays with equivalent contents and properties', function() { - const one = [1, 2, 3], - two = [1, 2, 3], - matchersUtil = new privateUnderTest.MatchersUtil(); + const one = [1, 2, 3]; + const two = [1, 2, 3]; + const matchersUtil = new privateUnderTest.MatchersUtil(); one.foo = 'bar'; two.foo = 'bar'; @@ -126,9 +126,9 @@ describe('matchersUtil', function() { }); it('handles symbol keys in Arrays', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - sym = Symbol('foo'), - arr1 = []; + const matchersUtil = new privateUnderTest.MatchersUtil(); + const sym = Symbol('foo'); + const arr1 = []; let arr2 = []; arr1[sym] = 'bar'; @@ -200,9 +200,9 @@ describe('matchersUtil', function() { }); it('passes for Objects that are equivalent (with cycles)', function() { - const actual = { a: 'foo' }, - expected = { a: 'foo' }, - matchersUtil = new privateUnderTest.MatchersUtil(); + const actual = { a: 'foo' }; + const expected = { a: 'foo' }; + const matchersUtil = new privateUnderTest.MatchersUtil(); actual.b = actual; expected.b = actual; @@ -211,9 +211,9 @@ describe('matchersUtil', function() { }); it('fails for Objects that are not equivalent (with cycles)', function() { - const actual = { a: 'foo' }, - expected = { a: 'bar' }, - matchersUtil = new privateUnderTest.MatchersUtil(); + const actual = { a: 'foo' }; + const expected = { a: 'bar' }; + const matchersUtil = new privateUnderTest.MatchersUtil(); actual.b = actual; expected.b = actual; @@ -222,26 +222,26 @@ describe('matchersUtil', function() { }); it('fails for Objects that have the same number of keys, but different keys/values', function() { - const expected = { a: undefined }, - actual = { b: 1 }, - matchersUtil = new privateUnderTest.MatchersUtil(); + const expected = { a: undefined }; + const actual = { b: 1 }; + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(actual, expected)).toBe(false); }); it('fails when comparing an empty object to an empty array (issue #114)', function() { - const emptyObject = {}, - emptyArray = [], - matchersUtil = new privateUnderTest.MatchersUtil(); + const emptyObject = {}; + const emptyArray = []; + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false); expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false); }); it('passes for equivalent frozen objects (GitHub issue #266)', function() { - const a = { foo: 1 }, - b = { foo: 1 }, - matchersUtil = new privateUnderTest.MatchersUtil(); + const a = { foo: 1 }; + const b = { foo: 1 }; + const matchersUtil = new privateUnderTest.MatchersUtil(); Object.freeze(a); Object.freeze(b); @@ -250,9 +250,9 @@ describe('matchersUtil', function() { }); it('passes for equivalent Promises (GitHub issue #1314)', function() { - const p1 = new Promise(function() {}), - p2 = new Promise(function() {}), - matchersUtil = new privateUnderTest.MatchersUtil(); + const p1 = new Promise(function() {}); + const p2 = new Promise(function() {}); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(p1, p1)).toBe(true); expect(matchersUtil.equals(p1, p2)).toBe(false); @@ -344,18 +344,18 @@ describe('matchersUtil', function() { }); it('passes when Any is used', function() { - const number = 3, - anyNumber = new privateUnderTest.Any(Number), - matchersUtil = new privateUnderTest.MatchersUtil(); + const number = 3; + const anyNumber = new privateUnderTest.Any(Number); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(number, anyNumber)).toBe(true); expect(matchersUtil.equals(anyNumber, number)).toBe(true); }); it('fails when Any is compared to something unexpected', function() { - const number = 3, - anyString = new privateUnderTest.Any(String), - matchersUtil = new privateUnderTest.MatchersUtil(); + const number = 3; + const anyString = new privateUnderTest.Any(String); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(number, anyString)).toBe(false); expect(matchersUtil.equals(anyString, number)).toBe(false); @@ -363,11 +363,11 @@ describe('matchersUtil', function() { it('passes when ObjectContaining is used', function() { const obj = { - foo: 3, - bar: 7 - }, - containing = new privateUnderTest.ObjectContaining({ foo: 3 }), - matchersUtil = new privateUnderTest.MatchersUtil(); + foo: 3, + bar: 7 + }; + const containing = new privateUnderTest.ObjectContaining({ foo: 3 }); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(obj, containing)).toBe(true); expect(matchersUtil.equals(containing, obj)).toBe(true); @@ -399,11 +399,11 @@ describe('matchersUtil', function() { it('passes when an asymmetric equality tester returns true', function() { const tester = { - asymmetricMatch: function() { - return true; - } - }, - matchersUtil = new privateUnderTest.MatchersUtil(); + asymmetricMatch: function() { + return true; + } + }; + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(false, tester)).toBe(true); expect(matchersUtil.equals(tester, false)).toBe(true); @@ -411,19 +411,19 @@ describe('matchersUtil', function() { it('fails when an asymmetric equality tester returns false', function() { const tester = { - asymmetricMatch: function() { - return false; - } - }, - matchersUtil = new privateUnderTest.MatchersUtil(); + asymmetricMatch: function() { + return false; + } + }; + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(true, tester)).toBe(false); expect(matchersUtil.equals(tester, true)).toBe(false); }); it('passes when ArrayContaining is used', function() { - const arr = ['foo', 'bar'], - matchersUtil = new privateUnderTest.MatchersUtil(); + const arr = ['foo', 'bar']; + const matchersUtil = new privateUnderTest.MatchersUtil(); expect( matchersUtil.equals(arr, new privateUnderTest.ArrayContaining(['bar'])) @@ -432,12 +432,12 @@ describe('matchersUtil', function() { it('passes when a custom equality matcher returns true', function() { const tester = function() { - return true; - }, - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: [tester], - pp: function() {} - }); + return true; + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: [tester], + pp: function() {} + }); expect(matchersUtil.equals(1, 2)).toBe(true); }); @@ -463,46 +463,46 @@ describe('matchersUtil', function() { it('fails for equivalents when a custom equality matcher returns false', function() { const tester = function() { - return false; - }, - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: [tester], - pp: function() {} - }); + return false; + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: [tester], + pp: function() {} + }); expect(matchersUtil.equals(1, 1)).toBe(false); }); it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() { const asymmetricTester = { - asymmetricMatch: function() { - return true; - } - }, - symmetricTester = function() { - return false; - }, - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: [symmetricTester()], - pp: function() {} - }); + asymmetricMatch: function() { + return true; + } + }; + const symmetricTester = function() { + return false; + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: [symmetricTester()], + pp: function() {} + }); expect(matchersUtil.equals(asymmetricTester, true)).toBe(true); expect(matchersUtil.equals(true, asymmetricTester)).toBe(true); }); it('passes when an Any is compared to an Any that checks for the same type', function() { - const any1 = new privateUnderTest.Any(Function), - any2 = new privateUnderTest.Any(Function), - matchersUtil = new privateUnderTest.MatchersUtil(); + const any1 = new privateUnderTest.Any(Function); + const any2 = new privateUnderTest.Any(Function); + const matchersUtil = new privateUnderTest.MatchersUtil(); expect(matchersUtil.equals(any1, any2)).toBe(true); }); it('passes for null prototype objects with same properties', function() { - const objA = Object.create(null), - objB = Object.create(null), - matchersUtil = new privateUnderTest.MatchersUtil(); + const objA = Object.create(null); + const objB = Object.create(null); + const matchersUtil = new privateUnderTest.MatchersUtil(); objA.name = 'test'; objB.name = 'test'; @@ -511,9 +511,9 @@ describe('matchersUtil', function() { }); it('fails for null prototype objects with different properties', function() { - const objA = Object.create(null), - objB = Object.create(null), - matchersUtil = new privateUnderTest.MatchersUtil(); + const objA = Object.create(null); + const objB = Object.create(null); + const matchersUtil = new privateUnderTest.MatchersUtil(); objA.name = 'test'; objB.test = 'name'; @@ -673,8 +673,8 @@ describe('matchersUtil', function() { }); it('fails when comparing two different URLs', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - url1 = new URL('http://localhost/1'); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const url1 = new URL('http://localhost/1'); expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe( false @@ -914,24 +914,24 @@ describe('matchersUtil', function() { describe('Building diffs for asymmetric equality testers', function() { it('diffs the values returned by valuesForDiff_', function() { const tester = { - asymmetricMatch: function() { - return false; - }, - valuesForDiff_: function() { - return { - self: 'asymmetric tester value', - other: 'other value' - }; - } + asymmetricMatch: function() { + return false; }, - actual = { x: 42 }, - expected = { x: tester }, - diffBuilder = jasmine.createSpyObj('diffBuilder', [ - 'recordMismatch', - 'withPath', - 'setRoots' - ]), - matchersUtil = new privateUnderTest.MatchersUtil(); + valuesForDiff_: function() { + return { + self: 'asymmetric tester value', + other: 'other value' + }; + } + }; + const actual = { x: 42 }; + const expected = { x: tester }; + const diffBuilder = jasmine.createSpyObj('diffBuilder', [ + 'recordMismatch', + 'withPath', + 'setRoots' + ]); + const matchersUtil = new privateUnderTest.MatchersUtil(); diffBuilder.withPath.and.callFake(function(p, block) { block(); @@ -948,18 +948,18 @@ describe('matchersUtil', function() { it('records both objects when the tester does not implement valuesForDiff', function() { const tester = { - asymmetricMatch: function() { - return false; - } - }, - actual = { x: 42 }, - expected = { x: tester }, - diffBuilder = jasmine.createSpyObj('diffBuilder', [ - 'recordMismatch', - 'withPath', - 'setRoots' - ]), - matchersUtil = new privateUnderTest.MatchersUtil(); + asymmetricMatch: function() { + return false; + } + }; + const actual = { x: 42 }; + const expected = { x: tester }; + const diffBuilder = jasmine.createSpyObj('diffBuilder', [ + 'recordMismatch', + 'withPath', + 'setRoots' + ]); + const matchersUtil = new privateUnderTest.MatchersUtil(); diffBuilder.withPath.and.callFake(function(p, block) { block(); @@ -976,8 +976,8 @@ describe('matchersUtil', function() { }); it('uses a diffBuilder if one is provided as the third argument', function() { - const diffBuilder = new privateUnderTest.DiffBuilder(), - matchersUtil = new privateUnderTest.MatchersUtil(); + const diffBuilder = new privateUnderTest.DiffBuilder(); + const matchersUtil = new privateUnderTest.MatchersUtil(); spyOn(diffBuilder, 'recordMismatch'); spyOn(diffBuilder, 'withPath').and.callThrough(); @@ -1026,12 +1026,12 @@ describe('matchersUtil', function() { it('uses custom equality testers if actual is an Array', function() { const customTester = function() { - return true; - }, - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: [customTester], - pp: function() {} - }); + return true; + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: [customTester], + pp: function() {} + }); expect(matchersUtil.contains([1, 2], 3)).toBe(true); }); @@ -1091,59 +1091,59 @@ describe('matchersUtil', function() { describe('buildFailureMessage', function() { it('builds an English sentence for a failure case', function() { - const actual = 'foo', - name = 'toBar', - pp = privateUnderTest.makePrettyPrinter(), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - message = matchersUtil.buildFailureMessage(name, false, actual); + const actual = 'foo'; + const name = 'toBar'; + const pp = privateUnderTest.makePrettyPrinter(); + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const message = matchersUtil.buildFailureMessage(name, false, actual); expect(message).toEqual("Expected 'foo' to bar."); }); it("builds an English sentence for a 'not' failure case", function() { - const actual = 'foo', - name = 'toBar', - isNot = true, - pp = privateUnderTest.makePrettyPrinter(), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - message = matchersUtil.buildFailureMessage(name, isNot, actual); + const actual = 'foo'; + const name = 'toBar'; + const isNot = true; + const pp = privateUnderTest.makePrettyPrinter(); + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const message = matchersUtil.buildFailureMessage(name, isNot, actual); expect(message).toEqual("Expected 'foo' not to bar."); }); it('builds an English sentence for an arbitrary array of expected arguments', function() { - const actual = 'foo', - name = 'toBar', - pp = privateUnderTest.makePrettyPrinter(), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - message = matchersUtil.buildFailureMessage( - name, - false, - actual, - 'quux', - 'corge' - ); + const actual = 'foo'; + const name = 'toBar'; + const pp = privateUnderTest.makePrettyPrinter(); + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const message = matchersUtil.buildFailureMessage( + name, + false, + actual, + 'quux', + 'corge' + ); expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'."); }); it('uses the injected pretty-printer to format the expecteds and actual', function() { - const actual = 'foo', - expected1 = 'qux', - expected2 = 'grault', - name = 'toBar', - isNot = false, - pp = function(value) { - return '<' + value + '>'; - }, - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - message = matchersUtil.buildFailureMessage( - name, - isNot, - actual, - expected1, - expected2 - ); + const actual = 'foo'; + const expected1 = 'qux'; + const expected2 = 'grault'; + const name = 'toBar'; + const isNot = false; + const pp = function(value) { + return '<' + value + '>'; + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const message = matchersUtil.buildFailureMessage( + name, + isNot, + actual, + expected1, + expected2 + ); expect(message).toEqual('Expected to bar , .'); }); diff --git a/spec/core/matchers/nothingSpec.js b/spec/core/matchers/nothingSpec.js index 4809255e..61deef4b 100644 --- a/spec/core/matchers/nothingSpec.js +++ b/spec/core/matchers/nothingSpec.js @@ -1,7 +1,7 @@ describe('nothing', function() { it('should pass', function() { - const matcher = privateUnderTest.matchers.nothing(), - result = matcher.compare(); + const matcher = privateUnderTest.matchers.nothing(); + const result = matcher.compare(); expect(result.pass).toBe(true); }); diff --git a/spec/core/matchers/toBeNaNSpec.js b/spec/core/matchers/toBeNaNSpec.js index b7e0f51e..89152351 100644 --- a/spec/core/matchers/toBeNaNSpec.js +++ b/spec/core/matchers/toBeNaNSpec.js @@ -28,9 +28,9 @@ describe('toBeNaN', function() { it('has a custom message on failure', function() { const matcher = privateUnderTest.matchers.toBeNaN({ - pp: privateUnderTest.makePrettyPrinter() - }), - result = matcher.compare(0); + pp: privateUnderTest.makePrettyPrinter() + }); + const result = matcher.compare(0); expect(result.message()).toEqual('Expected 0 to be NaN.'); }); diff --git a/spec/core/matchers/toBeNegativeInfinitySpec.js b/spec/core/matchers/toBeNegativeInfinitySpec.js index 07fcdeb0..adab83af 100644 --- a/spec/core/matchers/toBeNegativeInfinitySpec.js +++ b/spec/core/matchers/toBeNegativeInfinitySpec.js @@ -15,16 +15,16 @@ describe('toBeNegativeInfinity', function() { it('has a custom message on failure', function() { const matcher = privateUnderTest.matchers.toBeNegativeInfinity({ - pp: privateUnderTest.makePrettyPrinter() - }), - result = matcher.compare(0); + pp: privateUnderTest.makePrettyPrinter() + }); + const result = matcher.compare(0); expect(result.message()).toEqual('Expected 0 to be -Infinity.'); }); it('succeeds for -Infinity', function() { - const matcher = privateUnderTest.matchers.toBeNegativeInfinity(), - result = matcher.compare(Number.NEGATIVE_INFINITY); + const matcher = privateUnderTest.matchers.toBeNegativeInfinity(); + const result = matcher.compare(Number.NEGATIVE_INFINITY); expect(result.pass).toBe(true); expect(result.message).toEqual('Expected actual not to be -Infinity.'); diff --git a/spec/core/matchers/toBePositiveInfinitySpec.js b/spec/core/matchers/toBePositiveInfinitySpec.js index 7588c84a..fae1d0a2 100644 --- a/spec/core/matchers/toBePositiveInfinitySpec.js +++ b/spec/core/matchers/toBePositiveInfinitySpec.js @@ -15,16 +15,16 @@ describe('toBePositiveInfinity', function() { it('has a custom message on failure', function() { const matcher = privateUnderTest.matchers.toBePositiveInfinity({ - pp: privateUnderTest.makePrettyPrinter() - }), - result = matcher.compare(0); + pp: privateUnderTest.makePrettyPrinter() + }); + const result = matcher.compare(0); expect(result.message()).toEqual('Expected 0 to be Infinity.'); }); it('succeeds for Infinity', function() { - const matcher = privateUnderTest.matchers.toBePositiveInfinity(), - result = matcher.compare(Number.POSITIVE_INFINITY); + const matcher = privateUnderTest.matchers.toBePositiveInfinity(); + const result = matcher.compare(Number.POSITIVE_INFINITY); expect(result.pass).toBe(true); expect(result.message).toEqual('Expected actual not to be Infinity.'); diff --git a/spec/core/matchers/toBeSpec.js b/spec/core/matchers/toBeSpec.js index e1fe6bee..34fe09c6 100644 --- a/spec/core/matchers/toBeSpec.js +++ b/spec/core/matchers/toBeSpec.js @@ -1,17 +1,17 @@ describe('toBe', function() { it('passes with no message when actual === expected', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - result = matcher.compare(1, 1); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const result = matcher.compare(1, 1); expect(result.pass).toBe(true); }); it('passes with a custom message when expected is an array', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - array = [1]; + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const array = [1]; const result = matcher.compare(array, array); expect(result.pass).toBe(true); @@ -22,10 +22,10 @@ describe('toBe', function() { it('passes with a custom message when expected is an object', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - obj = { foo: 'bar' }; + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const obj = { foo: 'bar' }; const result = matcher.compare(obj, obj); expect(result.pass).toBe(true); @@ -35,19 +35,19 @@ describe('toBe', function() { }); it('fails with no message when actual !== expected', function() { - const matchersUtil = new privateUnderTest.MatchersUtil(), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - result = matcher.compare(1, 2); + const matchersUtil = new privateUnderTest.MatchersUtil(); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const result = matcher.compare(1, 2); expect(result.pass).toBe(false); expect(result.message).toBeUndefined(); }); it('fails with a custom message when expected is an array', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - result = matcher.compare([1], [1]); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const result = matcher.compare([1], [1]); expect(result.pass).toBe(false); expect(result.message).toBe( @@ -57,10 +57,10 @@ describe('toBe', function() { it('fails with a custom message when expected is an object', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); expect(result.pass).toBe(false); expect(result.message).toBe( @@ -70,12 +70,14 @@ describe('toBe', function() { it('works with custom object formatters when expected is an object', function() { const formatter = function(x) { - return '<' + x.foo + '>'; - }, - prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), - matcher = privateUnderTest.matchers.toBe(matchersUtil), - result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); + return '<' + x.foo + '>'; + }; + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: prettyPrinter + }); + const matcher = privateUnderTest.matchers.toBe(matchersUtil); + const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); expect(result.pass).toBe(false); expect(result.message).toBe( diff --git a/spec/core/matchers/toContainSpec.js b/spec/core/matchers/toContainSpec.js index 2980a09f..15be89bc 100644 --- a/spec/core/matchers/toContainSpec.js +++ b/spec/core/matchers/toContainSpec.js @@ -1,9 +1,9 @@ describe('toContain', function() { it('delegates to privateUnderTest.MatchersUtil.contains', function() { const matchersUtil = { - contains: jasmine.createSpy('delegated-contains').and.returnValue(true) - }, - matcher = privateUnderTest.matchers.toContain(matchersUtil); + contains: jasmine.createSpy('delegated-contains').and.returnValue(true) + }; + const matcher = privateUnderTest.matchers.toContain(matchersUtil); const result = matcher.compare('ABC', 'B'); expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B'); @@ -12,12 +12,12 @@ describe('toContain', function() { it('works with custom equality testers', function() { const tester = function(a, b) { - return a.toString() === b.toString(); - }, - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: [tester] - }), - matcher = privateUnderTest.matchers.toContain(matchersUtil); + return a.toString() === b.toString(); + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: [tester] + }); + const matcher = privateUnderTest.matchers.toContain(matchersUtil); const result = matcher.compare(['1', '2'], 2); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toEqualSpec.js b/spec/core/matchers/toEqualSpec.js index fce13347..2598bc1a 100644 --- a/spec/core/matchers/toEqualSpec.js +++ b/spec/core/matchers/toEqualSpec.js @@ -3,9 +3,9 @@ describe('toEqual', function() { function compareEquals(actual, expected) { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); const result = matcher.compare(actual, expected); @@ -14,13 +14,13 @@ describe('toEqual', function() { it('delegates to equals function', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equals').and.returnValue(true), - buildFailureMessage: function() { - return 'does not matter'; - }, - DiffBuilder: new privateUnderTest.DiffBuilder() + equals: jasmine.createSpy('delegated-equals').and.returnValue(true), + buildFailureMessage: function() { + return 'does not matter'; }, - matcher = privateUnderTest.matchers.toEqual(matchersUtil); + DiffBuilder: new privateUnderTest.DiffBuilder() + }; + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); const result = matcher.compare(1, 1); @@ -30,12 +30,12 @@ describe('toEqual', function() { it('works with custom equality testers', function() { const tester = function(a, b) { - return a.toString() === b.toString(); - }, - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: [tester] - }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil); + return a.toString() === b.toString(); + }; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: [tester] + }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); const result = matcher.compare(1, '1'); @@ -43,18 +43,18 @@ describe('toEqual', function() { }); it('reports the difference between objects that are not equal', function() { - const actual = { x: 1, y: 3 }, - expected = { x: 2, y: 3 }, - message = 'Expected $.x = 1 to equal 2.'; + const actual = { x: 1, y: 3 }; + const expected = { x: 2, y: 3 }; + const message = 'Expected $.x = 1 to equal 2.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports differences between enumerable symbol properties', function() { - const x = Symbol('x'), - actual = { [x]: 1, y: 3 }, - expected = { [x]: 2, y: 3 }, - message = 'Expected $[Symbol(x)] = 1 to equal 2.'; + const x = Symbol('x'); + const actual = { [x]: 1, y: 3 }; + const expected = { [x]: 2, y: 3 }; + const message = 'Expected $[Symbol(x)] = 1 to equal 2.'; expect(compareEquals(actual, expected).message).toEqual(message); }); @@ -72,69 +72,71 @@ describe('toEqual', function() { }); it('reports the difference between nested objects that are not equal', function() { - const actual = { x: { y: 1 } }, - expected = { x: { y: 2 } }, - message = 'Expected $.x.y = 1 to equal 2.'; + const actual = { x: { y: 1 } }; + const expected = { x: { y: 2 } }; + const message = 'Expected $.x.y = 1 to equal 2.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it("formats property access so that it's valid JavaScript", function() { - const actual = { 'my prop': 1 }, - expected = { 'my prop': 2 }, - message = "Expected $['my prop'] = 1 to equal 2."; + const actual = { 'my prop': 1 }; + const expected = { 'my prop': 2 }; + const message = "Expected $['my prop'] = 1 to equal 2."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports missing properties', function() { - const actual = { x: {} }, - expected = { x: { y: 1 } }, - message = 'Expected $.x to have properties\n' + ' y: 1'; + const actual = { x: {} }; + const expected = { x: { y: 1 } }; + const message = 'Expected $.x to have properties\n' + ' y: 1'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches as well as missing or extra properties', function() { - const actual = { x: { z: 2 } }, - expected = { x: { y: 1, z: 3 } }, - message = - 'Expected $.x to have properties\n' + - ' y: 1\n' + - 'Expected $.x.z = 2 to equal 3.'; + const actual = { x: { z: 2 } }; + const expected = { x: { y: 1, z: 3 } }; + const message = + 'Expected $.x to have properties\n' + + ' y: 1\n' + + 'Expected $.x.z = 2 to equal 3.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports missing symbol properties', function() { - const actual = { x: {} }, - expected = { x: { [Symbol('y')]: 1 } }, - message = 'Expected $.x to have properties\n' + ' Symbol(y): 1'; + const actual = { x: {} }; + const expected = { x: { [Symbol('y')]: 1 } }; + const message = 'Expected $.x to have properties\n' + ' Symbol(y): 1'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports extra symbol properties', function() { - const actual = { x: { [Symbol('y')]: 1 } }, - expected = { x: {} }, - message = 'Expected $.x not to have properties\n' + ' Symbol(y): 1'; + const actual = { x: { [Symbol('y')]: 1 } }; + const expected = { x: {} }; + const message = + 'Expected $.x not to have properties\n' + ' Symbol(y): 1'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports extra properties', function() { - const actual = { x: { y: 1, z: 2 } }, - expected = { x: {} }, - message = - 'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2'; + const actual = { x: { y: 1, z: 2 } }; + const expected = { x: {} }; + const message = + 'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('pretty-prints properties', function() { - const actual = { x: { y: 'foo bar' } }, - expected = { x: {} }, - message = 'Expected $.x not to have properties\n' + " y: 'foo bar'"; + const actual = { x: { y: 'foo bar' } }; + const expected = { x: {} }; + const message = + 'Expected $.x not to have properties\n' + " y: 'foo bar'"; expect(compareEquals(actual, expected).message).toEqual(message); }); @@ -146,16 +148,16 @@ describe('toEqual', function() { } } - const actual = { x: { y: 1, z: 2, f: 4 } }, - expected = { x: { y: 1, z: 2, g: 3 } }, - pp = privateUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil), - message = - 'Expected $.x to have properties\n' + - ' g: |3|\n' + - 'Expected $.x not to have properties\n' + - ' f: |4|'; + const actual = { x: { y: 1, z: 2, f: 4 } }; + const expected = { x: { y: 1, z: 2, g: 3 } }; + const pp = privateUnderTest.makePrettyPrinter([formatter]); + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); + const message = + 'Expected $.x to have properties\n' + + ' g: |3|\n' + + 'Expected $.x not to have properties\n' + + ' f: |4|'; expect(matcher.compare(actual, expected).message).toEqual(message); }); @@ -167,12 +169,14 @@ describe('toEqual', function() { } } - const actual = [{ foo: 4 }], - expected = [{ foo: 5 }], - prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil), - message = 'Expected $[0].foo = |4| to equal |5|.'; + const actual = [{ foo: 4 }]; + const expected = [{ foo: 5 }]; + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: prettyPrinter + }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); + const message = 'Expected $[0].foo = |4| to equal |5|.'; expect(matcher.compare(actual, expected).message).toEqual(message); }); @@ -185,184 +189,186 @@ describe('toEqual', function() { } const actual = [ - { - foo: { a: 1, b: 2 }, - bar: 'should not be pretty printed' - } - ], - expected = [ - { - foo: { a: 5, b: 2 }, - bar: "shouldn't be pretty printed" - } - ], - prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil), - message = - 'Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n' + - "Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'."; + { + foo: { a: 1, b: 2 }, + bar: 'should not be pretty printed' + } + ]; + const expected = [ + { + foo: { a: 5, b: 2 }, + bar: "shouldn't be pretty printed" + } + ]; + const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]); + const matchersUtil = new privateUnderTest.MatchersUtil({ + pp: prettyPrinter + }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); + const message = + 'Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n' + + "Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'."; expect(matcher.compare(actual, expected).message).toEqual(message); }); it('reports extra and missing properties of the root-level object', function() { - const actual = { x: 1 }, - expected = { a: 1 }, - message = - 'Expected object to have properties\n' + - ' a: 1\n' + - 'Expected object not to have properties\n' + - ' x: 1'; + const actual = { x: 1 }; + const expected = { a: 1 }; + const message = + 'Expected object to have properties\n' + + ' a: 1\n' + + 'Expected object not to have properties\n' + + ' x: 1'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports multiple incorrect values', function() { - const actual = { x: 1, y: 2 }, - expected = { x: 3, y: 4 }, - message = - 'Expected $.x = 1 to equal 3.\n' + 'Expected $.y = 2 to equal 4.'; + const actual = { x: 1, y: 2 }; + const expected = { x: 3, y: 4 }; + const message = + 'Expected $.x = 1 to equal 3.\n' + 'Expected $.y = 2 to equal 4.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatch between actual child object and expected child number', function() { - const actual = { x: { y: 2 } }, - expected = { x: 1 }, - message = 'Expected $.x = Object({ y: 2 }) to equal 1.'; + const actual = { x: { y: 2 } }; + const expected = { x: 1 }; + const message = 'Expected $.x = Object({ y: 2 }) to equal 1.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('uses the default failure message if actual is not an object', function() { - const actual = 1, - expected = { x: {} }, - message = 'Expected 1 to equal Object({ x: Object({ }) }).'; + const actual = 1; + const expected = { x: {} }; + const message = 'Expected 1 to equal Object({ x: Object({ }) }).'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('uses the default failure message if expected is not an object', function() { - const actual = { x: {} }, - expected = 1, - message = 'Expected Object({ x: Object({ }) }) to equal 1.'; + const actual = { x: {} }; + const expected = 1; + const message = 'Expected Object({ x: Object({ }) }) to equal 1.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('uses the default failure message given arrays with different lengths', function() { - const actual = [1, 2], - expected = [1, 2, 3], - message = - 'Expected $.length = 2 to equal 3.\n' + - 'Expected $[2] = undefined to equal 3.'; + const actual = [1, 2]; + const expected = [1, 2, 3]; + const message = + 'Expected $.length = 2 to equal 3.\n' + + 'Expected $[2] = undefined to equal 3.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports a mismatch between elements of equal-length arrays', function() { - const actual = [1, 2, 5], - expected = [1, 2, 3], - message = 'Expected $[2] = 5 to equal 3.'; + const actual = [1, 2, 5]; + const expected = [1, 2, 3]; + const message = 'Expected $[2] = 5 to equal 3.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports a mismatch between multiple array elements', function() { - const actual = [2, 2, 5], - expected = [1, 2, 3], - message = - 'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.'; + const actual = [2, 2, 5]; + const expected = [1, 2, 3]; + const message = + 'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports a mismatch between properties of objects in arrays', function() { - const actual = [{ x: 1 }], - expected = [{ x: 2 }], - message = 'Expected $[0].x = 1 to equal 2.'; + const actual = [{ x: 1 }]; + const expected = [{ x: 2 }]; + const message = 'Expected $[0].x = 1 to equal 2.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports a mismatch between arrays in objects', function() { - const actual = { x: [1] }, - expected = { x: [2] }, - message = 'Expected $.x[0] = 1 to equal 2.'; + const actual = { x: [1] }; + const expected = { x: [2] }; + const message = 'Expected $.x[0] = 1 to equal 2.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between nested arrays', function() { - const actual = [[1]], - expected = [[2]], - message = 'Expected $[0][0] = 1 to equal 2.'; + const actual = [[1]]; + const expected = [[2]]; + const message = 'Expected $[0][0] = 1 to equal 2.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between arrays of different types', function() { - const actual = new Uint32Array([1, 2, 3]), - expected = new Uint16Array([1, 2, 3]), - message = - 'Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].'; + const actual = new Uint32Array([1, 2, 3]); + const expected = new Uint16Array([1, 2, 3]); + const message = + 'Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving NaN', function() { - const actual = { x: 0 }, - expected = { x: 0 / 0 }, - message = 'Expected $.x = 0 to equal NaN.'; + const actual = { x: 0 }; + const expected = { x: 0 / 0 }; + const message = 'Expected $.x = 0 to equal NaN.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving regular expressions', function() { - const actual = { x: '1' }, - expected = { x: /1/ }, - message = "Expected $.x = '1' to equal /1/."; + const actual = { x: '1' }; + const expected = { x: /1/ }; + const message = "Expected $.x = '1' to equal /1/."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving infinities', function() { - const actual = { x: 0 }, - expected = { x: 1 / 0 }, - message = 'Expected $.x = 0 to equal Infinity.'; + const actual = { x: 0 }; + const expected = { x: 1 / 0 }; + const message = 'Expected $.x = 0 to equal Infinity.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving booleans', function() { - const actual = { x: false }, - expected = { x: true }, - message = 'Expected $.x = false to equal true.'; + const actual = { x: false }; + const expected = { x: true }; + const message = 'Expected $.x = false to equal true.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving strings', function() { - const actual = { x: 'foo' }, - expected = { x: 'bar' }, - message = "Expected $.x = 'foo' to equal 'bar'."; + const actual = { x: 'foo' }; + const expected = { x: 'bar' }; + const message = "Expected $.x = 'foo' to equal 'bar'."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving undefined', function() { - const actual = { x: void 0 }, - expected = { x: 0 }, - message = 'Expected $.x = undefined to equal 0.'; + const actual = { x: void 0 }; + const expected = { x: 0 }; + const message = 'Expected $.x = undefined to equal 0.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches involving null', function() { - const actual = { x: null }, - expected = { x: 0 }, - message = 'Expected $.x = null to equal 0.'; + const actual = { x: null }; + const expected = { x: 0 }; + const message = 'Expected $.x = null to equal 0.'; expect(compareEquals(actual, expected).message).toEqual(message); }); @@ -371,9 +377,9 @@ describe('toEqual', function() { function Foo() {} function Bar() {} - const actual = { x: new Foo() }, - expected = { x: new Bar() }, - message = 'Expected $.x to be a kind of Bar, but was Foo({ }).'; + const actual = { x: new Foo() }; + const expected = { x: new Bar() }; + const message = 'Expected $.x to be a kind of Bar, but was Foo({ }).'; expect(compareEquals(actual, expected).message).toEqual(message); }); @@ -387,12 +393,13 @@ describe('toEqual', function() { } } - const actual = { x: new Foo() }, - expected = { x: new Bar() }, - message = 'Expected $.x to be a kind of Bar, but was |[object Object]|.', - pp = privateUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil); + const actual = { x: new Foo() }; + const expected = { x: new Bar() }; + const message = + 'Expected $.x to be a kind of Bar, but was |[object Object]|.'; + const pp = privateUnderTest.makePrettyPrinter([formatter]); + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); expect(matcher.compare(actual, expected).message).toEqual(message); }); @@ -401,9 +408,9 @@ describe('toEqual', function() { function Foo() {} function Bar() {} - const actual = new Foo(), - expected = new Bar(), - message = 'Expected object to be a kind of Bar, but was Foo({ }).'; + const actual = new Foo(); + const expected = new Bar(); + const message = 'Expected object to be a kind of Bar, but was Foo({ }).'; expect(compareEquals(actual, expected).message).toEqual(message); }); @@ -413,18 +420,18 @@ describe('toEqual', function() { }); it('reports mismatches between objects with their own constructor property', function() { - const actual = { x: { constructor: 'blerf' } }, - expected = { x: { constructor: 'ftarrh' } }, - message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'."; + const actual = { x: { constructor: 'blerf' } }; + const expected = { x: { constructor: 'ftarrh' } }; + const message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between an object with a real constructor and one with its own constructor property', function() { - const actual = { x: {} }, - expected = { x: { constructor: 'ftarrh' } }, - message = - 'Expected $.x to have properties\n' + " constructor: 'ftarrh'"; + const actual = { x: {} }; + const expected = { x: { constructor: 'ftarrh' } }; + const message = + 'Expected $.x to have properties\n' + " constructor: 'ftarrh'"; expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(expected, actual).message).toEqual( @@ -433,26 +440,26 @@ describe('toEqual', function() { }); it('reports mismatches between 0 and -0', function() { - const actual = { x: 0 }, - expected = { x: -0 }, - message = 'Expected $.x = 0 to equal -0.'; + const actual = { x: 0 }; + const expected = { x: -0 }; + const message = 'Expected $.x = 0 to equal -0.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between 0 and Number.MIN_VALUE', function() { - const actual = { x: 0 }, - expected = { x: Number.MIN_VALUE }, - message = 'Expected $.x = 0 to equal 5e-324.'; + const actual = { x: 0 }; + const expected = { x: Number.MIN_VALUE }; + const message = 'Expected $.x = 0 to equal 5e-324.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Errors', function() { - const actual = { x: new Error('the error you got') }, - expected = { x: new Error('the error you want') }, - message = - 'Expected $.x = Error: the error you got to equal Error: the error you want.'; + const actual = { x: new Error('the error you got') }; + const expected = { x: new Error('the error you want') }; + const message = + 'Expected $.x = Error: the error you got to equal Error: the error you want.'; expect(compareEquals(actual, expected).message).toEqual(message); }); @@ -713,35 +720,38 @@ describe('toEqual', function() { }); it('reports mismatches between DOM nodes with different tags', function() { - const actual = { a: this.doc.createElement('div') }, - expected = { a: this.doc.createElement('p') }, - message = 'Expected $.a =
to equal

.'; + const actual = { a: this.doc.createElement('div') }; + const expected = { a: this.doc.createElement('p') }; + const message = 'Expected $.a =

to equal

.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between DOM nodes with different content', function() { - const nodeA = this.doc.createElement('div'), - nodeB = this.doc.createElement('div'); + const nodeA = this.doc.createElement('div'); + const nodeB = this.doc.createElement('div'); nodeA.setAttribute('thing', 'foo'); nodeB.setAttribute('thing', 'bar'); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = - 'Expected $.a =

to equal
.'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = + 'Expected $.a =
to equal
.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between SVG nodes', function() { const nodeA = this.doc.createElementNS( - 'http://www.w3.org/2000/svg', - 'svg' - ), - nodeB = this.doc.createElementNS('http://www.w3.org/2000/svg', 'svg'); + 'http://www.w3.org/2000/svg', + 'svg' + ); + const nodeB = this.doc.createElementNS( + 'http://www.w3.org/2000/svg', + 'svg' + ); nodeA.setAttribute('height', '50'); nodeB.setAttribute('height', '30'); @@ -754,33 +764,33 @@ describe('toEqual', function() { nodeA.appendChild(rect); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = - 'Expected $.a = ... to equal .'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = + 'Expected $.a = ... to equal .'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports whole DOM node when attribute contains > character', function() { - const nodeA = this.doc.createElement('div'), - nodeB = this.doc.createElement('div'); + const nodeA = this.doc.createElement('div'); + const nodeB = this.doc.createElement('div'); nodeA.setAttribute('thing', '>>>'); nodeB.setAttribute('thing', 'bar'); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = - 'Expected $.a =
to equal
.'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = + 'Expected $.a =
to equal
.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports no content when DOM node has multiple empty text nodes', function() { - const nodeA = this.doc.createElement('div'), - nodeB = this.doc.createElement('div'); + const nodeA = this.doc.createElement('div'); + const nodeB = this.doc.createElement('div'); nodeA.appendChild(this.doc.createTextNode('')); nodeA.appendChild(this.doc.createTextNode('')); @@ -788,85 +798,86 @@ describe('toEqual', function() { nodeA.appendChild(this.doc.createTextNode('')); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = 'Expected $.a =
to equal
.'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = 'Expected $.a =
to equal
.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports content when DOM node has non empty text node', function() { - const nodeA = this.doc.createElement('div'), - nodeB = this.doc.createElement('div'); + const nodeA = this.doc.createElement('div'); + const nodeB = this.doc.createElement('div'); nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!')); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = 'Expected $.a =
...
to equal
.'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = 'Expected $.a =
...
to equal
.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports empty DOM attributes', function() { - const nodeA = this.doc.createElement('div'), - nodeB = this.doc.createElement('div'); + const nodeA = this.doc.createElement('div'); + const nodeB = this.doc.createElement('div'); nodeA.setAttribute('contenteditable', ''); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = 'Expected $.a =
to equal
.'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = 'Expected $.a =
to equal
.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports 0 attr value as non empty DOM attribute', function() { - const nodeA = this.doc.createElement('div'), - nodeB = this.doc.createElement('div'); + const nodeA = this.doc.createElement('div'); + const nodeB = this.doc.createElement('div'); nodeA.setAttribute('contenteditable', 0); expect(nodeA.isEqualNode(nodeB)).toBe(false); - const actual = { a: nodeA }, - expected = { a: nodeB }, - message = 'Expected $.a =
to equal
.'; + const actual = { a: nodeA }; + const expected = { a: nodeB }; + const message = + 'Expected $.a =
to equal
.'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between a DOM node and a bare Object', function() { - const actual = { a: this.doc.createElement('div') }, - expected = { a: {} }, - message = 'Expected $.a =
to equal Object({ }).'; + const actual = { a: this.doc.createElement('div') }; + const expected = { a: {} }; + const message = 'Expected $.a =
to equal Object({ }).'; expect(compareEquals(actual, expected).message).toEqual(message); }); }); it('reports asymmetric mismatches', function() { - const actual = { a: 1 }, - expected = { a: jasmineUnderTest.any(String) }, - message = 'Expected $.a = 1 to equal .'; + const actual = { a: 1 }; + const expected = { a: jasmineUnderTest.any(String) }; + const message = 'Expected $.a = 1 to equal .'; expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).pass).toBe(false); }); it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() { - const actual = { a: jasmineUnderTest.any(String) }, - expected = { a: 1 }, - message = 'Expected $.a = to equal 1.'; + const actual = { a: jasmineUnderTest.any(String) }; + const expected = { a: 1 }; + const message = 'Expected $.a = to equal 1.'; expect(compareEquals(actual, expected).message).toEqual(message); expect(compareEquals(actual, expected).pass).toBe(false); }); it('does not report a mismatch when asymmetric matchers are satisfied', function() { - const actual = { a: 'a' }, - expected = { a: jasmineUnderTest.any(String) }; + const actual = { a: 'a' }; + const expected = { a: jasmineUnderTest.any(String) }; expect(compareEquals(actual, expected).message).toEqual(''); expect(compareEquals(actual, expected).pass).toBe(true); @@ -920,11 +931,10 @@ describe('toEqual', function() { describe('different length arrays', function() { it('actual array is longer', function() { - const actual = [1, 1, 2, 3, 5], - expected = [1, 1, 2, 3], - message = - 'Expected $.length = 5 to equal 4.\n' + - 'Unexpected $[4] = 5 in array.'; + const actual = [1, 1, 2, 3, 5]; + const expected = [1, 1, 2, 3]; + const 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); @@ -937,149 +947,149 @@ describe('toEqual', function() { } } - const actual = [1, 1, 2, 3, 5], - expected = [1, 1, 2, 3], - pp = privateUnderTest.makePrettyPrinter([formatter]), - matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toEqual(matchersUtil), - message = - 'Expected $.length = |5| to equal |4|.\n' + - 'Unexpected $[4] = |5| in array.'; + const actual = [1, 1, 2, 3, 5]; + const expected = [1, 1, 2, 3]; + const pp = privateUnderTest.makePrettyPrinter([formatter]); + const matchersUtil = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toEqual(matchersUtil); + const 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() { - const actual = [1, 1, 2, 3], - expected = [1, 1, 2, 3, 5], - message = - 'Expected $.length = 4 to equal 5.\n' + - 'Expected $[4] = undefined to equal 5.'; + const actual = [1, 1, 2, 3]; + const expected = [1, 1, 2, 3, 5]; + const 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() { - const actual = [1, void 0, 3], - expected = [1, 2, 3], - message = 'Expected $[1] = undefined to equal 2.'; + const actual = [1, void 0, 3]; + const expected = [1, 2, 3]; + const message = 'Expected $[1] = undefined to equal 2.'; expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).message).toEqual(message); }); it('undefined in middle of expected array', function() { - const actual = [1, 2, 3], - expected = [1, void 0, 3], - message = 'Expected $[1] = 2 to equal undefined.'; + const actual = [1, 2, 3]; + const expected = [1, void 0, 3]; + const message = 'Expected $[1] = 2 to equal undefined.'; expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).message).toEqual(message); }); it('actual array is longer by 4 elements', function() { - const actual = [1, 1, 2, 3, 5, 8, 13], - expected = [1, 1, 2], - 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' + - 'Unexpected $[6] = 13 in array.'; + const actual = [1, 1, 2, 3, 5, 8, 13]; + const expected = [1, 1, 2]; + const 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' + + 'Unexpected $[6] = 13 in array.'; expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).message).toEqual(message); }); it('expected array is longer by 4 elements', function() { - const actual = [1, 1, 2], - expected = [1, 1, 2, 3, 5, 8, 13], - 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' + - 'Expected $[6] = undefined to equal 13.'; + const actual = [1, 1, 2]; + const expected = [1, 1, 2, 3, 5, 8, 13]; + const 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' + + 'Expected $[6] = undefined to equal 13.'; expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).message).toEqual(message); }); it('different length and different elements', function() { - const actual = [1], - expected = [2, 3], - message = - 'Expected $.length = 1 to equal 2.\n' + - 'Expected $[0] = 1 to equal 2.\n' + - 'Expected $[1] = undefined to equal 3.'; + const actual = [1]; + const expected = [2, 3]; + const message = + 'Expected $.length = 1 to equal 2.\n' + + 'Expected $[0] = 1 to equal 2.\n' + + 'Expected $[1] = undefined to equal 3.'; expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).message).toEqual(message); }); it('object with nested array (actual longer than expected)', function() { - const actual = { values: [1, 1, 2, 3] }, - expected = { values: [1, 1, 2] }, - message = - 'Expected $.values.length = 4 to equal 3.\n' + - 'Unexpected $.values[3] = 3 in array.'; + const actual = { values: [1, 1, 2, 3] }; + const expected = { values: [1, 1, 2] }; + const 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() { - const actual = { values: [1, 1, 2] }, - expected = { values: [1, 1, 2, 3] }, - message = - 'Expected $.values.length = 3 to equal 4.\n' + - 'Expected $.values[3] = undefined to equal 3.'; + const actual = { values: [1, 1, 2] }; + const expected = { values: [1, 1, 2, 3] }; + const 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() { - const actual = [1, 1, 2, { value: 3 }], - expected = [1, 1, 2], - message = - 'Expected $.length = 4 to equal 3.\n' + - 'Unexpected $[3] = Object({ value: 3 }) in array.'; + const actual = [1, 1, 2, { value: 3 }]; + const expected = [1, 1, 2]; + const 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() { - const actual = [1, 1, 2], - expected = [1, 1, 2, { value: 3 }], - message = - 'Expected $.length = 3 to equal 4.\n' + - 'Expected $[3] = undefined to equal Object({ value: 3 }).'; + const actual = [1, 1, 2]; + const expected = [1, 1, 2, { value: 3 }]; + const 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() { - const actual = [[1], [1, 2]], - expected = [[1, 1], [2]], - 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' + - 'Unexpected $[1][1] = 2 in array.'; + const actual = [[1], [1, 2]]; + const expected = [[1, 1], [2]]; + const 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' + + 'Unexpected $[1][1] = 2 in array.'; expect(compareEquals(actual, expected).pass).toBe(false); expect(compareEquals(actual, expected).message).toEqual(message); }); it('last element of longer array is undefined', function() { - const actual = [1, 2], - expected = [1, 2, void 0], - message = 'Expected $.length = 2 to equal 3.'; + const actual = [1, 2]; + const expected = [1, 2, void 0]; + const message = 'Expected $.length = 2 to equal 3.'; 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 d620a837..3f4875d0 100644 --- a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +++ b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js @@ -1,10 +1,10 @@ describe('toHaveBeenCalledBefore', function() { it('throws an exception when the actual is not a spy', function() { const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() {}, - spy = new privateUnderTest.Env().createSpy('a spy'); + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() {}; + const spy = new privateUnderTest.Env().createSpy('a spy'); expect(function() { matcher.compare(fn, spy); @@ -13,10 +13,10 @@ describe('toHaveBeenCalledBefore', function() { it('throws an exception when the expected is not a spy', function() { const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore({ - pp: privateUnderTest.makePrettyPrinter() - }), - spy = new privateUnderTest.Env().createSpy('a spy'), - fn = function() {}; + pp: privateUnderTest.makePrettyPrinter() + }); + const spy = new privateUnderTest.Env().createSpy('a spy'); + const fn = function() {}; expect(function() { matcher.compare(spy, fn); @@ -24,9 +24,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual was not called', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); secondSpy(); @@ -38,9 +38,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the expected was not called', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); @@ -52,9 +52,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual is called after the expected', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); secondSpy(); firstSpy(); @@ -67,9 +67,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual is called before and after the expected', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); secondSpy(); @@ -83,9 +83,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the expected is called before and after the actual', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); secondSpy(); firstSpy(); @@ -99,9 +99,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('passes when the actual is called before the expected', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); secondSpy(); @@ -114,9 +114,9 @@ describe('toHaveBeenCalledBefore', function() { }); it('set the correct calls as verified when passing', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(), - firstSpy = new privateUnderTest.Spy('first spy'), - secondSpy = new privateUnderTest.Spy('second spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledBefore(); + const firstSpy = new privateUnderTest.Spy('first spy'); + const secondSpy = new privateUnderTest.Spy('second spy'); firstSpy(); secondSpy(); diff --git a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js index d6aa854f..c3cd44fe 100644 --- a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js @@ -1,9 +1,9 @@ describe('toHaveBeenCalledOnceWith', function() { it('passes when the actual was called only once and with matching parameters', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new privateUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -16,17 +16,17 @@ describe('toHaveBeenCalledOnceWith', function() { it('supports custom equality testers', function() { const customEqualityTesters = [ - function() { - return true; - } - ], - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: customEqualityTesters - }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith( - matchersUtil - ), - calledSpy = new privateUnderTest.Spy('called-spy'); + function() { + return true; + } + ]; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: customEqualityTesters + }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith( + matchersUtil + ); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'a'); @@ -35,10 +35,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was never called', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new privateUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const calledSpy = new privateUnderTest.Spy('called-spy'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -49,10 +49,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called once with different parameters', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new privateUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'c'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -64,10 +64,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called multiple times with expected parameters', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new privateUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); calledSpy('a', 'b'); @@ -80,10 +80,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called multiple times (one of them - with expected parameters)', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new privateUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); calledSpy('a', 'c'); @@ -96,10 +96,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('throws an exception when the actual is not a spy', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - fn = function() {}; + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const fn = function() {}; expect(function() { matcher.compare(fn); @@ -107,10 +107,10 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('set the correct calls as verified when passing', function() { - const pp = privateUnderTest.makePrettyPrinter(), - util = new privateUnderTest.MatchersUtil({ pp: pp }), - matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new privateUnderTest.Spy('called-spy'); + const pp = privateUnderTest.makePrettyPrinter(); + const util = new privateUnderTest.MatchersUtil({ pp: pp }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledOnceWith(util); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('x'); diff --git a/spec/core/matchers/toHaveBeenCalledSpec.js b/spec/core/matchers/toHaveBeenCalledSpec.js index 93b72be3..0ade4c8c 100644 --- a/spec/core/matchers/toHaveBeenCalledSpec.js +++ b/spec/core/matchers/toHaveBeenCalledSpec.js @@ -1,7 +1,7 @@ describe('toHaveBeenCalled', function() { it('passes when the actual was called, with a custom .not fail message', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalled(), - calledSpy = new privateUnderTest.Spy('called-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy(); @@ -13,8 +13,8 @@ describe('toHaveBeenCalled', function() { }); it('fails when the actual was not called', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalled(), - uncalledSpy = new privateUnderTest.Spy('uncalled spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(); + const uncalledSpy = new privateUnderTest.Spy('uncalled spy'); const result = matcher.compare(uncalledSpy); expect(result.pass).toBe(false); @@ -22,9 +22,9 @@ describe('toHaveBeenCalled', function() { it('throws an exception when the actual is not a spy', function() { const matcher = privateUnderTest.matchers.toHaveBeenCalled({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() {}; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() {}; expect(function() { matcher.compare(fn); @@ -32,8 +32,8 @@ describe('toHaveBeenCalled', function() { }); it('throws an exception when invoked with any arguments', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalled(), - spy = new privateUnderTest.Spy('sample spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(); + const spy = new privateUnderTest.Spy('sample spy'); expect(function() { matcher.compare(spy, 'foo'); @@ -41,8 +41,8 @@ describe('toHaveBeenCalled', function() { }); it('has a custom message on failure', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalled(), - spy = new privateUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(); + const spy = new privateUnderTest.Spy('sample-spy'); const result = matcher.compare(spy); @@ -52,8 +52,8 @@ describe('toHaveBeenCalled', function() { }); it('set the correct calls as verified when passing', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalled(), - spy = new privateUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalled(); + const spy = new privateUnderTest.Spy('sample-spy'); spy(); diff --git a/spec/core/matchers/toHaveBeenCalledTimesSpec.js b/spec/core/matchers/toHaveBeenCalledTimesSpec.js index 7935d540..ee6df13b 100644 --- a/spec/core/matchers/toHaveBeenCalledTimesSpec.js +++ b/spec/core/matchers/toHaveBeenCalledTimesSpec.js @@ -1,13 +1,13 @@ describe('toHaveBeenCalledTimes', function() { it('passes when the actual 0 matches the expected 0 ', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - calledSpy = new privateUnderTest.Spy('called-spy'), - result = matcher.compare(calledSpy, 0); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const calledSpy = new privateUnderTest.Spy('called-spy'); + const result = matcher.compare(calledSpy, 0); expect(result.pass).toBeTruthy(); }); it('passes when the actual matches the expected', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - calledSpy = new privateUnderTest.Spy('called-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy(); const result = matcher.compare(calledSpy, 1); @@ -15,8 +15,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('fails when expected numbers is not supplied', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new privateUnderTest.Spy('spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const spy = new privateUnderTest.Spy('spy'); spy(); expect(function() { @@ -27,16 +27,16 @@ describe('toHaveBeenCalledTimes', function() { }); it('fails when the actual was called less than the expected', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - uncalledSpy = new privateUnderTest.Spy('uncalled spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const uncalledSpy = new privateUnderTest.Spy('uncalled spy'); const result = matcher.compare(uncalledSpy, 2); expect(result.pass).toBe(false); }); it('fails when the actual was called more than expected', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - uncalledSpy = new privateUnderTest.Spy('uncalled spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const uncalledSpy = new privateUnderTest.Spy('uncalled spy'); uncalledSpy(); uncalledSpy(); @@ -47,9 +47,9 @@ describe('toHaveBeenCalledTimes', function() { it('throws an exception when the actual is not a spy', function() { const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() {}; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() {}; expect(function() { matcher.compare(fn); @@ -57,8 +57,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('has a custom message on failure that tells it was called only once', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new privateUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const spy = new privateUnderTest.Spy('sample-spy'); spy(); spy(); spy(); @@ -73,8 +73,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('has a custom message on failure that tells how many times it was called', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new privateUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const spy = new privateUnderTest.Spy('sample-spy'); spy(); spy(); spy(); @@ -89,8 +89,8 @@ describe('toHaveBeenCalledTimes', function() { }); it('set the correct calls as verified when passing', function() { - const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new privateUnderTest.Spy('sample-spy'); + const matcher = privateUnderTest.matchers.toHaveBeenCalledTimes(); + const spy = new privateUnderTest.Spy('sample-spy'); spy(); spy(); diff --git a/spec/core/matchers/toHaveBeenCalledWithSpec.js b/spec/core/matchers/toHaveBeenCalledWithSpec.js index e1ee60e1..0b9ca7d6 100644 --- a/spec/core/matchers/toHaveBeenCalledWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledWithSpec.js @@ -1,12 +1,14 @@ describe('toHaveBeenCalledWith', function() { it('passes when the actual was called with matching parameters', function() { const matchersUtil = { - contains: jasmine.createSpy('delegated-contains').and.returnValue(true), - equals: jasmine.createSpy('delegated-equals').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new privateUnderTest.Spy('called-spy'); + contains: jasmine.createSpy('delegated-contains').and.returnValue(true), + equals: jasmine.createSpy('delegated-equals').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toHaveBeenCalledWith( + matchersUtil + ); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -19,15 +21,17 @@ describe('toHaveBeenCalledWith', function() { it('supports custom equality testers', function() { const customEqualityTesters = [ - function() { - return true; - } - ], - matchersUtil = new privateUnderTest.MatchersUtil({ - customTesters: customEqualityTesters - }), - matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new privateUnderTest.Spy('called-spy'); + function() { + return true; + } + ]; + const matchersUtil = new privateUnderTest.MatchersUtil({ + customTesters: customEqualityTesters + }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledWith( + matchersUtil + ); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); const result = matcher.compare(calledSpy, 'a', 'b'); @@ -36,13 +40,13 @@ describe('toHaveBeenCalledWith', function() { it('fails when the actual was not called', function() { const matchersUtil = { - contains: jasmine - .createSpy('delegated-contains') - .and.returnValue(false), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - uncalledSpy = new privateUnderTest.Spy('uncalled spy'); + contains: jasmine.createSpy('delegated-contains').and.returnValue(false), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toHaveBeenCalledWith( + matchersUtil + ); + const uncalledSpy = new privateUnderTest.Spy('uncalled spy'); const result = matcher.compare(uncalledSpy); expect(result.pass).toBe(false); @@ -53,10 +57,12 @@ describe('toHaveBeenCalledWith', function() { it('fails when the actual was called with different parameters', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new privateUnderTest.Spy('called spy'); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toHaveBeenCalledWith( + matchersUtil + ); + const calledSpy = new privateUnderTest.Spy('called spy'); calledSpy('a'); calledSpy('c', 'd'); @@ -85,9 +91,9 @@ describe('toHaveBeenCalledWith', function() { it('throws an exception when the actual is not a spy', function() { const matcher = privateUnderTest.matchers.toHaveBeenCalledWith({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() {}; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() {}; expect(function() { matcher.compare(fn); @@ -96,12 +102,14 @@ describe('toHaveBeenCalledWith', function() { it('set the correct calls as verified when passing', function() { const matchersUtil = { - contains: jasmine.createSpy('delegated-contains').and.returnValue(true), - equals: jasmine.createSpy('delegated-equals').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new privateUnderTest.Spy('called-spy'); + contains: jasmine.createSpy('delegated-contains').and.returnValue(true), + equals: jasmine.createSpy('delegated-equals').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toHaveBeenCalledWith( + matchersUtil + ); + const calledSpy = new privateUnderTest.Spy('called-spy'); calledSpy('a', 'b'); matcher.compare(calledSpy, 'a', 'b'); diff --git a/spec/core/matchers/toHaveClassSpec.js b/spec/core/matchers/toHaveClassSpec.js index 0c9c566d..c61488b4 100644 --- a/spec/core/matchers/toHaveClassSpec.js +++ b/spec/core/matchers/toHaveClassSpec.js @@ -1,17 +1,17 @@ describe('toHaveClass', function() { it('fails for a DOM element that lacks the expected class', function() { - const matcher = privateUnderTest.matchers.toHaveClass(), - result = matcher.compare( - specHelpers.domHelpers.createElementWithClassName(''), - 'foo' - ); + const matcher = privateUnderTest.matchers.toHaveClass(); + const result = matcher.compare( + specHelpers.domHelpers.createElementWithClassName(''), + 'foo' + ); expect(result.pass).toBe(false); }); it('passes for a DOM element that has the expected class', function() { - const matcher = privateUnderTest.matchers.toHaveClass(), - el = specHelpers.domHelpers.createElementWithClassName('foo bar baz'); + const matcher = privateUnderTest.matchers.toHaveClass(); + const el = specHelpers.domHelpers.createElementWithClassName('foo bar baz'); expect(matcher.compare(el, 'foo').pass).toBe(true); expect(matcher.compare(el, 'bar').pass).toBe(true); @@ -19,8 +19,8 @@ describe('toHaveClass', function() { }); it('fails for a DOM element that only has other classes', function() { - const matcher = privateUnderTest.matchers.toHaveClass(), - el = specHelpers.domHelpers.createElementWithClassName('foo bar'); + const matcher = privateUnderTest.matchers.toHaveClass(); + const el = specHelpers.domHelpers.createElementWithClassName('foo bar'); expect(matcher.compare(el, 'fo').pass).toBe(false); }); diff --git a/spec/core/matchers/toHaveClassesSpec.js b/spec/core/matchers/toHaveClassesSpec.js index e31e6ad0..d0751a95 100644 --- a/spec/core/matchers/toHaveClassesSpec.js +++ b/spec/core/matchers/toHaveClassesSpec.js @@ -1,24 +1,24 @@ describe('toHaveClasses', function() { it('fails for a DOM element that lacks all the expected classes', function() { - const matcher = privateUnderTest.matchers.toHaveClasses(), - result = matcher.compare( - specHelpers.domHelpers.createElementWithClassName(''), - ['foo', 'bar'] - ); + const matcher = privateUnderTest.matchers.toHaveClasses(); + const result = matcher.compare( + specHelpers.domHelpers.createElementWithClassName(''), + ['foo', 'bar'] + ); expect(result.pass).toBe(false); }); it('passes for a DOM element that has all the expected classes', function() { - const matcher = privateUnderTest.matchers.toHaveClasses(), - el = specHelpers.domHelpers.createElementWithClassName('foo bar baz'); + const matcher = privateUnderTest.matchers.toHaveClasses(); + const el = specHelpers.domHelpers.createElementWithClassName('foo bar baz'); expect(matcher.compare(el, ['foo', 'bar']).pass).toBe(true); }); it('fails for a DOM element that only has some matching classes', function() { - const matcher = privateUnderTest.matchers.toHaveClasses(), - el = specHelpers.domHelpers.createElementWithClassName('foo bar'); + const matcher = privateUnderTest.matchers.toHaveClasses(); + const el = specHelpers.domHelpers.createElementWithClassName('foo bar'); expect(matcher.compare(el, ['foo', 'can']).pass).toBe(false); }); diff --git a/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js b/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js index 96cc916e..ab3b822c 100644 --- a/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js +++ b/spec/core/matchers/toHaveNoOtherSpyInteractionsSpec.js @@ -130,17 +130,17 @@ describe('toHaveNoOtherSpyInteractions', function() { it('handles multiple interactions with a single spy', function() { const matchersUtil = new privateUnderTest.MatchersUtil({ - pp: privateUnderTest.makePrettyPrinter() - }), - matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions( - matchersUtil - ), - toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith( - matchersUtil - ), - spyObj = jasmineUnderTest - .getEnv() - .createSpyObj('NewClass', ['spyA', 'spyB']); + pp: privateUnderTest.makePrettyPrinter() + }); + const matcher = privateUnderTest.matchers.toHaveNoOtherSpyInteractions( + matchersUtil + ); + const toHaveBeenCalledWithMatcher = privateUnderTest.matchers.toHaveBeenCalledWith( + matchersUtil + ); + const spyObj = jasmineUnderTest + .getEnv() + .createSpyObj('NewClass', ['spyA', 'spyB']); spyObj.spyA('x'); spyObj.spyA('y'); diff --git a/spec/core/matchers/toHaveSizeSpec.js b/spec/core/matchers/toHaveSizeSpec.js index 0fddaa72..ad5540de 100644 --- a/spec/core/matchers/toHaveSizeSpec.js +++ b/spec/core/matchers/toHaveSizeSpec.js @@ -2,24 +2,24 @@ describe('toHaveSize', function() { 'use strict'; it('passes for an array whose length matches', function() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare([1, 2], 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare([1, 2], 2); expect(result.pass).toBe(true); }); it('fails for an array whose length does not match', function() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare([1, 2, 3], 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare([1, 2, 3], 2); expect(result.pass).toBe(false); }); it('informs about the size of an array whose length does not match', function() { const matcher = privateUnderTest.matchers.toHaveSize({ - pp: privateUnderTest.makePrettyPrinter() - }), - result = matcher.compare([1, 2, 3], 2); + pp: privateUnderTest.makePrettyPrinter() + }); + const result = matcher.compare([1, 2, 3], 2); expect(result.message()).toEqual( 'Expected [ 1, 2, 3 ] with size 3 to have size 2.' @@ -27,43 +27,43 @@ describe('toHaveSize', function() { }); it('passes for an object with the proper number of keys', function() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare({ a: 1, b: 2 }, 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const 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() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare({ a: 1, b: 2 }, 1); + const matcher = privateUnderTest.matchers.toHaveSize(); + const 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() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare({ a: 1, b: 2, length: 5 }, 5); + const matcher = privateUnderTest.matchers.toHaveSize(); + const 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() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare({ a: 1, b: 2, length: 5 }, 1); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare({ a: 1, b: 2, length: 5 }, 1); expect(result.pass).toBe(false); }); it('passes for a string whose length matches', function() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare('ab', 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare('ab', 2); expect(result.pass).toBe(true); }); it('fails for a string whose length does not match', function() { - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare('abc', 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare('abc', 2); expect(result.pass).toBe(false); }); @@ -73,8 +73,8 @@ describe('toHaveSize', function() { map.set('a', 1); map.set('b', 2); - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare(map, 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare(map, 2); expect(result.pass).toBe(true); }); @@ -84,8 +84,8 @@ describe('toHaveSize', function() { map.set('a', 1); map.set('b', 2); - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare(map, 1); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare(map, 1); expect(result.pass).toBe(false); }); @@ -95,8 +95,8 @@ describe('toHaveSize', function() { set.add('a'); set.add('b'); - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare(set, 2); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare(set, 2); expect(result.pass).toBe(true); }); @@ -106,8 +106,8 @@ describe('toHaveSize', function() { set.add('a'); set.add('b'); - const matcher = privateUnderTest.matchers.toHaveSize(), - result = matcher.compare(set, 1); + const matcher = privateUnderTest.matchers.toHaveSize(); + const result = matcher.compare(set, 1); expect(result.pass).toBe(false); }); diff --git a/spec/core/matchers/toThrowErrorSpec.js b/spec/core/matchers/toThrowErrorSpec.js index 6ba2edda..2a8fe369 100644 --- a/spec/core/matchers/toThrowErrorSpec.js +++ b/spec/core/matchers/toThrowErrorSpec.js @@ -8,10 +8,10 @@ describe('toThrowError', function() { }); it('throws an error when the expected is not an Error, string, or RegExp', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - throw new Error('foo'); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + throw new Error('foo'); + }; expect(function() { matcher.compare(fn, 1); @@ -19,10 +19,10 @@ describe('toThrowError', function() { }); it('throws an error when the expected error type is not an Error', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - throw new Error('foo'); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + throw new Error('foo'); + }; expect(function() { matcher.compare(fn, void 0, 'foo'); @@ -30,10 +30,10 @@ describe('toThrowError', function() { }); it('throws an error when the expected error message is not a string or RegExp', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - throw new Error('foo'); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + throw new Error('foo'); + }; expect(function() { matcher.compare(fn, Error, 1); @@ -41,10 +41,10 @@ describe('toThrowError', function() { }); it('fails if actual does not throw at all', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - return true; - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + return true; + }; const result = matcher.compare(fn); @@ -54,11 +54,11 @@ describe('toThrowError', function() { it('fails if thrown is not an instanceof Error', function() { const matcher = privateUnderTest.matchers.toThrowError({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw 4; - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw 4; + }; const result = matcher.compare(fn); expect(result.pass).toBe(false); @@ -104,11 +104,11 @@ describe('toThrowError', function() { it('fails with the correct message if thrown is a falsy value', function() { const matcher = privateUnderTest.matchers.toThrowError({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw undefined; - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw undefined; + }; const result = matcher.compare(fn); expect(result.pass).toBe(false); @@ -118,10 +118,10 @@ describe('toThrowError', function() { }); it('passes if thrown is a type of Error, but there is no expected error', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - throw new TypeError(); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + throw new TypeError(); + }; const result = matcher.compare(fn); @@ -133,11 +133,11 @@ describe('toThrowError', function() { it('passes if thrown is an Error and the expected is the same message', function() { const matcher = privateUnderTest.matchers.toThrowError({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw new Error('foo'); - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw new Error('foo'); + }; const result = matcher.compare(fn, 'foo'); @@ -149,11 +149,11 @@ describe('toThrowError', function() { it('fails if thrown is an Error and the expected is not the same message', function() { const matcher = privateUnderTest.matchers.toThrowError({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw new Error('foo'); - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw new Error('foo'); + }; const result = matcher.compare(fn, 'bar'); @@ -165,11 +165,11 @@ describe('toThrowError', function() { it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() { const matcher = privateUnderTest.matchers.toThrowError({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw new Error('a long message'); - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw new Error('a long message'); + }; const result = matcher.compare(fn, /long/); @@ -181,11 +181,11 @@ describe('toThrowError', function() { it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() { const matcher = privateUnderTest.matchers.toThrowError({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw new Error('a long message'); - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw new Error('a long message'); + }; const result = matcher.compare(fn, /foo/); @@ -196,10 +196,10 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected the same Error', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - throw new Error(); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + throw new Error(); + }; const result = matcher.compare(fn, Error); @@ -208,13 +208,13 @@ describe('toThrowError', function() { }); it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - CustomError = function CustomError(arg) { - arg.x; - }, - fn = function() { - throw new CustomError({ x: 1 }); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const CustomError = function CustomError(arg) { + arg.x; + }; + const fn = function() { + throw new CustomError({ x: 1 }); + }; CustomError.prototype = new Error(); @@ -227,10 +227,10 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is a different Error', function() { - const matcher = privateUnderTest.matchers.toThrowError(), - fn = function() { - throw new Error(); - }; + const matcher = privateUnderTest.matchers.toThrowError(); + const fn = function() { + throw new Error(); + }; const result = matcher.compare(fn, TypeError); @@ -242,13 +242,13 @@ describe('toThrowError', function() { it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrowError(matchersUtil), - fn = function() { - throw new TypeError('foo'); - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrowError(matchersUtil); + const fn = function() { + throw new TypeError('foo'); + }; const result = matcher.compare(fn, TypeError, 'foo'); @@ -260,16 +260,16 @@ describe('toThrowError', function() { it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrowError(matchersUtil), - CustomError = function CustomError(arg) { - this.message = arg.message; - }, - fn = function() { - throw new CustomError({ message: 'foo' }); - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrowError(matchersUtil); + const CustomError = function CustomError(arg) { + this.message = arg.message; + }; + const fn = function() { + throw new CustomError({ message: 'foo' }); + }; CustomError.prototype = new Error(); @@ -284,13 +284,13 @@ describe('toThrowError', function() { describe('with a string', function() { it('fails if thrown is a type of Error and the expected is a different Error', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrowError(matchersUtil), - fn = function() { - throw new TypeError('foo'); - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(false), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrowError(matchersUtil); + const fn = function() { + throw new TypeError('foo'); + }; const result = matcher.compare(fn, TypeError, 'bar'); @@ -304,13 +304,13 @@ describe('toThrowError', function() { describe('with a regex', function() { it('fails if thrown is a type of Error and the expected is a different Error', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrowError(matchersUtil), - fn = function() { - throw new TypeError('foo'); - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(false), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrowError(matchersUtil); + const fn = function() { + throw new TypeError('foo'); + }; const result = matcher.compare(fn, TypeError, /bar/); @@ -323,13 +323,13 @@ describe('toThrowError', function() { it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrowError(matchersUtil), - fn = function() { - throw new TypeError('foo'); - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrowError(matchersUtil); + const fn = function() { + throw new TypeError('foo'); + }; const result = matcher.compare(fn, TypeError, /foo/); diff --git a/spec/core/matchers/toThrowMatchingSpec.js b/spec/core/matchers/toThrowMatchingSpec.js index 7bfa8821..f2f00f55 100644 --- a/spec/core/matchers/toThrowMatchingSpec.js +++ b/spec/core/matchers/toThrowMatchingSpec.js @@ -10,10 +10,10 @@ describe('toThrowMatching', function() { }); it('throws an error when the expected is not a function', function() { - const matcher = privateUnderTest.matchers.toThrowMatching(), - fn = function() { - throw new Error('foo'); - }; + const matcher = privateUnderTest.matchers.toThrowMatching(); + const fn = function() { + throw new Error('foo'); + }; expect(function() { matcher.compare(fn, 1); @@ -21,10 +21,10 @@ describe('toThrowMatching', function() { }); it('fails if actual does not throw at all', function() { - const matcher = privateUnderTest.matchers.toThrowMatching(), - fn = function() { - return true; - }; + const matcher = privateUnderTest.matchers.toThrowMatching(); + const fn = function() { + return true; + }; const result = matcher.compare(fn, function() { return true; @@ -36,11 +36,11 @@ describe('toThrowMatching', function() { it('fails with the correct message if thrown is a falsy value', function() { const matcher = privateUnderTest.matchers.toThrowMatching({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw undefined; - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw undefined; + }; const result = matcher.compare(fn, function() { return false; @@ -52,13 +52,13 @@ describe('toThrowMatching', function() { }); it('passes if the argument is a function that returns true when called with the error', function() { - const matcher = privateUnderTest.matchers.toThrowMatching(), - predicate = function(e) { - return e.message === 'nope'; - }, - fn = function() { - throw new TypeError('nope'); - }; + const matcher = privateUnderTest.matchers.toThrowMatching(); + const predicate = function(e) { + return e.message === 'nope'; + }; + const fn = function() { + throw new TypeError('nope'); + }; const result = matcher.compare(fn, predicate); @@ -70,14 +70,14 @@ describe('toThrowMatching', function() { it('fails if the argument is a function that returns false when called with the error', function() { const matcher = privateUnderTest.matchers.toThrowMatching({ - pp: privateUnderTest.makePrettyPrinter() - }), - predicate = function(e) { - return e.message === 'oh no'; - }, - fn = function() { - throw new TypeError('nope'); - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const predicate = function(e) { + return e.message === 'oh no'; + }; + const fn = function() { + throw new TypeError('nope'); + }; const result = matcher.compare(fn, predicate); diff --git a/spec/core/matchers/toThrowSpec.js b/spec/core/matchers/toThrowSpec.js index 386a9dcc..81f47f32 100644 --- a/spec/core/matchers/toThrowSpec.js +++ b/spec/core/matchers/toThrowSpec.js @@ -9,10 +9,10 @@ describe('toThrow', function() { }); it('fails if actual does not throw', function() { - const matcher = privateUnderTest.matchers.toThrow(), - fn = function() { - return true; - }; + const matcher = privateUnderTest.matchers.toThrow(); + const fn = function() { + return true; + }; const result = matcher.compare(fn); @@ -22,13 +22,13 @@ describe('toThrow', function() { it('passes if it throws but there is no expected', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrow(matchersUtil), - fn = function() { - throw 5; - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrow(matchersUtil); + const fn = function() { + throw 5; + }; const result = matcher.compare(fn); @@ -40,11 +40,11 @@ describe('toThrow', function() { it('passes even if what is thrown is falsy', function() { const matcher = privateUnderTest.matchers.toThrow({ - pp: privateUnderTest.makePrettyPrinter() - }), - fn = function() { - throw undefined; - }; + pp: privateUnderTest.makePrettyPrinter() + }); + const fn = function() { + throw undefined; + }; const result = matcher.compare(fn); expect(result.pass).toBe(true); @@ -55,13 +55,13 @@ describe('toThrow', function() { it('passes if what is thrown is equivalent to what is expected', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(true), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrow(matchersUtil), - fn = function() { - throw 5; - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(true), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrow(matchersUtil); + const fn = function() { + throw 5; + }; const result = matcher.compare(fn, 5); @@ -71,13 +71,13 @@ describe('toThrow', function() { it('fails if what is thrown is not equivalent to what is expected', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrow(matchersUtil), - fn = function() { - throw 5; - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(false), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrow(matchersUtil); + const fn = function() { + throw 5; + }; const result = matcher.compare(fn, 'foo'); @@ -89,13 +89,13 @@ describe('toThrow', function() { it('fails if what is thrown is not equivalent to undefined', function() { const matchersUtil = { - equals: jasmine.createSpy('delegated-equal').and.returnValue(false), - pp: privateUnderTest.makePrettyPrinter() - }, - matcher = privateUnderTest.matchers.toThrow(matchersUtil), - fn = function() { - throw 5; - }; + equals: jasmine.createSpy('delegated-equal').and.returnValue(false), + pp: privateUnderTest.makePrettyPrinter() + }; + const matcher = privateUnderTest.matchers.toThrow(matchersUtil); + const fn = function() { + throw 5; + }; const result = matcher.compare(fn, void 0); diff --git a/spec/helpers/integrationMatchers.js b/spec/helpers/integrationMatchers.js index 76254bf6..4e3e112d 100644 --- a/spec/helpers/integrationMatchers.js +++ b/spec/helpers/integrationMatchers.js @@ -4,9 +4,10 @@ toHaveFailedExpectationsForRunnable: function() { return { compare: function(actual, fullName, expectedFailures) { - let foundRunnable = false, - expectations = true, - foundFailures = []; + let foundRunnable = false; + let expectations = true; + let foundFailures = []; + for (let i = 0; i < actual.calls.count(); i++) { const args = actual.calls.argsFor(i)[0]; diff --git a/spec/helpers/nodeDefineJasmineUnderTest.js b/spec/helpers/nodeDefineJasmineUnderTest.js index ca9382bf..8dbc84da 100644 --- a/spec/helpers/nodeDefineJasmineUnderTest.js +++ b/spec/helpers/nodeDefineJasmineUnderTest.js @@ -1,6 +1,6 @@ (function() { - const path = require('path'), - glob = require('glob'); + const path = require('path'); + const glob = require('glob'); const jasmineUnderTestRequire = require(path.join( __dirname, diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js index 11627c87..36832dad 100644 --- a/spec/html/HtmlReporterSpec.js +++ b/spec/html/HtmlReporterSpec.js @@ -14,14 +14,14 @@ describe('HtmlReporter', function() { }); it('emits a deprecation warning', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); expect(deprecator.addDeprecationWarning).toHaveBeenCalledWith( @@ -32,14 +32,14 @@ describe('HtmlReporter', function() { }); it('builds the initial DOM elements, including the title banner', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); // Main top-level elements @@ -62,14 +62,14 @@ describe('HtmlReporter', function() { }); it('builds a single reporter even if initialized multiple times', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.initialize(); reporter.initialize(); @@ -130,14 +130,14 @@ describe('HtmlReporter', function() { }); it('reports the status symbol of a excluded spec', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.specDone({ id: 789, @@ -156,14 +156,14 @@ describe('HtmlReporter', function() { }); it('reports the status symbol of a pending spec', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.specDone({ @@ -179,14 +179,14 @@ describe('HtmlReporter', function() { }); it('reports the status symbol of a passing spec', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.specDone({ @@ -203,14 +203,14 @@ describe('HtmlReporter', function() { }); it('reports the status symbol of a failing spec', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -229,14 +229,14 @@ describe('HtmlReporter', function() { describe('when there are deprecation warnings', function() { it('displays the messages in their own alert bars', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -278,14 +278,14 @@ describe('HtmlReporter', function() { }); it('displays expandable stack traces', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -322,14 +322,14 @@ describe('HtmlReporter', function() { }); it('omits the expander when there is no stack trace', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -349,14 +349,14 @@ describe('HtmlReporter', function() { }); it('nicely formats the verboseDeprecations note', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -384,14 +384,14 @@ describe('HtmlReporter', function() { if (!window.console) { window.console = { error: function() {} }; } - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); spyOn(console, 'error'); @@ -422,14 +422,14 @@ describe('HtmlReporter', function() { }); it('reports the run time', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -444,17 +444,17 @@ describe('HtmlReporter', function() { }); it('reports the suite names with status, and spec names with status and duration', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer, - addToExistingQueryString: function(key, value) { - return '?foo=bar&' + key + '=' + value; - } - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer, + addToExistingQueryString: function(key, value) { + return '?foo=bar&' + key + '=' + value; + } + }); reporter.initialize(); reporter.jasmineStarted({}); @@ -561,24 +561,24 @@ describe('HtmlReporter', function() { }); it('has an options menu', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineDone({}); const trigger = container.querySelector( - '.jasmine-run-options .jasmine-trigger' - ), - payload = container.querySelector( - '.jasmine-run-options .jasmine-payload' - ); + '.jasmine-run-options .jasmine-trigger' + ); + const payload = container.querySelector( + '.jasmine-run-options .jasmine-payload' + ); expect(payload).not.toHaveClass('jasmine-open'); @@ -593,14 +593,14 @@ describe('HtmlReporter', function() { describe('when there are global errors', function() { it('displays the exceptions in their own alert bars', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -671,14 +671,14 @@ describe('HtmlReporter', function() { }); it('displays file and line information if available', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -707,14 +707,14 @@ describe('HtmlReporter', function() { describe('UI for stop on spec failure', function() { it('should be unchecked for full execution', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineDone({}); @@ -724,14 +724,14 @@ describe('HtmlReporter', function() { }); it('should be checked if stopping short', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); env.configure({ stopOnSpecFailure: true }); @@ -743,16 +743,16 @@ describe('HtmlReporter', function() { }); it('should navigate and turn the setting on', function() { - const container = document.createElement('div'), - navigationHandler = jasmine.createSpy('navigate'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - navigateWithNewParam: navigationHandler, - getContainer: getContainer - }); + const container = document.createElement('div'); + const navigationHandler = jasmine.createSpy('navigate'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + navigateWithNewParam: navigationHandler, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineDone({}); @@ -767,16 +767,16 @@ describe('HtmlReporter', function() { }); it('should navigate and turn the setting off', function() { - const container = document.createElement('div'), - navigationHandler = jasmine.createSpy('navigate'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - navigateWithNewParam: navigationHandler, - getContainer: getContainer - }); + const container = document.createElement('div'); + const navigationHandler = jasmine.createSpy('navigate'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + navigateWithNewParam: navigationHandler, + getContainer: getContainer + }); env.configure({ stopOnSpecFailure: true }); @@ -795,14 +795,14 @@ describe('HtmlReporter', function() { describe('UI for throwing errors on expectation failures', function() { it('should be unchecked if not throwing', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineDone({}); @@ -814,14 +814,14 @@ describe('HtmlReporter', function() { }); it('should be checked if throwing', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); env.configure({ stopSpecOnExpectationFailure: true }); @@ -835,16 +835,16 @@ describe('HtmlReporter', function() { }); it('should navigate and change the setting to on', function() { - const container = document.createElement('div'), - navigateHandler = jasmine.createSpy('navigate'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer, - navigateWithNewParam: navigateHandler - }); + const container = document.createElement('div'); + const navigateHandler = jasmine.createSpy('navigate'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer, + navigateWithNewParam: navigateHandler + }); reporter.initialize(); reporter.jasmineDone({}); @@ -861,16 +861,16 @@ describe('HtmlReporter', function() { }); it('should navigate and change the setting to off', function() { - const container = document.createElement('div'), - navigateHandler = jasmine.createSpy('navigate'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer, - navigateWithNewParam: navigateHandler - }); + const container = document.createElement('div'); + const navigateHandler = jasmine.createSpy('navigate'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer, + navigateWithNewParam: navigateHandler + }); env.configure({ stopSpecOnExpectationFailure: true }); @@ -937,14 +937,14 @@ describe('HtmlReporter', function() { }); it('should not display specs that have been disabled', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); env.configure({ hideDisabled: true }); reporter.initialize(); @@ -965,14 +965,14 @@ describe('HtmlReporter', function() { describe('UI for running tests in random order', function() { it('should be unchecked if not randomizing', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); env.configure({ random: false }); reporter.initialize(); @@ -983,14 +983,14 @@ describe('HtmlReporter', function() { }); it('should be checked if randomizing', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); env.configure({ random: true }); reporter.initialize(); @@ -1001,16 +1001,16 @@ describe('HtmlReporter', function() { }); it('should navigate and change the setting to on', function() { - const container = document.createElement('div'), - navigateHandler = jasmine.createSpy('navigate'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer, - navigateWithNewParam: navigateHandler - }); + const container = document.createElement('div'); + const navigateHandler = jasmine.createSpy('navigate'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer, + navigateWithNewParam: navigateHandler + }); env.configure({ random: false }); reporter.initialize(); @@ -1023,16 +1023,16 @@ describe('HtmlReporter', function() { }); it('should navigate and change the setting to off', function() { - const container = document.createElement('div'), - navigateHandler = jasmine.createSpy('navigate'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer, - navigateWithNewParam: navigateHandler - }); + const container = document.createElement('div'); + const navigateHandler = jasmine.createSpy('navigate'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer, + navigateWithNewParam: navigateHandler + }); env.configure({ random: true }); reporter.initialize(); @@ -1045,14 +1045,14 @@ describe('HtmlReporter', function() { }); it('should show the seed bar if randomizing', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineDone({ @@ -1069,14 +1069,14 @@ describe('HtmlReporter', function() { }); it('should not show the current seed bar if not randomizing', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineDone({}); @@ -1114,16 +1114,16 @@ describe('HtmlReporter', function() { }); it('should include non-spec query params in the jasmine-skipped link when present', function() { - const container = document.createElement('div'), - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: function() { - return container; - }, - addToExistingQueryString: function(key, value) { - return '?foo=bar&' + key + '=' + value; - } - }); + const container = document.createElement('div'); + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: function() { + return container; + }, + addToExistingQueryString: function(key, value) { + return '?foo=bar&' + key + '=' + value; + } + }); reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 1 }); @@ -1140,12 +1140,12 @@ describe('HtmlReporter', function() { beforeEach(function() { container = document.createElement('div'); const getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 2 }); @@ -1464,9 +1464,9 @@ describe('HtmlReporter', function() { it('reports traces when present', function() { const specFailure = container.querySelectorAll( - '.jasmine-spec-detail.jasmine-failed' - )[2], - debugLogs = specFailure.querySelector('.jasmine-debug-log table'); + '.jasmine-spec-detail.jasmine-failed' + )[2]; + const debugLogs = specFailure.querySelector('.jasmine-debug-log table'); expect(debugLogs).toBeTruthy(); const rows = debugLogs.querySelectorAll('tbody tr'); @@ -1570,14 +1570,14 @@ describe('HtmlReporter', function() { describe('The overall result bar', function() { describe("When the jasmineDone event's overallStatus is 'passed'", function() { it('has class jasmine-passed', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -1594,14 +1594,14 @@ describe('HtmlReporter', function() { describe("When the jasmineDone event's overallStatus is 'failed'", function() { it('has class jasmine-failed', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); @@ -1618,14 +1618,14 @@ describe('HtmlReporter', function() { describe("When the jasmineDone event's overallStatus is 'incomplete'", function() { it('has class jasmine-incomplete', function() { - const container = document.createElement('div'), - getContainer = function() { - return container; - }, - reporter = new jasmineUnderTest.HtmlReporter({ - env: env, - getContainer: getContainer - }); + const container = document.createElement('div'); + const getContainer = function() { + return container; + }; + const reporter = new jasmineUnderTest.HtmlReporter({ + env: env, + getContainer: getContainer + }); reporter.initialize(); diff --git a/spec/html/HtmlReporterV2Spec.js b/spec/html/HtmlReporterV2Spec.js index dcc583a0..2c72f6ca 100644 --- a/spec/html/HtmlReporterV2Spec.js +++ b/spec/html/HtmlReporterV2Spec.js @@ -606,11 +606,11 @@ describe('HtmlReporterV2', function() { reporter.jasmineDone({}); const trigger = container.querySelector( - '.jasmine-run-options .jasmine-trigger' - ), - payload = container.querySelector( - '.jasmine-run-options .jasmine-payload' - ); + '.jasmine-run-options .jasmine-trigger' + ); + const payload = container.querySelector( + '.jasmine-run-options .jasmine-payload' + ); expect(payload).not.toHaveClass('jasmine-open'); @@ -1202,9 +1202,9 @@ describe('HtmlReporterV2', function() { it('reports traces when present', function() { const specFailure = container.querySelectorAll( - '.jasmine-spec-detail.jasmine-failed' - )[2], - debugLogs = specFailure.querySelector('.jasmine-debug-log table'); + '.jasmine-spec-detail.jasmine-failed' + )[2]; + const debugLogs = specFailure.querySelector('.jasmine-debug-log table'); expect(debugLogs).toBeTruthy(); const rows = debugLogs.querySelectorAll('tbody tr'); diff --git a/spec/html/QueryStringSpec.js b/spec/html/QueryStringSpec.js index bc8d1770..13a008eb 100644 --- a/spec/html/QueryStringSpec.js +++ b/spec/html/QueryStringSpec.js @@ -2,13 +2,13 @@ describe('QueryString', function() { describe('#navigateWithNewParam', function() { it('sets the query string to include the given key/value pair', function() { const windowLocation = { - search: '' - }, - queryString = new jasmineUnderTest.QueryString({ - getWindowLocation: function() { - return windowLocation; - } - }); + search: '' + }; + const queryString = new jasmineUnderTest.QueryString({ + getWindowLocation: function() { + return windowLocation; + } + }); queryString.navigateWithNewParam('foo', 'bar baz'); @@ -17,13 +17,13 @@ describe('QueryString', function() { it('leaves existing params alone', function() { const windowLocation = { - search: '?foo=bar' - }, - queryString = new jasmineUnderTest.QueryString({ - getWindowLocation: function() { - return windowLocation; - } - }); + search: '?foo=bar' + }; + const queryString = new jasmineUnderTest.QueryString({ + getWindowLocation: function() { + return windowLocation; + } + }); queryString.navigateWithNewParam('baz', 'quux'); @@ -35,13 +35,13 @@ describe('QueryString', function() { describe('#fullStringWithNewParam', function() { it('gets the query string including the given key/value pair', function() { const windowLocation = { - search: '?foo=bar' - }, - queryString = new jasmineUnderTest.QueryString({ - getWindowLocation: function() { - return windowLocation; - } - }); + search: '?foo=bar' + }; + const queryString = new jasmineUnderTest.QueryString({ + getWindowLocation: function() { + return windowLocation; + } + }); const result = queryString.fullStringWithNewParam('baz', 'quux'); @@ -53,26 +53,26 @@ describe('QueryString', function() { describe('#getParam', function() { it('returns the value of the requested key', function() { const windowLocation = { - search: '?baz=quux%20corge' - }, - queryString = new jasmineUnderTest.QueryString({ - getWindowLocation: function() { - return windowLocation; - } - }); + search: '?baz=quux%20corge' + }; + const queryString = new jasmineUnderTest.QueryString({ + getWindowLocation: function() { + return windowLocation; + } + }); expect(queryString.getParam('baz')).toEqual('quux corge'); }); it('returns null if the key is not present', function() { const windowLocation = { - search: '' - }, - queryString = new jasmineUnderTest.QueryString({ - getWindowLocation: function() { - return windowLocation; - } - }); + search: '' + }; + const queryString = new jasmineUnderTest.QueryString({ + getWindowLocation: function() { + return windowLocation; + } + }); expect(queryString.getParam('baz')).toBeFalsy(); }); diff --git a/spec/html/ResultsNodeSpec.js b/spec/html/ResultsNodeSpec.js index f4474d69..34f93779 100644 --- a/spec/html/ResultsNodeSpec.js +++ b/spec/html/ResultsNodeSpec.js @@ -1,10 +1,10 @@ describe('ResultsNode', function() { it('wraps a result', function() { const fakeResult = { - id: 123, - message: 'foo' - }, - node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); + id: 123, + message: 'foo' + }; + const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); expect(node.result).toBe(fakeResult); expect(node.type).toEqual('suite'); @@ -12,14 +12,14 @@ describe('ResultsNode', function() { it('can add children with a type', function() { const fakeResult = { - id: 123, - message: 'foo' - }, - fakeChildResult = { - id: 456, - message: 'bar' - }, - node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); + id: 123, + message: 'foo' + }; + const fakeChildResult = { + id: 456, + message: 'bar' + }; + const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); node.addChild(fakeChildResult, 'spec'); @@ -30,14 +30,14 @@ describe('ResultsNode', function() { it('has a pointer back to its parent ResultNode', function() { const fakeResult = { - id: 123, - message: 'foo' - }, - fakeChildResult = { - id: 456, - message: 'bar' - }, - node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); + id: 123, + message: 'foo' + }; + const fakeChildResult = { + id: 456, + message: 'bar' + }; + const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); node.addChild(fakeChildResult, 'spec'); @@ -46,14 +46,14 @@ describe('ResultsNode', function() { it('can provide the most recent child', function() { const fakeResult = { - id: 123, - message: 'foo' - }, - fakeChildResult = { - id: 456, - message: 'bar' - }, - node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); + id: 123, + message: 'foo' + }; + const fakeChildResult = { + id: 456, + message: 'bar' + }; + const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null); node.addChild(fakeChildResult, 'spec'); diff --git a/spec/html/SpyRegistryHtmlSpec.js b/spec/html/SpyRegistryHtmlSpec.js index 5347a6d1..99dcea44 100644 --- a/spec/html/SpyRegistryHtmlSpec.js +++ b/spec/html/SpyRegistryHtmlSpec.js @@ -4,15 +4,15 @@ describe('Spy Registry browser-specific behavior', function() { } it('can spy on and unspy window.onerror', function() { - const spies = [], - spyRegistry = new privateUnderTest.SpyRegistry({ - currentSpies: function() { - return spies; - }, - createSpy: createSpy, - global: window - }), - originalHandler = window.onerror; + const spies = []; + const spyRegistry = new privateUnderTest.SpyRegistry({ + currentSpies: function() { + return spies; + }, + createSpy: createSpy, + global: window + }); + const originalHandler = window.onerror; try { spyRegistry.spyOn(window, 'onerror'); diff --git a/spec/support/ci.js b/spec/support/ci.js index c49c7124..ad9a2800 100644 --- a/spec/support/ci.js +++ b/spec/support/ci.js @@ -1,6 +1,6 @@ -const path = require('path'), - jasmineBrowser = require('jasmine-browser-runner'), - jasmineCore = require('../../lib/jasmine-core'); +const path = require('path'); +const jasmineBrowser = require('jasmine-browser-runner'); +const jasmineCore = require('../../lib/jasmine-core'); const config = require(path.resolve('spec/support/jasmine-browser.js')); config.clearReporters = true; diff --git a/spec/support/localJasmineBrowser.js b/spec/support/localJasmineBrowser.js index ab451de7..6c387b98 100644 --- a/spec/support/localJasmineBrowser.js +++ b/spec/support/localJasmineBrowser.js @@ -1,6 +1,6 @@ -const path = require('path'), - jasmineBrowser = require('jasmine-browser-runner'), - jasmineCore = require('../../lib/jasmine-core.js'); +const path = require('path'); +const jasmineBrowser = require('jasmine-browser-runner'); +const jasmineCore = require('../../lib/jasmine-core.js'); const configFile = process.argv[2] || 'jasmine-browser.js'; diff --git a/src/boot/boot0.js b/src/boot/boot0.js index 0bb9da86..3bef81a7 100644 --- a/src/boot/boot0.js +++ b/src/boot/boot0.js @@ -14,8 +14,8 @@ * * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. */ - const jasmine = jasmineRequire.core(jasmineRequire), - global = jasmine.getGlobal(); + const jasmine = jasmineRequire.core(jasmineRequire); + const global = jasmine.getGlobal(); global.jasmine = jasmine; /** diff --git a/src/boot/jasmine-core.js b/src/boot/jasmine-core.js index 1ceab28c..ab86328f 100644 --- a/src/boot/jasmine-core.js +++ b/src/boot/jasmine-core.js @@ -55,15 +55,15 @@ module.exports.noGlobals = function() { return jasmineInterface; }; -const path = require('path'), - fs = require('fs'); +const path = require('path'); +const fs = require('fs'); -const rootPath = path.join(__dirname, 'jasmine-core'), - bootFiles = ['boot0.js', 'boot1.js'], - legacyBootFiles = ['boot.js'], - cssFiles = [], - jsFiles = [], - jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); +const rootPath = path.join(__dirname, 'jasmine-core'); +const bootFiles = ['boot0.js', 'boot1.js']; +const legacyBootFiles = ['boot.js']; +const cssFiles = []; +const jsFiles = []; +const jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles); fs.readdirSync(rootPath).forEach(function(file) { if (fs.statSync(path.join(rootPath, file)).isFile()) { diff --git a/src/core/JsApiReporter.js b/src/core/JsApiReporter.js index 5e54c708..bedd0555 100644 --- a/src/core/JsApiReporter.js +++ b/src/core/JsApiReporter.js @@ -43,8 +43,8 @@ getJasmineRequireObj().JsApiReporter = function(j$) { return status; }; - const suites = [], - suites_hash = {}; + const suites = []; + const suites_hash = {}; this.suiteStarted = function(result) { suites_hash[result.id] = result; diff --git a/src/core/Spec.js b/src/core/Spec.js index 254b50fc..baa4b16d 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -364,10 +364,12 @@ getJasmineRequireObj().Spec = function(j$) { } const extractCustomPendingMessage = function(e) { - const fullMessage = e.toString(), - boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage), - boilerplateEnd = - boilerplateStart + Spec.pendingSpecExceptionMessage.length; + const fullMessage = e.toString(); + const boilerplateStart = fullMessage.indexOf( + Spec.pendingSpecExceptionMessage + ); + const boilerplateEnd = + boilerplateStart + Spec.pendingSpecExceptionMessage.length; return fullMessage.slice(boilerplateEnd); }; diff --git a/src/core/Spy.js b/src/core/Spy.js index 5e84d19b..98e71da6 100644 --- a/src/core/Spy.js +++ b/src/core/Spy.js @@ -40,22 +40,22 @@ getJasmineRequireObj().Spy = function(j$) { }; const { originalFn, customStrategies, defaultStrategyFn } = optionals || {}; - const numArgs = typeof originalFn === 'function' ? originalFn.length : 0, - wrapper = makeFunc(numArgs, function(context, args, invokeNew) { - return spy(context, args, invokeNew); - }), - strategyDispatcher = new SpyStrategyDispatcher( - { - name: name, - fn: originalFn, - getSpy: function() { - return wrapper; - }, - customStrategies: customStrategies + const numArgs = typeof originalFn === 'function' ? originalFn.length : 0; + const wrapper = makeFunc(numArgs, function(context, args, invokeNew) { + return spy(context, args, invokeNew); + }); + const strategyDispatcher = new SpyStrategyDispatcher( + { + name: name, + fn: originalFn, + getSpy: function() { + return wrapper; }, - matchersUtil - ), - callTracker = new j$.private.CallTracker(); + customStrategies: customStrategies + }, + matchersUtil + ); + const callTracker = new j$.private.CallTracker(); function makeFunc(length, fn) { switch (length) { diff --git a/src/core/SpyRegistry.js b/src/core/SpyRegistry.js index 85723f33..59c0f2d4 100644 --- a/src/core/SpyRegistry.js +++ b/src/core/SpyRegistry.js @@ -200,10 +200,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { ); } - let pointer = obj, - propsToSpyOn = [], - properties, - propertiesToSkip = []; + let pointer = obj; + let propsToSpyOn = []; + let properties; + let propertiesToSkip = []; while ( pointer && diff --git a/src/core/SuiteBuilder.js b/src/core/SuiteBuilder.js index f809d841..66101b60 100644 --- a/src/core/SuiteBuilder.js +++ b/src/core/SuiteBuilder.js @@ -323,9 +323,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) { function beforeAndAfterFns(targetSuite) { return function() { - let befores = [], - afters = [], - suite = targetSuite; + let befores = []; + let afters = []; + let suite = targetSuite; while (suite) { befores = befores.concat(suite.beforeFns); diff --git a/src/core/TreeProcessor.js b/src/core/TreeProcessor.js index 04feb514..e3bbb59f 100644 --- a/src/core/TreeProcessor.js +++ b/src/core/TreeProcessor.js @@ -144,15 +144,15 @@ getJasmineRequireObj().TreeProcessor = function(j$) { function segmentChildren(node, orderedChildren, stats, executableIndex) { let currentSegment = { - index: 0, - owner: node, - nodes: [], - min: startingMin(executableIndex), - max: startingMax(executableIndex) - }, - result = [currentSegment], - lastMax = defaultMax, - orderedChildSegments = orderChildSegments(orderedChildren, stats); + index: 0, + owner: node, + nodes: [], + min: startingMin(executableIndex), + max: startingMax(executableIndex) + }; + let result = [currentSegment]; + let lastMax = defaultMax; + let orderedChildSegments = orderChildSegments(orderedChildren, stats); function isSegmentBoundary(minIndex) { return ( @@ -163,9 +163,9 @@ getJasmineRequireObj().TreeProcessor = function(j$) { } for (let i = 0; i < orderedChildSegments.length; i++) { - const childSegment = orderedChildSegments[i], - maxIndex = childSegment.max, - minIndex = childSegment.min; + const childSegment = orderedChildSegments[i]; + const maxIndex = childSegment.max; + const minIndex = childSegment.min; if (isSegmentBoundary(minIndex)) { currentSegment = { @@ -188,12 +188,12 @@ getJasmineRequireObj().TreeProcessor = function(j$) { } function orderChildSegments(children, stats) { - const specifiedOrder = [], - unspecifiedOrder = []; + const specifiedOrder = []; + const unspecifiedOrder = []; for (let i = 0; i < children.length; i++) { - const child = children[i], - segments = stats[child.id].segments; + const child = children[i]; + const segments = stats[child.id].segments; for (let j = 0; j < segments.length; j++) { const seg = segments[j]; diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js index 0ad6f61c..388ea719 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -76,14 +76,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) { }; MatchersUtil.prototype.buildFailureMessage = function() { - const args = Array.prototype.slice.call(arguments, 0), - matcherName = args[0], - isNot = args[1], - actual = args[2], - expected = args.slice(3), - englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { - return ' ' + s.toLowerCase(); - }); + const args = Array.prototype.slice.call(arguments, 0); + const matcherName = args[0]; + const isNot = args[1]; + const actual = args[2]; + const expected = args.slice(3); + const englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { + return ' ' + s.toLowerCase(); + }); let message = 'Expected ' + @@ -465,8 +465,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) { } else { // Objects with different constructors are not equivalent, but `Object`s // or `Array`s from different frames are. - const aCtor = a.constructor, - bCtor = b.constructor; + const aCtor = a.constructor; + const bCtor = b.constructor; if ( aCtor !== bCtor && isFunction(aCtor) && @@ -572,11 +572,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) { } function objectKeysAreDifferentFormatter(pp, actual, expected, path) { - const missingProperties = extraKeysAndValues(expected, actual), - extraProperties = extraKeysAndValues(actual, expected), - missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties), - extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties), - messages = []; + const missingProperties = extraKeysAndValues(expected, actual); + const extraProperties = extraKeysAndValues(actual, expected); + const missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties); + const extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties); + const messages = []; if (!path.depth()) { path = 'object'; diff --git a/src/core/matchers/requireAsyncMatchers.js b/src/core/matchers/requireAsyncMatchers.js index 0794f88e..f1d97d81 100644 --- a/src/core/matchers/requireAsyncMatchers.js +++ b/src/core/matchers/requireAsyncMatchers.js @@ -2,15 +2,15 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) { 'use strict'; const availableMatchers = [ - 'toBePending', - 'toBeResolved', - 'toBeRejected', - 'toBeResolvedTo', - 'toBeRejectedWith', - 'toBeRejectedWithError', - 'toBeRejectedWithMatching' - ], - matchers = {}; + 'toBePending', + 'toBeResolved', + 'toBeRejected', + 'toBeResolvedTo', + 'toBeRejectedWith', + 'toBeRejectedWithError', + 'toBeRejectedWithMatching' + ]; + const matchers = {}; for (const name of availableMatchers) { matchers[name] = jRequire[name](j$); diff --git a/src/core/matchers/requireMatchers.js b/src/core/matchers/requireMatchers.js index d0567a1e..354c4d49 100755 --- a/src/core/matchers/requireMatchers.js +++ b/src/core/matchers/requireMatchers.js @@ -2,43 +2,43 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) { 'use strict'; const availableMatchers = [ - 'nothing', - 'toBe', - 'toBeCloseTo', - 'toBeDefined', - 'toBeInstanceOf', - 'toBeFalse', - 'toBeFalsy', - 'toBeGreaterThan', - 'toBeGreaterThanOrEqual', - 'toBeLessThan', - 'toBeLessThanOrEqual', - 'toBeNaN', - 'toBeNegativeInfinity', - 'toBeNull', - 'toBePositiveInfinity', - 'toBeTrue', - 'toBeTruthy', - 'toBeUndefined', - 'toBeNullish', - 'toContain', - 'toEqual', - 'toHaveSize', - 'toHaveBeenCalled', - 'toHaveBeenCalledBefore', - 'toHaveBeenCalledOnceWith', - 'toHaveBeenCalledTimes', - 'toHaveBeenCalledWith', - 'toHaveClass', - 'toHaveClasses', - 'toHaveSpyInteractions', - 'toHaveNoOtherSpyInteractions', - 'toMatch', - 'toThrow', - 'toThrowError', - 'toThrowMatching' - ], - matchers = {}; + 'nothing', + 'toBe', + 'toBeCloseTo', + 'toBeDefined', + 'toBeInstanceOf', + 'toBeFalse', + 'toBeFalsy', + 'toBeGreaterThan', + 'toBeGreaterThanOrEqual', + 'toBeLessThan', + 'toBeLessThanOrEqual', + 'toBeNaN', + 'toBeNegativeInfinity', + 'toBeNull', + 'toBePositiveInfinity', + 'toBeTrue', + 'toBeTruthy', + 'toBeUndefined', + 'toBeNullish', + 'toContain', + 'toEqual', + 'toHaveSize', + 'toHaveBeenCalled', + 'toHaveBeenCalledBefore', + 'toHaveBeenCalledOnceWith', + 'toHaveBeenCalledTimes', + 'toHaveBeenCalledWith', + 'toHaveClass', + 'toHaveClasses', + 'toHaveSpyInteractions', + 'toHaveNoOtherSpyInteractions', + 'toMatch', + 'toThrow', + 'toThrowError', + 'toThrowMatching' + ]; + const matchers = {}; for (const name of availableMatchers) { matchers[name] = jRequire[name](j$); diff --git a/src/core/matchers/toEqual.js b/src/core/matchers/toEqual.js index 9a8ad1c0..5f4d00b4 100644 --- a/src/core/matchers/toEqual.js +++ b/src/core/matchers/toEqual.js @@ -14,11 +14,11 @@ getJasmineRequireObj().toEqual = function(j$) { return { compare: function(actual, expected) { const result = { - pass: false - }, - diffBuilder = new j$.private.DiffBuilder({ - prettyPrinter: matchersUtil.pp - }); + pass: false + }; + const diffBuilder = new j$.private.DiffBuilder({ + prettyPrinter: matchersUtil.pp + }); result.pass = matchersUtil.equals(actual, expected, diffBuilder); diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js index 1b241ab0..52b8a69f 100644 --- a/src/core/matchers/toHaveBeenCalledOnceWith.js +++ b/src/core/matchers/toHaveBeenCalledOnceWith.js @@ -18,9 +18,9 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { function toHaveBeenCalledOnceWith(matchersUtil) { return { compare: function() { - const args = Array.prototype.slice.call(arguments, 0), - actual = args[0], - expectedArgs = args.slice(1); + const args = Array.prototype.slice.call(arguments, 0); + const actual = args[0]; + const expectedArgs = args.slice(1); if (!j$.isSpy(actual)) { throw new Error( diff --git a/src/core/matchers/toHaveBeenCalledTimes.js b/src/core/matchers/toHaveBeenCalledTimes.js index 68023ac0..af7e7b22 100644 --- a/src/core/matchers/toHaveBeenCalledTimes.js +++ b/src/core/matchers/toHaveBeenCalledTimes.js @@ -26,8 +26,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { ); } - const args = Array.prototype.slice.call(arguments, 0), - result = { pass: false }; + const args = Array.prototype.slice.call(arguments, 0); + const result = { pass: false }; if (!j$.private.isNumber(expected)) { throw new Error( diff --git a/src/core/matchers/toHaveBeenCalledWith.js b/src/core/matchers/toHaveBeenCalledWith.js index ebdc8492..43d9fc5c 100644 --- a/src/core/matchers/toHaveBeenCalledWith.js +++ b/src/core/matchers/toHaveBeenCalledWith.js @@ -18,10 +18,10 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { function toHaveBeenCalledWith(matchersUtil) { return { compare: function() { - const args = Array.prototype.slice.call(arguments, 0), - actual = args[0], - expectedArgs = args.slice(1), - result = { pass: false }; + const args = Array.prototype.slice.call(arguments, 0); + const actual = args[0]; + const expectedArgs = args.slice(1); + const result = { pass: false }; if (!j$.isSpy(actual)) { throw new Error( diff --git a/src/core/util.js b/src/core/util.js index a39defae..cbd509ce 100644 --- a/src/core/util.js +++ b/src/core/util.js @@ -20,8 +20,8 @@ getJasmineRequireObj().util = function(j$) { util.cloneArgs = function(args) { return Array.from(args).map(function(arg) { - const str = Object.prototype.toString.apply(arg), - primitives = /^\[object (Boolean|String|RegExp|Number)/; + const str = Object.prototype.toString.apply(arg); + const primitives = /^\[object (Boolean|String|RegExp|Number)/; // All falsey values are either primitives, `null`, or `undefined. if (!arg || str.match(primitives)) { @@ -35,8 +35,8 @@ getJasmineRequireObj().util = function(j$) { }; util.getPropertyDescriptor = function(obj, methodName) { - let descriptor, - proto = obj; + let descriptor; + let proto = obj; do { descriptor = Object.getOwnPropertyDescriptor(proto, methodName); diff --git a/src/html/Banner.js b/src/html/Banner.js index f3e93377..99153ab1 100644 --- a/src/html/Banner.js +++ b/src/html/Banner.js @@ -138,9 +138,9 @@ jasmineRequire.Banner = function(j$) { }; } - const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'), - optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'), - isOpen = /\bjasmine-open\b/; + const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'); + const optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'); + const isOpen = /\bjasmine-open\b/; optionsTrigger.onclick = function() { if (isOpen.test(optionsPayload.className)) {