From 1166d10e4383c2462522fe272202ecedfdb31b18 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 16 Apr 2022 13:41:44 -0700 Subject: [PATCH] Use const/let in specs, not var --- spec/.eslintrc.js | 2 + spec/core/AsyncExpectationSpec.js | 146 +++---- spec/core/CallTrackerSpec.js | 32 +- spec/core/ClearStackSpec.js | 32 +- spec/core/ClockSpec.js | 114 +++-- spec/core/DelayedFunctionSchedulerSpec.js | 98 +++-- spec/core/DeprecatorSpec.js | 70 +-- spec/core/EnvSpec.js | 34 +- spec/core/ExceptionFormatterSpec.js | 89 ++-- spec/core/ExceptionsSpec.js | 10 +- spec/core/ExpectationFilterChainSpec.js | 29 +- spec/core/ExpectationResultSpec.js | 34 +- spec/core/ExpectationSpec.js | 142 +++--- spec/core/GlobalErrorsSpec.js | 70 ++- spec/core/JsApiReporterSpec.js | 26 +- spec/core/MockDateSpec.js | 114 ++--- spec/core/PrettyPrintSpec.js | 164 +++---- spec/core/QueueRunnerSpec.js | 174 ++++---- spec/core/ReportDispatcherSpec.js | 20 +- spec/core/SpecSpec.js | 145 ++++--- spec/core/SpyRegistrySpec.js | 138 +++--- spec/core/SpySpec.js | 58 +-- spec/core/SpyStrategySpec.js | 66 ++- spec/core/StackTraceSpec.js | 46 +- spec/core/SuiteSpec.js | 50 +-- spec/core/TimerSpec.js | 6 +- spec/core/TreeProcessorSpec.js | 99 ++--- spec/core/UserContextSpec.js | 4 +- spec/core/UtilSpec.js | 28 +- spec/core/asymmetric_equality/AnySpec.js | 24 +- spec/core/asymmetric_equality/AnythingSpec.js | 22 +- .../ArrayContainingSpec.js | 28 +- .../ArrayWithExactContentsSpec.js | 22 +- spec/core/asymmetric_equality/EmptySpec.js | 16 +- spec/core/asymmetric_equality/FalsySpec.js | 10 +- .../asymmetric_equality/MapContainingSpec.js | 78 ++-- spec/core/asymmetric_equality/NotEmptySpec.js | 20 +- .../ObjectContainingSpec.js | 66 +-- .../asymmetric_equality/SetContainingSpec.js | 54 +-- .../StringContainingSpec.js | 6 +- .../asymmetric_equality/StringMatchingSpec.js | 6 +- spec/core/asymmetric_equality/TruthySpec.js | 18 +- spec/core/baseSpec.js | 39 +- spec/core/formatErrorMsgSpec.js | 4 +- .../AsymmetricEqualityTestersSpec.js | 16 +- .../integration/CustomAsyncMatchersSpec.js | 16 +- spec/core/integration/CustomMatchersSpec.js | 34 +- .../integration/CustomObjectFormatterSpec.js | 14 +- .../integration/CustomSpyStrategiesSpec.js | 26 +- .../integration/DefaultSpyStrategySpec.js | 14 +- spec/core/integration/DeprecationSpec.js | 26 +- spec/core/integration/EnvSpec.js | 403 +++++++++--------- spec/core/integration/MatchersSpec.js | 54 +-- spec/core/integration/SpecRunningSpec.js | 106 ++--- spec/core/matchers/DiffBuilderSpec.js | 28 +- spec/core/matchers/MismatchTreeSpec.js | 30 +- spec/core/matchers/NullDiffBuilderSpec.js | 2 +- spec/core/matchers/ObjectPathSpec.js | 6 +- spec/core/matchers/async/toBePendingSpec.js | 8 +- spec/core/matchers/async/toBeRejectedSpec.js | 6 +- .../async/toBeRejectedWithErrorSpec.js | 24 +- .../matchers/async/toBeRejectedWithSpec.js | 12 +- spec/core/matchers/async/toBeResolvedSpec.js | 6 +- .../core/matchers/async/toBeResolvedToSpec.js | 12 +- spec/core/matchers/matchersUtilSpec.js | 355 ++++++++------- spec/core/matchers/nothingSpec.js | 2 +- spec/core/matchers/toBeCloseToSpec.js | 22 +- spec/core/matchers/toBeDefinedSpec.js | 12 +- spec/core/matchers/toBeFalseSpec.js | 18 +- spec/core/matchers/toBeFalsySpec.js | 8 +- .../matchers/toBeGreaterThanOrEqualSpec.js | 8 +- spec/core/matchers/toBeGreaterThanSpec.js | 10 +- spec/core/matchers/toBeInstanceOfSpec.js | 86 ++-- spec/core/matchers/toBeLessThanOrEqualSpec.js | 8 +- spec/core/matchers/toBeLessThanSpec.js | 10 +- spec/core/matchers/toBeNaNSpec.js | 12 +- .../core/matchers/toBeNegativeInfinitySpec.js | 8 +- spec/core/matchers/toBeNullSpec.js | 12 +- .../core/matchers/toBePositiveInfinitySpec.js | 8 +- spec/core/matchers/toBeSpec.js | 37 +- spec/core/matchers/toBeTrueSpec.js | 12 +- spec/core/matchers/toBeTruthySpec.js | 8 +- spec/core/matchers/toBeUndefinedSpec.js | 12 +- spec/core/matchers/toContainSpec.js | 14 +- spec/core/matchers/toEqualSpec.js | 328 +++++++------- .../matchers/toHaveBeenCalledBeforeSpec.js | 36 +- .../matchers/toHaveBeenCalledOnceWithSpec.js | 44 +- spec/core/matchers/toHaveBeenCalledSpec.js | 25 +- .../matchers/toHaveBeenCalledTimesSpec.js | 44 +- .../core/matchers/toHaveBeenCalledWithSpec.js | 30 +- spec/core/matchers/toHaveClassSpec.js | 10 +- spec/core/matchers/toHaveSizeSpec.js | 38 +- spec/core/matchers/toMatchSpec.js | 22 +- spec/core/matchers/toThrowErrorSpec.js | 128 +++--- spec/core/matchers/toThrowMatchingSpec.js | 32 +- spec/core/matchers/toThrowSpec.js | 44 +- spec/helpers/BrowserFlags.js | 4 +- spec/helpers/domHelpers.js | 8 +- spec/helpers/integrationMatchers.js | 14 +- spec/helpers/nodeDefineJasmineUnderTest.js | 6 +- spec/html/HtmlReporterSpec.js | 302 ++++++------- spec/html/HtmlSpecFilterSpec.js | 4 +- spec/html/MatchersHtmlSpec.js | 6 +- spec/html/PrettyPrintHtmlSpec.js | 21 +- spec/html/QueryStringSpec.js | 12 +- spec/html/ResultsNodeSpec.js | 8 +- spec/html/SpyRegistryHtmlSpec.js | 2 +- spec/npmPackage/npmPackageSpec.js | 54 ++- spec/performance/large_object_test.js | 9 +- spec/performance/performance_test.js | 2 +- spec/support/localJasmineBrowser.js | 6 +- 111 files changed, 2522 insertions(+), 2675 deletions(-) diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js index bafb67ca..b97d34d3 100644 --- a/spec/.eslintrc.js +++ b/spec/.eslintrc.js @@ -14,6 +14,8 @@ module.exports = { // TODO: consider doing this in src files as well as specs 'no-unused-vars': ['error', { args: 'after-used' }], + 'no-var': 'error', + // Since linting is done at the end of the process and doesn't stop us // from running tests, it makes sense to fail if debugger statements // or console references are present. diff --git a/spec/core/AsyncExpectationSpec.js b/spec/core/AsyncExpectationSpec.js index c624c831..a0117be9 100644 --- a/spec/core/AsyncExpectationSpec.js +++ b/spec/core/AsyncExpectationSpec.js @@ -7,7 +7,7 @@ describe('AsyncExpectation', function() { describe('#not', function() { it('converts a pass to a fail', function() { - var addExpectationResult = jasmine.createSpy('addExpectationResult'), + const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.resolve(), pp = jasmineUnderTest.makePrettyPrinter(), expectation = jasmineUnderTest.Expectation.asyncFactory({ @@ -28,7 +28,7 @@ describe('AsyncExpectation', function() { }); it('converts a fail to a pass', function() { - var addExpectationResult = jasmine.createSpy('addExpectationResult'), + const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.reject(), expectation = jasmineUnderTest.Expectation.asyncFactory({ matchersUtil: new jasmineUnderTest.MatchersUtil({ @@ -51,9 +51,9 @@ describe('AsyncExpectation', function() { }); it('propagates rejections from the comparison function', function() { - var error = new Error('ExpectationSpec failure'); + const error = new Error('ExpectationSpec failure'); - var addExpectationResult = jasmine.createSpy('addExpectationResult'), + const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = dummyPromise(), expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: actual, @@ -74,7 +74,7 @@ describe('AsyncExpectation', function() { describe('#withContext', function() { it('prepends the context to the generated failure message', function() { - var matchersUtil = { + const matchersUtil = { pp: function(val) { return val.toString(); } @@ -101,7 +101,7 @@ describe('AsyncExpectation', function() { }); it('prepends the context to a custom failure message', function() { - var matchersUtil = { + const matchersUtil = { buildFailureMessage: function() { return 'failure message'; }, @@ -132,7 +132,7 @@ describe('AsyncExpectation', function() { it('prepends the context to a custom failure message from a function', function() { pending('should actually work, but no custom matchers for async yet'); - var matchersUtil = { + const matchersUtil = { buildFailureMessage: function() { return 'failure message'; } @@ -159,7 +159,7 @@ describe('AsyncExpectation', function() { }); it('works with #not', function() { - var addExpectationResult = jasmine.createSpy('addExpectationResult'), + const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.resolve(), pp = jasmineUnderTest.makePrettyPrinter(), expectation = jasmineUnderTest.Expectation.asyncFactory({ @@ -183,7 +183,7 @@ describe('AsyncExpectation', function() { }); it('works with #not and a custom message', function() { - var addExpectationResult = jasmine.createSpy('addExpectationResult'), + const addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = Promise.resolve('a'), expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: actual, @@ -210,22 +210,20 @@ describe('AsyncExpectation', function() { describe('async matchers', function() { it('makes custom matchers available to this expectation', function() { - var asyncMatchers = { + const asyncMatchers = { toFoo: function() {}, toBar: function() {} }, - expectation; - - expectation = jasmineUnderTest.Expectation.asyncFactory({ - customAsyncMatchers: asyncMatchers - }); + expectation = jasmineUnderTest.Expectation.asyncFactory({ + customAsyncMatchers: asyncMatchers + }); expect(expectation.toFoo).toBeDefined(); expect(expectation.toBar).toBeDefined(); }); it("wraps matchers's compare functions, passing in matcher dependencies", function() { - var fakeCompare = function() { + const fakeCompare = function() { return Promise.resolve({ pass: true }); }, matcherFactory = jasmine @@ -238,14 +236,12 @@ describe('AsyncExpectation', function() { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; - - expectation = jasmineUnderTest.Expectation.asyncFactory({ - matchersUtil: matchersUtil, - customAsyncMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + expectation = jasmineUnderTest.Expectation.asyncFactory({ + matchersUtil: matchersUtil, + customAsyncMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); return expectation.toFoo('hello').then(function() { expect(matcherFactory).toHaveBeenCalledWith(matchersUtil); @@ -253,7 +249,7 @@ describe('AsyncExpectation', function() { }); it("wraps matchers's compare functions, passing the actual and expected", function() { - var fakeCompare = jasmine + const fakeCompare = jasmine .createSpy('fake-compare') .and.returnValue(Promise.resolve({ pass: true })), matchers = { @@ -267,14 +263,12 @@ describe('AsyncExpectation', function() { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; - - expectation = jasmineUnderTest.Expectation.asyncFactory({ - matchersUtil: matchersUtil, - customAsyncMatchers: matchers, - actual: 'an actual', - addExpectationResult: addExpectationResult - }); + expectation = jasmineUnderTest.Expectation.asyncFactory({ + matchersUtil: matchersUtil, + customAsyncMatchers: matchers, + actual: 'an actual', + addExpectationResult: addExpectationResult + }); return expectation.toFoo('hello').then(function() { expect(fakeCompare).toHaveBeenCalledWith('an actual', 'hello'); @@ -282,7 +276,7 @@ describe('AsyncExpectation', function() { }); it('reports a passing result to the spec when the comparison passes', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -295,14 +289,13 @@ describe('AsyncExpectation', function() { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -323,7 +316,7 @@ describe('AsyncExpectation', function() { }); it('reports a failing result to the spec when the comparison fails', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -338,14 +331,13 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -366,7 +358,7 @@ describe('AsyncExpectation', function() { }); it('reports a failing result and a custom fail message to the spec when the comparison fails', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -379,14 +371,13 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult @@ -406,7 +397,7 @@ describe('AsyncExpectation', function() { }); it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -421,14 +412,13 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -448,7 +438,7 @@ describe('AsyncExpectation', function() { }); it('reports a passing result to the spec when the comparison fails for a negative expectation', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -459,14 +449,13 @@ describe('AsyncExpectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = 'an actual', - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -486,7 +475,7 @@ describe('AsyncExpectation', function() { }); it('reports a failing result to the spec when the comparison passes for a negative expectation', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -502,14 +491,13 @@ describe('AsyncExpectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = 'an actual', - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', matchersUtil: matchersUtil, @@ -530,7 +518,7 @@ describe('AsyncExpectation', function() { }); it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -544,14 +532,13 @@ describe('AsyncExpectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = 'an actual', - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -571,7 +558,7 @@ describe('AsyncExpectation', function() { }); it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -585,14 +572,13 @@ describe('AsyncExpectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = 'an actual', - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -612,7 +598,7 @@ describe('AsyncExpectation', function() { }); it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -629,14 +615,13 @@ describe('AsyncExpectation', function() { }, addExpectationResult = jasmine.createSpy('addExpectationResult'), actual = 'an actual', - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ customAsyncMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -656,8 +641,8 @@ describe('AsyncExpectation', function() { }); it('reports errorWithStack when a custom error message is returned', function() { - var customError = new Error('I am a custom error'); - var matchers = { + const customError = new Error('I am a custom error'); + const matchers = { toFoo: function() { return { compare: function() { @@ -671,14 +656,13 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult @@ -698,7 +682,7 @@ describe('AsyncExpectation', function() { }); it("reports a custom message to the spec when a 'not' comparison fails", function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -711,14 +695,13 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + const expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult @@ -738,7 +721,7 @@ describe('AsyncExpectation', function() { }); it("reports a custom message func to the spec when a 'not' comparison fails", function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -753,14 +736,13 @@ describe('AsyncExpectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - errorWithStack = new Error('errorWithStack'), - expectation; + errorWithStack = new Error('errorWithStack'); spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue( errorWithStack ); - expectation = jasmineUnderTest.Expectation.asyncFactory({ + let expectation = jasmineUnderTest.Expectation.asyncFactory({ actual: 'an actual', customAsyncMatchers: matchers, addExpectationResult: addExpectationResult diff --git a/spec/core/CallTrackerSpec.js b/spec/core/CallTrackerSpec.js index f997de44..da5cecc7 100644 --- a/spec/core/CallTrackerSpec.js +++ b/spec/core/CallTrackerSpec.js @@ -1,6 +1,6 @@ describe('CallTracker', function() { it('tracks that it was called when executed', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); expect(callTracker.any()).toBe(false); @@ -10,7 +10,7 @@ describe('CallTracker', function() { }); it('tracks that number of times that it is executed', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); expect(callTracker.count()).toEqual(0); @@ -20,7 +20,7 @@ describe('CallTracker', function() { }); it('tracks the params from each execution', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.track({ object: void 0, args: [] }); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -31,9 +31,9 @@ describe('CallTracker', function() { }); it("tracks the 'this' object from each execution", function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); - var this0 = {}, + const this0 = {}, this1 = {}; callTracker.track({ object: this0, args: [] }); callTracker.track({ object: this1, args: [] }); @@ -45,13 +45,13 @@ describe('CallTracker', function() { }); it('returns any empty array when there was no call', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); expect(callTracker.argsFor(0)).toEqual([]); }); it('allows access for the arguments for all calls', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.track({ object: {}, args: [] }); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -60,7 +60,7 @@ describe('CallTracker', function() { }); it('tracks the context and arguments for each call', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.track({ object: {}, args: [] }); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -71,7 +71,7 @@ describe('CallTracker', function() { }); it('simplifies access to the arguments for the last (most recent) call', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.track(); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -83,13 +83,13 @@ describe('CallTracker', function() { }); it("returns a useful falsy value when there isn't a last (most recent) call", function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); expect(callTracker.mostRecent()).toBeFalsy(); }); it('simplifies access to the arguments for the first (oldest) call', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -97,13 +97,13 @@ describe('CallTracker', function() { }); it("returns a useful falsy value when there isn't a first (oldest) call", function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); expect(callTracker.first()).toBeFalsy(); }); it('allows the tracking to be reset', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.track(); callTracker.track({ object: {}, args: [0, 'foo'] }); @@ -117,10 +117,10 @@ describe('CallTracker', function() { }); it('allows object arguments to be shallow cloned', function() { - var callTracker = new jasmineUnderTest.CallTracker(); + const callTracker = new jasmineUnderTest.CallTracker(); callTracker.saveArgumentsByValue(); - var objectArg = { foo: 'bar' }, + const objectArg = { foo: 'bar' }, arrayArg = ['foo', 'bar']; callTracker.track({ @@ -135,7 +135,7 @@ describe('CallTracker', function() { }); it('saves primitive arguments by value', function() { - var callTracker = new jasmineUnderTest.CallTracker(), + const callTracker = new jasmineUnderTest.CallTracker(), args = [undefined, null, false, '', /\s/, 0, 1.2, NaN]; callTracker.saveArgumentsByValue(); diff --git a/spec/core/ClearStackSpec.js b/spec/core/ClearStackSpec.js index 9592b2d2..1cfaf6ad 100644 --- a/spec/core/ClearStackSpec.js +++ b/spec/core/ClearStackSpec.js @@ -1,6 +1,6 @@ describe('ClearStack', function() { it('works in an integrationy way', function(done) { - var clearStack = jasmineUnderTest.getClearStack( + const clearStack = jasmineUnderTest.getClearStack( jasmineUnderTest.getGlobal() ); @@ -10,14 +10,14 @@ describe('ClearStack', function() { }); it('uses setImmediate when available', function() { - var setImmediate = jasmine + const setImmediate = jasmine .createSpy('setImmediate') .and.callFake(function(fn) { fn(); }), global = { setImmediate: setImmediate }, - clearStack = jasmineUnderTest.getClearStack(global), - called = false; + clearStack = jasmineUnderTest.getClearStack(global); + let called = false; clearStack(function() { called = true; @@ -28,7 +28,7 @@ describe('ClearStack', function() { }); it('uses setTimeout instead of setImmediate every 10 calls to make sure we release the CPU', function() { - var setImmediate = jasmine.createSpy('setImmediate'), + const setImmediate = jasmine.createSpy('setImmediate'), setTimeout = jasmine.createSpy('setTimeout'), global = { setImmediate: setImmediate, setTimeout: setTimeout }, clearStack = jasmineUnderTest.getClearStack(global); @@ -56,7 +56,7 @@ describe('ClearStack', function() { }); it('uses MessageChannels when available', function() { - var fakeChannel = { + const fakeChannel = { port1: {}, port2: { postMessage: function() { @@ -69,8 +69,8 @@ describe('ClearStack', function() { return fakeChannel; } }, - clearStack = jasmineUnderTest.getClearStack(global), - called = false; + clearStack = jasmineUnderTest.getClearStack(global); + let called = false; clearStack(function() { called = true; @@ -80,7 +80,7 @@ describe('ClearStack', function() { }); it('uses setTimeout instead of MessageChannel every 10 calls to make sure we release the CPU', function() { - var fakeChannel = { + const fakeChannel = { port1: {}, port2: { postMessage: jasmine @@ -122,7 +122,7 @@ describe('ClearStack', function() { }); it('calls setTimeout when onmessage is called recursively', function() { - var fakeChannel = { + const fakeChannel = { port1: {}, port2: { postMessage: function() { @@ -149,12 +149,14 @@ describe('ClearStack', function() { }); it('falls back to setTimeout', function() { - var setTimeout = jasmine.createSpy('setTimeout').and.callFake(function(fn) { - fn(); - }), + const setTimeout = jasmine + .createSpy('setTimeout') + .and.callFake(function(fn) { + fn(); + }), global = { setTimeout: setTimeout }, - clearStack = jasmineUnderTest.getClearStack(global), - called = false; + clearStack = jasmineUnderTest.getClearStack(global); + let called = false; clearStack(function() { called = true; diff --git a/spec/core/ClockSpec.js b/spec/core/ClockSpec.js index 9046ece0..474fbab8 100644 --- a/spec/core/ClockSpec.js +++ b/spec/core/ClockSpec.js @@ -1,11 +1,11 @@ describe('Clock', function() { - var NODE_JS = + const NODE_JS = typeof process !== 'undefined' && process.versions && typeof process.versions.node === 'string'; it('does not replace setTimeout until it is installed', function() { - var fakeSetTimeout = jasmine.createSpy('global setTimeout'), + const fakeSetTimeout = jasmine.createSpy('global setTimeout'), fakeGlobal = { setTimeout: fakeSetTimeout }, delayedFunctionScheduler = jasmine.createSpyObj( 'delayedFunctionScheduler', @@ -40,7 +40,7 @@ describe('Clock', function() { }); it('does not replace clearTimeout until it is installed', function() { - var fakeClearTimeout = jasmine.createSpy('global cleartimeout'), + const fakeClearTimeout = jasmine.createSpy('global cleartimeout'), fakeGlobal = { clearTimeout: fakeClearTimeout }, delayedFunctionScheduler = jasmine.createSpyObj( 'delayedFunctionScheduler', @@ -76,7 +76,7 @@ describe('Clock', function() { }); it('does not replace setInterval until it is installed', function() { - var fakeSetInterval = jasmine.createSpy('global setInterval'), + const fakeSetInterval = jasmine.createSpy('global setInterval'), fakeGlobal = { setInterval: fakeSetInterval }, delayedFunctionScheduler = jasmine.createSpyObj( 'delayedFunctionScheduler', @@ -111,7 +111,7 @@ describe('Clock', function() { }); it('does not replace clearInterval until it is installed', function() { - var fakeClearInterval = jasmine.createSpy('global clearinterval'), + const fakeClearInterval = jasmine.createSpy('global clearinterval'), fakeGlobal = { clearInterval: fakeClearInterval }, delayedFunctionScheduler = jasmine.createSpyObj( 'delayedFunctionScheduler', @@ -147,7 +147,7 @@ describe('Clock', function() { }); it('does not install if the current setTimeout is not the original function on the global', function() { - var originalFakeSetTimeout = function() {}, + const originalFakeSetTimeout = function() {}, replacedSetTimeout = function() {}, fakeGlobal = { setTimeout: originalFakeSetTimeout }, delayedFunctionSchedulerFactory = jasmine.createSpy( @@ -171,7 +171,7 @@ describe('Clock', function() { }); it('does not install if the current clearTimeout is not the original function on the global', function() { - var originalFakeClearTimeout = function() {}, + const originalFakeClearTimeout = function() {}, replacedClearTimeout = function() {}, fakeGlobal = { clearTimeout: originalFakeClearTimeout }, delayedFunctionSchedulerFactory = jasmine.createSpy( @@ -195,7 +195,7 @@ describe('Clock', function() { }); it('does not install if the current setInterval is not the original function on the global', function() { - var originalFakeSetInterval = function() {}, + const originalFakeSetInterval = function() {}, replacedSetInterval = function() {}, fakeGlobal = { setInterval: originalFakeSetInterval }, delayedFunctionSchedulerFactory = jasmine.createSpy( @@ -219,7 +219,7 @@ describe('Clock', function() { }); it('does not install if the current clearInterval is not the original function on the global', function() { - var originalFakeClearInterval = function() {}, + const originalFakeClearInterval = function() {}, replacedClearInterval = function() {}, fakeGlobal = { clearInterval: originalFakeClearInterval }, delayedFunctionSchedulerFactory = jasmine.createSpy( @@ -243,7 +243,7 @@ describe('Clock', function() { }); it('replaces the global timer functions on uninstall', function() { - var fakeSetTimeout = jasmine.createSpy('global setTimeout'), + const fakeSetTimeout = jasmine.createSpy('global setTimeout'), fakeClearTimeout = jasmine.createSpy('global clearTimeout'), fakeSetInterval = jasmine.createSpy('global setInterval'), fakeClearInterval = jasmine.createSpy('global clearInterval'), @@ -286,7 +286,7 @@ describe('Clock', function() { }); it('can be installed for the duration of a passed in function and uninstalled when done', function() { - var fakeSetTimeout = jasmine.createSpy('global setTimeout'), + const fakeSetTimeout = jasmine.createSpy('global setTimeout'), fakeClearTimeout = jasmine.createSpy('global clearTimeout'), fakeSetInterval = jasmine.createSpy('global setInterval'), fakeClearInterval = jasmine.createSpy('global clearInterval'), @@ -312,8 +312,8 @@ describe('Clock', function() { return delayedFunctionScheduler; }, mockDate - ), - passedFunctionCalled = false; + ); + let passedFunctionCalled = false; clock.withMock(function() { fakeGlobal.setTimeout(delayedFn, 0); @@ -346,7 +346,7 @@ describe('Clock', function() { }); it('can be installed for the duration of a passed in function and uninstalled if an error is thrown', function() { - var fakeSetTimeout = jasmine.createSpy('global setTimeout'), + const fakeSetTimeout = jasmine.createSpy('global setTimeout'), fakeClearTimeout = jasmine.createSpy('global clearTimeout'), fakeSetInterval = jasmine.createSpy('global setInterval'), fakeClearInterval = jasmine.createSpy('global clearInterval'), @@ -372,8 +372,8 @@ describe('Clock', function() { return delayedFunctionScheduler; }, mockDate - ), - passedFunctionCalled = false; + ); + let passedFunctionCalled = false; expect(function() { clock.withMock(function() { @@ -409,7 +409,7 @@ describe('Clock', function() { }); it('schedules the delayed function (via setTimeout) with the fake timer', function() { - var fakeSetTimeout = jasmine.createSpy('setTimeout'), + const fakeSetTimeout = jasmine.createSpy('setTimeout'), scheduleFunction = jasmine.createSpy('scheduleFunction'), delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, fakeGlobal = { setTimeout: fakeSetTimeout }, @@ -451,7 +451,7 @@ describe('Clock', function() { }); it('returns an id for the delayed function', function() { - var fakeSetTimeout = jasmine.createSpy('setTimeout'), + const fakeSetTimeout = jasmine.createSpy('setTimeout'), scheduleId = 123, scheduleFunction = jasmine .createSpy('scheduleFunction') @@ -470,11 +470,10 @@ describe('Clock', function() { return delayedFunctionScheduler; }, mockDate - ), - timeout; + ); clock.install(); - timeout = clock.setTimeout(delayedFn, 0); + const timeout = clock.setTimeout(delayedFn, 0); if (!NODE_JS) { expect(timeout).toEqual(123); @@ -484,7 +483,7 @@ describe('Clock', function() { }); it('clears the scheduled function with the scheduler', function() { - var fakeClearTimeout = jasmine.createSpy('clearTimeout'), + const fakeClearTimeout = jasmine.createSpy('clearTimeout'), delayedFunctionScheduler = jasmine.createSpyObj( 'delayedFunctionScheduler', ['removeFunctionWithId'] @@ -513,7 +512,7 @@ describe('Clock', function() { }); it('schedules the delayed function with the fake timer', function() { - var fakeSetInterval = jasmine.createSpy('setInterval'), + const fakeSetInterval = jasmine.createSpy('setInterval'), scheduleFunction = jasmine.createSpy('scheduleFunction'), delayedFunctionScheduler = { scheduleFunction: scheduleFunction }, fakeGlobal = { setInterval: fakeSetInterval }, @@ -556,7 +555,7 @@ describe('Clock', function() { }); it('returns an id for the delayed function', function() { - var fakeSetInterval = jasmine.createSpy('setInterval'), + const fakeSetInterval = jasmine.createSpy('setInterval'), scheduleId = 123, scheduleFunction = jasmine .createSpy('scheduleFunction') @@ -575,11 +574,10 @@ describe('Clock', function() { return delayedFunctionScheduler; }, mockDate - ), - interval; + ); clock.install(); - interval = clock.setInterval(delayedFn, 0); + const interval = clock.setInterval(delayedFn, 0); if (!NODE_JS) { expect(interval).toEqual(123); @@ -589,7 +587,7 @@ describe('Clock', function() { }); it('clears the scheduled function with the scheduler', function() { - var clearInterval = jasmine.createSpy('clearInterval'), + const clearInterval = jasmine.createSpy('clearInterval'), delayedFunctionScheduler = jasmine.createSpyObj( 'delayedFunctionScheduler', ['removeFunctionWithId'] @@ -618,7 +616,7 @@ describe('Clock', function() { }); it('gives you a friendly reminder if the Clock is not installed and you tick', function() { - var clock = new jasmineUnderTest.Clock( + const clock = new jasmineUnderTest.Clock( {}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']) ); @@ -630,7 +628,7 @@ describe('Clock', function() { describe('Clock (acceptance)', function() { it('can run setTimeouts/setIntervals synchronously', function() { - var delayedFn1 = jasmine.createSpy('delayedFn1'), + const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), delayedFn3 = jasmine.createSpy('delayedFn3'), recurring1 = jasmine.createSpy('recurring1'), @@ -651,7 +649,7 @@ describe('Clock (acceptance)', function() { clock.install(); clock.setTimeout(delayedFn1, 0); - var intervalId = clock.setInterval(recurring1, 50); + const intervalId = clock.setInterval(recurring1, 50); clock.setTimeout(delayedFn2, 100); clock.setTimeout(delayedFn3, 200); @@ -690,7 +688,7 @@ describe('Clock (acceptance)', function() { }); it('can clear a previously set timeout', function() { - var clearedFn = jasmine.createSpy('clearedFn'), + const clearedFn = jasmine.createSpy('clearedFn'), delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, @@ -703,12 +701,11 @@ describe('Clock (acceptance)', function() { return delayedFunctionScheduler; }, mockDate - ), - timeoutId; + ); clock.install(); - timeoutId = clock.setTimeout(clearedFn, 100); + const timeoutId = clock.setTimeout(clearedFn, 100); expect(clearedFn).not.toHaveBeenCalled(); clock.clearTimeout(timeoutId); @@ -718,7 +715,7 @@ describe('Clock (acceptance)', function() { }); it("can clear a previously set interval using that interval's handler", function() { - var spy = jasmine.createSpy('spy'), + const spy = jasmine.createSpy('spy'), delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, @@ -731,12 +728,11 @@ describe('Clock (acceptance)', function() { return delayedFunctionScheduler; }, mockDate - ), - intervalId; + ); clock.install(); - intervalId = clock.setInterval(function() { + const intervalId = clock.setInterval(function() { spy(); clock.clearInterval(intervalId); }, 100); @@ -746,7 +742,7 @@ describe('Clock (acceptance)', function() { }); it('correctly schedules functions after the Clock has advanced', function() { - var delayedFn1 = jasmine.createSpy('delayedFn1'), + const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), mockDate = { install: function() {}, @@ -772,7 +768,7 @@ describe('Clock (acceptance)', function() { }); it('correctly schedules functions while the Clock is advancing', function() { - var delayedFn1 = jasmine.createSpy('delayedFn1'), + const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), mockDate = { @@ -803,7 +799,7 @@ describe('Clock (acceptance)', function() { }); it('correctly calls functions scheduled while the Clock is advancing', function() { - var delayedFn1 = jasmine.createSpy('delayedFn1'), + const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), mockDate = { @@ -831,7 +827,7 @@ describe('Clock (acceptance)', function() { }); it('correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled', function() { - var delayedFn1 = jasmine.createSpy('delayedFn1'), + const delayedFn1 = jasmine.createSpy('delayedFn1'), delayedFn2 = jasmine.createSpy('delayedFn2'), delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), mockDate = { @@ -865,7 +861,7 @@ describe('Clock (acceptance)', function() { }); it('does not mock the Date object by default', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -880,7 +876,7 @@ describe('Clock (acceptance)', function() { expect(global.Date).toEqual(Date); - var now = new global.Date().getTime(); + const now = new global.Date().getTime(); clock.tick(50); @@ -888,7 +884,7 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and sets it to current time', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -901,13 +897,13 @@ describe('Clock (acceptance)', function() { clock.install().mockDate(); - var now = new global.Date().getTime(); + const now = new global.Date().getTime(); clock.tick(50); expect(new global.Date().getTime() - now).toEqual(50); - var timeoutDate = 0; + let timeoutDate = 0; clock.setTimeout(function() { timeoutDate = new global.Date().getTime(); }, 100); @@ -918,7 +914,7 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and sets it to a given time', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -932,7 +928,7 @@ describe('Clock (acceptance)', function() { clock.install().mockDate(baseTime); - var now = new global.Date().getTime(); + const now = new global.Date().getTime(); expect(now).toEqual(baseTime.getTime()); @@ -940,7 +936,7 @@ describe('Clock (acceptance)', function() { expect(new global.Date().getTime()).toEqual(baseTime.getTime() + 50); - var timeoutDate = 0; + let timeoutDate = 0; clock.setTimeout(function() { timeoutDate = new global.Date().getTime(); }, 100); @@ -951,7 +947,7 @@ describe('Clock (acceptance)', function() { }); it('throws mockDate is called with a non-Date', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -969,7 +965,7 @@ describe('Clock (acceptance)', function() { }); it('mocks the Date object and updates the date per delayed function', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -983,8 +979,8 @@ describe('Clock (acceptance)', function() { clock.install().mockDate(baseTime); - var actualTimes = []; - var pushCurrentTime = function() { + const actualTimes = []; + const pushCurrentTime = function() { actualTimes.push(global.Date().getTime()); }; delayedFunctionScheduler.scheduleFunction(pushCurrentTime); @@ -1008,7 +1004,7 @@ describe('Clock (acceptance)', function() { }); it('correctly clears a scheduled timeout while the Clock is advancing', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date, setTimeout: undefined }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -1021,7 +1017,7 @@ describe('Clock (acceptance)', function() { clock.install(); - var timerId2; + let timerId2; global.setTimeout(function() { global.clearTimeout(timerId2); @@ -1033,7 +1029,7 @@ describe('Clock (acceptance)', function() { }); it('correctly clears a scheduled interval while the Clock is advancing', function() { - var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(), global = { Date: Date, setTimeout: undefined }, mockDate = new jasmineUnderTest.MockDate(global), clock = new jasmineUnderTest.Clock( @@ -1046,7 +1042,7 @@ describe('Clock (acceptance)', function() { clock.install(); - var timerId2; + let timerId2; global.setInterval(function() { global.clearInterval(timerId2); }, 100); diff --git a/spec/core/DelayedFunctionSchedulerSpec.js b/spec/core/DelayedFunctionSchedulerSpec.js index caa585c6..d14b937e 100644 --- a/spec/core/DelayedFunctionSchedulerSpec.js +++ b/spec/core/DelayedFunctionSchedulerSpec.js @@ -1,6 +1,6 @@ describe('DelayedFunctionScheduler', function() { it('schedules a function for later execution', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0); @@ -13,7 +13,7 @@ describe('DelayedFunctionScheduler', function() { }); it('schedules a string for later execution', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), strfn = 'horrible = true;'; scheduler.scheduleFunction(strfn, 0); @@ -24,7 +24,7 @@ describe('DelayedFunctionScheduler', function() { }); it('#tick defaults to 0', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0); @@ -37,7 +37,7 @@ describe('DelayedFunctionScheduler', function() { }); it('defaults delay to 0', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn); @@ -50,7 +50,7 @@ describe('DelayedFunctionScheduler', function() { }); it('optionally passes params to scheduled functions', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 0, ['foo', 'bar']); @@ -63,7 +63,7 @@ describe('DelayedFunctionScheduler', function() { }); it('scheduled fns can optionally reoccur', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'); scheduler.scheduleFunction(fn, 20, [], true); @@ -84,7 +84,7 @@ describe('DelayedFunctionScheduler', function() { }); it('increments scheduled fns ids unless one is passed', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); expect(scheduler.scheduleFunction(function() {}, 0)).toBe(1); expect(scheduler.scheduleFunction(function() {}, 0)).toBe(2); @@ -95,11 +95,9 @@ describe('DelayedFunctionScheduler', function() { }); it('#removeFunctionWithId removes a previously scheduled function with a given id', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), - timeoutKey; - - timeoutKey = scheduler.scheduleFunction(fn, 0); + timeoutKey = scheduler.scheduleFunction(fn, 0); expect(fn).not.toHaveBeenCalled(); @@ -111,15 +109,15 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions interleaved with regular functions in the correct order', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - recurringCallCount = 0, - recurring = jasmine.createSpy('recurring').and.callFake(function() { - recurringCallCount++; - if (recurringCallCount < 5) { - expect(fn).not.toHaveBeenCalled(); - } - }); + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + let recurringCallCount = 0; + const recurring = jasmine.createSpy('recurring').and.callFake(function() { + recurringCallCount++; + if (recurringCallCount < 5) { + expect(fn).not.toHaveBeenCalled(); + } + }); scheduler.scheduleFunction(recurring, 10, [], true); scheduler.scheduleFunction(fn, 50); @@ -132,7 +130,7 @@ describe('DelayedFunctionScheduler', function() { }); it('schedules a function for later execution during a tick', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), fnDelay = 10; @@ -148,10 +146,10 @@ describe('DelayedFunctionScheduler', function() { }); it('#removeFunctionWithId removes a previously scheduled function with a given id during a tick', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), - fnDelay = 10, - timeoutKey; + fnDelay = 10; + let timeoutKey; scheduler.scheduleFunction(function() { scheduler.removeFunctionWithId(timeoutKey); @@ -166,24 +164,24 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), - fn = jasmine.createSpy('fn'), - recurringCallCount = 0, - recurring = jasmine.createSpy('recurring').and.callFake(function() { - recurringCallCount++; - if (recurringCallCount < 5) { - expect(fn).not.toHaveBeenCalled(); - } - }), - innerFn = jasmine.createSpy('innerFn').and.callFake(function() { - expect(recurring.calls.count()).toBe(4); + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(); + const fn = jasmine.createSpy('fn'); + let recurringCallCount = 0; + const recurring = jasmine.createSpy('recurring').and.callFake(function() { + recurringCallCount++; + if (recurringCallCount < 5) { expect(fn).not.toHaveBeenCalled(); - }), - scheduling = jasmine.createSpy('scheduling').and.callFake(function() { - expect(recurring.calls.count()).toBe(3); - expect(fn).not.toHaveBeenCalled(); - scheduler.scheduleFunction(innerFn, 10); // 41ms absolute - }); + } + }); + const innerFn = jasmine.createSpy('innerFn').and.callFake(function() { + expect(recurring.calls.count()).toBe(4); + expect(fn).not.toHaveBeenCalled(); + }); + const scheduling = jasmine.createSpy('scheduling').and.callFake(function() { + expect(recurring.calls.count()).toBe(3); + expect(fn).not.toHaveBeenCalled(); + scheduler.scheduleFunction(innerFn, 10); // 41ms absolute + }); scheduler.scheduleFunction(recurring, 10, [], true); scheduler.scheduleFunction(fn, 50); @@ -199,7 +197,7 @@ describe('DelayedFunctionScheduler', function() { }); it('executes recurring functions after rescheduling them', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), recurring = function() { expect(scheduler.scheduleFunction).toHaveBeenCalled(); }; @@ -212,11 +210,11 @@ describe('DelayedFunctionScheduler', function() { }); it('removes functions during a tick that runs the function', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), spy = jasmine.createSpy('fn'), spyAndRemove = jasmine.createSpy('fn'), - fnDelay = 10, - timeoutKey; + fnDelay = 10; + let timeoutKey; spyAndRemove.and.callFake(function() { scheduler.removeFunctionWithId(timeoutKey); @@ -233,10 +231,10 @@ describe('DelayedFunctionScheduler', function() { }); it('removes functions during the first tick that runs the function', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), - fnDelay = 10, - timeoutKey; + fnDelay = 10; + let timeoutKey; timeoutKey = scheduler.scheduleFunction(fn, fnDelay, [], true); scheduler.scheduleFunction(function() { @@ -252,7 +250,7 @@ describe('DelayedFunctionScheduler', function() { }); it("does not remove a function that hasn't been added yet", function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), fn = jasmine.createSpy('fn'), fnDelay = 10; @@ -267,7 +265,7 @@ describe('DelayedFunctionScheduler', function() { }); it('updates the mockDate per scheduled time', function() { - var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), + const scheduler = new jasmineUnderTest.DelayedFunctionScheduler(), tickDate = jasmine.createSpy('tickDate'); scheduler.scheduleFunction(function() {}); diff --git a/spec/core/DeprecatorSpec.js b/spec/core/DeprecatorSpec.js index 4be31dbe..c2a126bf 100644 --- a/spec/core/DeprecatorSpec.js +++ b/spec/core/DeprecatorSpec.js @@ -6,8 +6,8 @@ describe('Deprecator', function() { }); it('logs the mesage without context when the runnable is the top suite', function() { - var runnable = { addDeprecationWarning: function() {} }; - var deprecator = new jasmineUnderTest.Deprecator(runnable); + const runnable = { addDeprecationWarning: function() {} }; + const deprecator = new jasmineUnderTest.Deprecator(runnable); deprecator.verboseDeprecations(true); deprecator.addDeprecationWarning(runnable, 'the message', { @@ -18,14 +18,14 @@ describe('Deprecator', function() { }); it('logs the message in a descendant suite', function() { - var runnable = { + const runnable = { addDeprecationWarning: function() {}, getFullName: function() { return 'the suite'; }, children: [] }; - var deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new jasmineUnderTest.Deprecator({}); deprecator.verboseDeprecations(true); deprecator.addDeprecationWarning(runnable, 'the message', { @@ -38,13 +38,13 @@ describe('Deprecator', function() { }); it('logs and reports the message in a spec', function() { - var runnable = { + const runnable = { addDeprecationWarning: function() {}, getFullName: function() { return 'the spec'; } }; - var deprecator = new jasmineUnderTest.Deprecator({}); + const deprecator = new jasmineUnderTest.Deprecator({}); deprecator.verboseDeprecations(true); deprecator.addDeprecationWarning(runnable, 'the message', { @@ -57,12 +57,12 @@ describe('Deprecator', function() { }); it('logs and reports the message without runnable info when ignoreRunnable is true', function() { - var topSuite = jasmine.createSpyObj('topSuite', [ + const topSuite = jasmine.createSpyObj('topSuite', [ 'addDeprecationWarning', 'getFullName' ]); - var deprecator = new jasmineUnderTest.Deprecator(topSuite); - var runnable = jasmine.createSpyObj('spec', [ + const deprecator = new jasmineUnderTest.Deprecator(topSuite); + const runnable = jasmine.createSpyObj('spec', [ 'addDeprecationWarning', 'getFullName' ]); @@ -105,12 +105,12 @@ describe('Deprecator', function() { }); it('emits the deprecation only once when verboseDeprecations is not set', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable1 = jasmine.createSpyObj('runnable1', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable1 = jasmine.createSpyObj('runnable1', [ 'addDeprecationWarning', 'getFullName' ]); - var runnable2 = jasmine.createSpyObj('runnable2', [ + const runnable2 = jasmine.createSpyObj('runnable2', [ 'addDeprecationWarning', 'getFullName' ]); @@ -124,12 +124,12 @@ describe('Deprecator', function() { }); it('emits the deprecation only once when verboseDeprecations is false', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable1 = jasmine.createSpyObj('runnable1', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable1 = jasmine.createSpyObj('runnable1', [ 'addDeprecationWarning', 'getFullName' ]); - var runnable2 = jasmine.createSpyObj('runnable2', [ + const runnable2 = jasmine.createSpyObj('runnable2', [ 'addDeprecationWarning', 'getFullName' ]); @@ -144,12 +144,12 @@ describe('Deprecator', function() { }); it('emits the deprecation for each call when verboseDeprecations is true', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable1 = jasmine.createSpyObj('runnable1', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable1 = jasmine.createSpyObj('runnable1', [ 'addDeprecationWarning', 'getFullName' ]); - var runnable2 = jasmine.createSpyObj('runnable2', [ + const runnable2 = jasmine.createSpyObj('runnable2', [ 'addDeprecationWarning', 'getFullName' ]); @@ -164,8 +164,8 @@ describe('Deprecator', function() { }); it('includes a note about verboseDeprecations', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); @@ -183,8 +183,8 @@ describe('Deprecator', function() { }); it('omits the note about verboseDeprecations when verboseDeprecations is true', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); @@ -207,12 +207,12 @@ describe('Deprecator', function() { // to report their own deprecations through Jasmine. See // . it('passes the error through unchanged', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); - var deprecation, originalStack; + let deprecation, originalStack; try { throw new Error('the deprecation'); @@ -238,12 +238,12 @@ describe('Deprecator', function() { }); it('reports the deprecation every time, regardless of config.verboseDeprecations', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); - var deprecation; + let deprecation; try { throw new Error('the deprecation'); @@ -259,12 +259,12 @@ describe('Deprecator', function() { }); it('omits the note about verboseDeprecations', function() { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); - var deprecation; + let deprecation; try { throw new Error('the deprecation'); @@ -293,8 +293,8 @@ describe('Deprecator', function() { } function testStackTrace(options) { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); @@ -311,8 +311,8 @@ describe('Deprecator', function() { } function testNoStackTrace(options) { - var deprecator = new jasmineUnderTest.Deprecator({}); - var runnable = jasmine.createSpyObj('runnable', [ + const deprecator = new jasmineUnderTest.Deprecator({}); + const runnable = jasmine.createSpyObj('runnable', [ 'addDeprecationWarning', 'getFullName' ]); diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index e835f923..d809e19d 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -1,6 +1,6 @@ // TODO: Fix these unit tests! describe('Env', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); }); @@ -27,7 +27,6 @@ describe('Env', function() { describe('#topSuite', function() { it('returns an object that describes the tree of suites and specs', function() { - var suite; spyOn(env, 'deprecated'); env.it('a top level spec'); @@ -38,7 +37,7 @@ describe('Env', function() { }); }); - suite = env.topSuite(); + const suite = env.topSuite(); expect(suite).not.toBeInstanceOf(jasmineUnderTest.Suite); expect(suite.description).toEqual('Jasmine__TopLevel__Suite'); expect(suite.getFullName()).toEqual(''); @@ -113,7 +112,7 @@ describe('Env', function() { it('ignores configuration properties that are present but undefined', function() { spyOn(env, 'deprecated'); - var initialConfig = { + const initialConfig = { random: true, seed: '123', failSpecWithNoExpectations: true, @@ -316,7 +315,7 @@ describe('Env', function() { behavesLikeIt('xit'); it('calls spec.exclude with "Temporarily disabled with xit"', function() { - var excludeSpy = jasmine.createSpy(); + const excludeSpy = jasmine.createSpy(); spyOn(env, 'it_').and.returnValue({ exclude: excludeSpy }); @@ -325,8 +324,8 @@ describe('Env', function() { }); it('calls spec.pend with "Temporarily disabled with xit"', function() { - var pendSpy = jasmine.createSpy(); - var realExclude = jasmineUnderTest.Spec.prototype.exclude; + const pendSpy = jasmine.createSpy(); + const realExclude = jasmineUnderTest.Spec.prototype.exclude; spyOn(env, 'it_').and.returnValue({ exclude: realExclude, @@ -465,7 +464,7 @@ describe('Env', function() { describe('when not constructed with suppressLoadErrors: true', function() { it('installs a global error handler on construction', function() { - var globalErrors = jasmine.createSpyObj('globalErrors', [ + const globalErrors = jasmine.createSpyObj('globalErrors', [ 'install', 'uninstall', 'pushListener', @@ -480,7 +479,7 @@ describe('Env', function() { describe('when constructed with suppressLoadErrors: true', function() { it('does not install a global error handler until execute is called', function() { - var globalErrors = jasmine.createSpyObj('globalErrors', [ + const globalErrors = jasmine.createSpyObj('globalErrors', [ 'install', 'uninstall', 'pushListener', @@ -499,9 +498,9 @@ describe('Env', function() { function customEqualityTester() {} function customObjectFormatter() {} function prettyPrinter() {} - var RealSpec = jasmineUnderTest.Spec, - specInstance, - expectationFactory; + const RealSpec = jasmineUnderTest.Spec; + let specInstance; + let expectationFactory; spyOn(jasmineUnderTest, 'MatchersUtil'); spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter); spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) { @@ -532,9 +531,9 @@ describe('Env', function() { function customEqualityTester() {} function customObjectFormatter() {} function prettyPrinter() {} - var RealSpec = jasmineUnderTest.Spec, - specInstance, - asyncExpectationFactory; + const RealSpec = jasmineUnderTest.Spec; + let specInstance; + let asyncExpectationFactory; spyOn(jasmineUnderTest, 'MatchersUtil'); spyOn(jasmineUnderTest, 'makePrettyPrinter').and.returnValue(prettyPrinter); spyOn(jasmineUnderTest, 'Spec').and.callFake(function(options) { @@ -562,7 +561,7 @@ describe('Env', function() { }); it("does not expose the suite as 'this'", function() { - var suiteThis; + let suiteThis; spyOn(env, 'deprecated'); env.describe('a suite', function() { @@ -586,11 +585,10 @@ describe('Env', function() { return env.execute(); // 2 }) .then(function() { - var id; expect( jasmineUnderTest.Suite.prototype.reset ).toHaveBeenCalledOnceWith(); - id = jasmineUnderTest.Suite.prototype.reset.calls.thisFor(0).id; + const id = jasmineUnderTest.Suite.prototype.reset.calls.thisFor(0).id; expect(id).toBeTruthy(); expect(id).toEqual(env.topSuite().id); }); diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index f4f15700..3f410e10 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -1,7 +1,7 @@ describe('ExceptionFormatter', function() { describe('#message', function() { it('formats Firefox exception messages', function() { - var sampleFirefoxException = { + const sampleFirefoxException = { fileName: 'foo.js', lineNumber: '1978', message: 'you got your foo in my bar', @@ -16,7 +16,7 @@ describe('ExceptionFormatter', function() { }); it('formats Webkit exception messages', function() { - var sampleWebkitException = { + const sampleWebkitException = { sourceURL: 'foo.js', line: '1978', message: 'you got your foo in my bar', @@ -31,7 +31,7 @@ describe('ExceptionFormatter', function() { }); it('formats V8 exception messages', function() { - var sampleV8 = { + const sampleV8 = { message: 'you got your foo in my bar', name: 'A Classic Mistake' }, @@ -42,29 +42,29 @@ describe('ExceptionFormatter', function() { }); it('formats unnamed exceptions with message', function() { - var unnamedError = { message: 'This is an unnamed error message.' }; + const unnamedError = { message: 'This is an unnamed error message.' }; - var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(unnamedError); expect(message).toEqual('This is an unnamed error message.'); }); it('formats empty exceptions with toString format', function() { - var EmptyError = function() {}; + const EmptyError = function() {}; EmptyError.prototype.toString = function() { return '[EmptyError]'; }; - var emptyError = new EmptyError(); + const emptyError = new EmptyError(); - var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(emptyError); expect(message).toEqual('[EmptyError] thrown'); }); it("formats thrown exceptions that aren't errors", function() { - var thrown = 'crazy error', + const thrown = 'crazy error', exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), message = exceptionFormatter.message(thrown); @@ -74,12 +74,7 @@ describe('ExceptionFormatter', function() { describe('#stack', function() { it('formats stack traces', function() { - var error; - try { - throw new Error('an error'); - } catch (e) { - error = e; - } + const error = new Error('an error'); expect(new jasmineUnderTest.ExceptionFormatter().stack(error)).toMatch( /ExceptionFormatterSpec\.js.*\d+/ @@ -87,7 +82,7 @@ describe('ExceptionFormatter', function() { }); it('filters Jasmine stack frames from V8-style traces but leaves unmatched lines intact', function() { - var error = { + const error = { message: 'nope', stack: 'C:\\__spec__\\core\\UtilSpec.ts:120\n' + @@ -101,10 +96,10 @@ describe('ExceptionFormatter', function() { ' at fn3 (C:\\__jasmine__\\lib\\jasmine-core\\jasmine.js:7575:25)\n' + ' at fn4 (node:internal/timers:462:21)\n' }; - var subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new jasmineUnderTest.ExceptionFormatter({ jasmineFile: 'C:\\__jasmine__\\lib\\jasmine-core\\jasmine.js' }); - var result = subject.stack(error); + const result = subject.stack(error); expect(result).toEqual( 'C:\\__spec__\\core\\UtilSpec.ts:120\n' + " new Error('nope');\n" + @@ -118,7 +113,7 @@ describe('ExceptionFormatter', function() { }); it('filters Jasmine stack frames from V8 style traces', function() { - var error = { + const error = { message: 'nope', stack: 'Error: nope\n' + @@ -127,10 +122,10 @@ describe('ExceptionFormatter', function() { ' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' + ' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n' }; - var subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new jasmineUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); - var result = subject.stack(error); + const result = subject.stack(error); expect(result).toEqual( 'Error: nope\n' + ' at fn1 (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' + @@ -140,17 +135,17 @@ describe('ExceptionFormatter', function() { }); it('filters Jasmine stack frames from Webkit style traces', function() { - var error = { + const error = { stack: 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' + 'fn1@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' + 'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' + 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28' }; - var subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new jasmineUnderTest.ExceptionFormatter({ jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js' }); - var result = subject.stack(error); + const result = subject.stack(error); expect(result).toEqual( 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' + '\n' + @@ -159,17 +154,12 @@ describe('ExceptionFormatter', function() { }); it('filters Jasmine stack frames in this environment', function() { - var error, i; - try { - throw new Error('an error'); - } catch (e) { - error = e; - } - var subject = new jasmineUnderTest.ExceptionFormatter({ + const error = new Error('an error'); + const subject = new jasmineUnderTest.ExceptionFormatter({ jasmineFile: jasmine.util.jasmineFile() }); - var result = subject.stack(error); - var lines = result.split('\n'); + const result = subject.stack(error); + const lines = result.split('\n'); if (lines[0].match(/an error/)) { lines.shift(); @@ -179,28 +169,23 @@ describe('ExceptionFormatter', function() { expect(lines[1]).toMatch(//); // Node has some number of additional frames below Jasmine. - for (i = 2; i < lines.length; i++) { + for (let i = 2; i < lines.length; i++) { expect(lines[i]).not.toMatch(/jasmine.js/); } }); it('handles multiline error messages in this environment', function() { - var error, - msg = 'an error\nwith two lines'; - try { - throw new Error(msg); - } catch (e) { - error = e; - } + const msg = 'an error\nwith two lines'; + const error = new Error(msg); if (error.stack.indexOf(msg) === -1) { pending("Stack traces don't have messages in this environment"); } - var subject = new jasmineUnderTest.ExceptionFormatter({ + const subject = new jasmineUnderTest.ExceptionFormatter({ jasmineFile: jasmine.util.jasmineFile() }); - var result = subject.stack(error); - var lines = result.split('\n'); + const result = subject.stack(error); + const lines = result.split('\n'); expect(lines[0]).toMatch(/an error/); expect(lines[1]).toMatch(/with two lines/); @@ -213,15 +198,10 @@ describe('ExceptionFormatter', function() { }); it('includes error properties in stack', function() { - var error; - try { - throw new Error('an error'); - } catch (e) { - error = e; - } + const error = new Error('an error'); error.someProperty = 'hello there'; - var result = new jasmineUnderTest.ExceptionFormatter().stack(error); + const result = new jasmineUnderTest.ExceptionFormatter().stack(error); expect(result).toMatch(/error properties:.*someProperty.*hello there/); }); @@ -268,12 +248,7 @@ describe('ExceptionFormatter', function() { }); it('ensures that stack traces do not include the message in this environment', function() { - let error; - try { - throw new Error('an error'); - } catch (e) { - error = e; - } + const error = new Error('an error'); const subject = new jasmineUnderTest.ExceptionFormatter({ jasmineFile: jasmine.util.jasmineFile() }); diff --git a/spec/core/ExceptionsSpec.js b/spec/core/ExceptionsSpec.js index aee9844c..c1e67051 100644 --- a/spec/core/ExceptionsSpec.js +++ b/spec/core/ExceptionsSpec.js @@ -1,5 +1,5 @@ describe('Exceptions:', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -10,7 +10,7 @@ describe('Exceptions:', function() { }); it('should handle exceptions thrown, but continue', function(done) { - var secondTest = jasmine.createSpy('second test'); + const secondTest = jasmine.createSpy('second test'); env.describe('Suite for handles exceptions', function() { env.it( 'should be a test that fails because it throws an exception', @@ -24,7 +24,7 @@ describe('Exceptions:', function() { ); }); - var expectations = function() { + const expectations = function() { expect(secondTest).toHaveBeenCalled(); done(); }; @@ -33,7 +33,7 @@ describe('Exceptions:', function() { }); it('should handle exceptions thrown directly in top-level describe blocks and continue', function(done) { - var secondDescribe = jasmine + const secondDescribe = jasmine .createSpy('second describe') .and.callFake(function() { env.it('has a test', function() {}); @@ -47,7 +47,7 @@ describe('Exceptions:', function() { }); env.describe("a suite that doesn't throw an exception", secondDescribe); - var expectations = function() { + const expectations = function() { expect(secondDescribe).toHaveBeenCalled(); done(); }; diff --git a/spec/core/ExpectationFilterChainSpec.js b/spec/core/ExpectationFilterChainSpec.js index 009a5ba3..aab7171d 100644 --- a/spec/core/ExpectationFilterChainSpec.js +++ b/spec/core/ExpectationFilterChainSpec.js @@ -1,7 +1,7 @@ describe('ExpectationFilterChain', function() { describe('#addFilter', function() { it('returns a new filter chain with the added filter', function() { - var first = jasmine.createSpy('first'), + const first = jasmine.createSpy('first'), second = jasmine.createSpy('second'), orig = new jasmineUnderTest.ExpectationFilterChain({ modifyFailureMessage: first @@ -15,7 +15,7 @@ describe('ExpectationFilterChain', function() { }); it('does not modify the original filter chain', function() { - var orig = new jasmineUnderTest.ExpectationFilterChain({}), + const orig = new jasmineUnderTest.ExpectationFilterChain({}), f = jasmine.createSpy('f'); orig.addFilter({ selectComparisonFunc: f }); @@ -28,7 +28,7 @@ describe('ExpectationFilterChain', function() { describe('#selectComparisonFunc', function() { describe('When no filters have #selectComparisonFunc', function() { it('returns undefined', function() { - var chain = new jasmineUnderTest.ExpectationFilterChain(); + const chain = new jasmineUnderTest.ExpectationFilterChain(); chain.addFilter({}); expect(chain.selectComparisonFunc()).toBeUndefined(); }); @@ -36,15 +36,13 @@ describe('ExpectationFilterChain', function() { describe('When some filters have #selectComparisonFunc', function() { it('calls the first filter that has #selectComparisonFunc', function() { - var first = jasmine.createSpy('first').and.returnValue('first'), + const first = jasmine.createSpy('first').and.returnValue('first'), second = jasmine.createSpy('second').and.returnValue('second'), chain = new jasmineUnderTest.ExpectationFilterChain() .addFilter({ selectComparisonFunc: first }) .addFilter({ selectComparisonFunc: second }), matcher = {}, - result; - - result = chain.selectComparisonFunc(matcher); + result = chain.selectComparisonFunc(matcher); expect(first).toHaveBeenCalledWith(matcher); expect(second).not.toHaveBeenCalled(); @@ -56,7 +54,7 @@ describe('ExpectationFilterChain', function() { describe('#buildFailureMessage', function() { describe('When no filters have #buildFailureMessage', function() { it('returns undefined', function() { - var chain = new jasmineUnderTest.ExpectationFilterChain(); + const chain = new jasmineUnderTest.ExpectationFilterChain(); chain.addFilter({}); expect(chain.buildFailureMessage()).toBeUndefined(); }); @@ -64,7 +62,7 @@ describe('ExpectationFilterChain', function() { describe('When some filters have #buildFailureMessage', function() { it('calls the first filter that has #buildFailureMessage', function() { - var first = jasmine.createSpy('first').and.returnValue('first'), + const first = jasmine.createSpy('first').and.returnValue('first'), second = jasmine.createSpy('second').and.returnValue('second'), chain = new jasmineUnderTest.ExpectationFilterChain() .addFilter({ buildFailureMessage: first }) @@ -72,10 +70,9 @@ describe('ExpectationFilterChain', function() { matcherResult = { pass: false }, matcherName = 'foo', args = [], - matchersUtil = {}, - result; + matchersUtil = {}; - result = chain.buildFailureMessage( + const result = chain.buildFailureMessage( matcherResult, matcherName, args, @@ -97,7 +94,7 @@ describe('ExpectationFilterChain', function() { describe('#modifyFailureMessage', function() { describe('When no filters have #modifyFailureMessage', function() { it('returns the original message', function() { - var chain = new jasmineUnderTest.ExpectationFilterChain(); + const chain = new jasmineUnderTest.ExpectationFilterChain(); chain.addFilter({}); expect(chain.modifyFailureMessage('msg')).toEqual('msg'); }); @@ -105,14 +102,12 @@ describe('ExpectationFilterChain', function() { describe('When some filters have #modifyFailureMessage', function() { it('calls the first filter that has #modifyFailureMessage', function() { - var first = jasmine.createSpy('first').and.returnValue('first'), + const first = jasmine.createSpy('first').and.returnValue('first'), second = jasmine.createSpy('second').and.returnValue('second'), chain = new jasmineUnderTest.ExpectationFilterChain() .addFilter({ modifyFailureMessage: first }) .addFilter({ modifyFailureMessage: second }), - result; - - result = chain.modifyFailureMessage('original'); + result = chain.modifyFailureMessage('original'); expect(first).toHaveBeenCalledWith('original'); expect(second).not.toHaveBeenCalled(); diff --git a/spec/core/ExpectationResultSpec.js b/spec/core/ExpectationResultSpec.js index d68b1655..906d5afc 100644 --- a/spec/core/ExpectationResultSpec.js +++ b/spec/core/ExpectationResultSpec.js @@ -1,13 +1,13 @@ describe('buildExpectationResult', function() { it('defaults to passed', function() { - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: 'some-value' }); expect(result.passed).toBe('some-value'); }); it('message defaults to Passed for passing specs', function() { - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: true, message: 'some-value' }); @@ -15,7 +15,7 @@ describe('buildExpectationResult', function() { }); it('message returns the message for failing expectations', function() { - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: false, message: 'some-value' }); @@ -23,12 +23,12 @@ describe('buildExpectationResult', function() { }); it('delegates message formatting to the provided formatter if there was an Error', function() { - var fakeError = { message: 'foo' }, + const fakeError = { message: 'foo' }, messageFormatter = jasmine .createSpy('exception message formatter') .and.returnValue(fakeError.message); - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: false, error: fakeError, messageFormatter: messageFormatter @@ -39,12 +39,12 @@ describe('buildExpectationResult', function() { }); it('delegates stack formatting to the provided formatter if there was an Error', function() { - var fakeError = { stack: 'foo' }, + const fakeError = { stack: 'foo' }, stackFormatter = jasmine .createSpy('stack formatter') .and.returnValue(fakeError.stack); - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: false, error: fakeError, stackFormatter: stackFormatter @@ -57,12 +57,12 @@ describe('buildExpectationResult', function() { }); it('delegates stack formatting to the provided formatter if there was a provided errorForStack', function() { - var fakeError = { stack: 'foo' }, + const fakeError = { stack: 'foo' }, stackFormatter = jasmine .createSpy('stack formatter') .and.returnValue(fakeError.stack); - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: false, errorForStack: fakeError, stackFormatter: stackFormatter @@ -75,21 +75,21 @@ describe('buildExpectationResult', function() { }); it('matcherName returns passed matcherName', function() { - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ matcherName: 'some-value' }); expect(result.matcherName).toBe('some-value'); }); it('expected returns passed expected', function() { - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ expected: 'some-value' }); expect(result.expected).toBe('some-value'); }); it('actual returns passed actual', function() { - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ actual: 'some-value' }); expect(result.actual).toBe('some-value'); @@ -99,10 +99,10 @@ describe('buildExpectationResult', function() { if (typeof require === 'undefined') { return; } - var assert = require('assert'); - var error; - var value = 8421; - var expectedValue = 'JasmineExpectationTestValue'; + const assert = require('assert'); + const value = 8421; + const expectedValue = 'JasmineExpectationTestValue'; + let error; try { assert.equal(value, expectedValue); } catch (e) { @@ -114,7 +114,7 @@ describe('buildExpectationResult', function() { expect(error.expected).toEqual(expectedValue); expect(error.operator).toEqual('=='); - var result = jasmineUnderTest.buildExpectationResult({ + const result = jasmineUnderTest.buildExpectationResult({ passed: false, matcherName: '', expected: '', diff --git a/spec/core/ExpectationSpec.js b/spec/core/ExpectationSpec.js index ce2b9ae9..c127e1de 100644 --- a/spec/core/ExpectationSpec.js +++ b/spec/core/ExpectationSpec.js @@ -1,34 +1,31 @@ describe('Expectation', function() { it('makes custom matchers available to this expectation', function() { - var matchers = { + const matchers = { toFoo: function() {}, toBar: function() {} }, - expectation; - - expectation = jasmineUnderTest.Expectation.factory({ - customMatchers: matchers - }); + expectation = jasmineUnderTest.Expectation.factory({ + customMatchers: matchers + }); expect(expectation.toFoo).toBeDefined(); expect(expectation.toBar).toBeDefined(); }); it('.addCoreMatchers makes matchers available to any expectation', function() { - var coreMatchers = { - toQuux: function() {} - }, - expectation; + const coreMatchers = { + toQuux: function() {} + }; jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers); - expectation = jasmineUnderTest.Expectation.factory({}); + const expectation = jasmineUnderTest.Expectation.factory({}); expect(expectation.toQuux).toBeDefined(); }); it("wraps matchers's compare functions, passing in matcher dependencies", function() { - var fakeCompare = function() { + const fakeCompare = function() { return { pass: true }; }, matcherFactory = jasmine @@ -40,10 +37,9 @@ describe('Expectation', function() { matchersUtil = { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ matchersUtil: matchersUtil, customMatchers: matchers, actual: 'an actual', @@ -56,7 +52,7 @@ describe('Expectation', function() { }); it("wraps matchers's compare functions, passing the actual and expected", function() { - var fakeCompare = jasmine + const fakeCompare = jasmine .createSpy('fake-compare') .and.returnValue({ pass: true }), matchers = { @@ -69,10 +65,9 @@ describe('Expectation', function() { matchersUtil = { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ matchersUtil: matchersUtil, customMatchers: matchers, actual: 'an actual', @@ -85,7 +80,7 @@ describe('Expectation', function() { }); it('reports a passing result to the spec when the comparison passes', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -97,10 +92,9 @@ describe('Expectation', function() { matchersUtil = { buildFailureMessage: jasmine.createSpy('buildFailureMessage') }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -121,7 +115,7 @@ describe('Expectation', function() { }); it('reports a failing result to the spec when the comparison fails', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -135,10 +129,9 @@ describe('Expectation', function() { return ''; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, matchersUtil: matchersUtil, actual: 'an actual', @@ -159,7 +152,7 @@ describe('Expectation', function() { }); it('reports a failing result and a custom fail message to the spec when the comparison fails', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -171,10 +164,9 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -194,7 +186,7 @@ describe('Expectation', function() { }); it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -208,10 +200,9 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -231,7 +222,7 @@ describe('Expectation', function() { }); it('reports a passing result to the spec when the comparison fails for a negative expectation', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -241,10 +232,9 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual', - expectation; + actual = 'an actual'; - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -264,7 +254,7 @@ describe('Expectation', function() { }); it('reports a failing result to the spec when the comparison passes for a negative expectation', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -279,10 +269,9 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual', - expectation; + actual = 'an actual'; - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', matchersUtil: matchersUtil, @@ -303,7 +292,7 @@ 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() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -316,10 +305,9 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual', - expectation; + actual = 'an actual'; - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -339,7 +327,7 @@ describe('Expectation', function() { }); it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -352,10 +340,9 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual', - expectation; + actual = 'an actual'; - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -375,7 +362,7 @@ 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() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -391,10 +378,9 @@ describe('Expectation', function() { } }, addExpectationResult = jasmine.createSpy('addExpectationResult'), - actual = 'an actual', - expectation; + actual = 'an actual'; - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult @@ -414,8 +400,8 @@ describe('Expectation', function() { }); it('reports a custom error message to the spec', function() { - var customError = new Error('I am a custom error'); - var matchers = { + const customError = new Error('I am a custom error'); + const matchers = { toFoo: function() { return { compare: function() { @@ -428,10 +414,9 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -451,8 +436,8 @@ describe('Expectation', function() { }); it("reports a custom message to the spec when a 'not' comparison fails", function() { - var customError = new Error('I am a custom error'); - var matchers = { + const customError = new Error('I am a custom error'); + const matchers = { toFoo: function() { return { compare: function() { @@ -465,10 +450,9 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -488,8 +472,8 @@ describe('Expectation', function() { }); it("reports a custom message func to the spec when a 'not' comparison fails", function() { - var customError = new Error('I am a custom error'); - var matchers = { + const customError = new Error('I am a custom error'); + const matchers = { toFoo: function() { return { compare: function() { @@ -504,10 +488,9 @@ describe('Expectation', function() { }; } }, - addExpectationResult = jasmine.createSpy('addExpectationResult'), - expectation; + addExpectationResult = jasmine.createSpy('addExpectationResult'); - expectation = jasmineUnderTest.Expectation.factory({ + const expectation = jasmineUnderTest.Expectation.factory({ actual: 'an actual', customMatchers: matchers, addExpectationResult: addExpectationResult @@ -528,7 +511,7 @@ describe('Expectation', function() { describe('#withContext', function() { it('prepends the context to the generated failure message', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -561,7 +544,7 @@ describe('Expectation', function() { }); it('prepends the context to a custom failure message', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -588,7 +571,7 @@ describe('Expectation', function() { }); it('indents a multiline failure message', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -602,19 +585,18 @@ describe('Expectation', function() { customMatchers: matchers, actual: 'an actual', addExpectationResult: addExpectationResult - }), - actualMessage; + }); expectation.withContext('Some context').toFoo('hello'); - actualMessage = addExpectationResult.calls.argsFor(0)[1].message; + const actualMessage = addExpectationResult.calls.argsFor(0)[1].message; expect(actualMessage).toEqual( 'Some context:\n a\n multiline\n message' ); }); it('prepends the context to a custom failure message from a function', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -646,7 +628,7 @@ describe('Expectation', function() { }); it('works with #not', function() { - var matchers = { + const matchers = { toFoo: function() { return { compare: function() { @@ -675,8 +657,8 @@ describe('Expectation', function() { }); it('works with #not and a custom message', function() { - var customError = new Error('I am a custom error'); - var matchers = { + const customError = new Error('I am a custom error'); + const matchers = { toFoo: function() { return { compare: function() { diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index 07e2f48c..6a179bfa 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -1,6 +1,6 @@ describe('GlobalErrors', function() { it('calls the added handler on error', function() { - var fakeGlobal = { onerror: null }, + const fakeGlobal = { onerror: null }, handler = jasmine.createSpy('errorHandler'), errors = new jasmineUnderTest.GlobalErrors(fakeGlobal); @@ -13,7 +13,7 @@ describe('GlobalErrors', function() { }); it('enables external interception of error by overriding global.onerror', function() { - var fakeGlobal = { onerror: null }, + const fakeGlobal = { onerror: null }, handler = jasmine.createSpy('errorHandler'), hijackHandler = jasmine.createSpy('hijackErrorHandler'), errors = new jasmineUnderTest.GlobalErrors(fakeGlobal); @@ -30,7 +30,7 @@ describe('GlobalErrors', function() { }); it('calls the global error handler with all parameters', function() { - var fakeGlobal = { onerror: null }, + const fakeGlobal = { onerror: null }, handler = jasmine.createSpy('errorHandler'), errors = new jasmineUnderTest.GlobalErrors(fakeGlobal), fooError = new Error('foo'); @@ -50,7 +50,7 @@ describe('GlobalErrors', function() { }); it('only calls the most recent handler', function() { - var fakeGlobal = { onerror: null }, + const fakeGlobal = { onerror: null }, handler1 = jasmine.createSpy('errorHandler1'), handler2 = jasmine.createSpy('errorHandler2'), errors = new jasmineUnderTest.GlobalErrors(fakeGlobal); @@ -66,7 +66,7 @@ describe('GlobalErrors', function() { }); it('calls previous handlers when one is removed', function() { - var fakeGlobal = { onerror: null }, + const fakeGlobal = { onerror: null }, handler1 = jasmine.createSpy('errorHandler1'), handler2 = jasmine.createSpy('errorHandler2'), errors = new jasmineUnderTest.GlobalErrors(fakeGlobal); @@ -84,14 +84,14 @@ describe('GlobalErrors', function() { }); it('throws when no listener is passed to #popListener', function() { - var errors = new jasmineUnderTest.GlobalErrors({}); + const errors = new jasmineUnderTest.GlobalErrors({}); expect(function() { errors.popListener(); }).toThrowError('popListener expects a listener'); }); it('uninstalls itself, putting back a previous callback', function() { - var originalCallback = jasmine.createSpy('error'), + const originalCallback = jasmine.createSpy('error'), fakeGlobal = { onerror: originalCallback }, errors = new jasmineUnderTest.GlobalErrors(fakeGlobal); @@ -107,7 +107,7 @@ describe('GlobalErrors', function() { }); it('rethrows the original error when there is no handler', function() { - var fakeGlobal = {}, + const fakeGlobal = {}, errors = new jasmineUnderTest.GlobalErrors(fakeGlobal), originalError = new Error('nope'); @@ -123,7 +123,7 @@ describe('GlobalErrors', function() { }); it('reports uncaught exceptions in node.js', function() { - var fakeGlobal = { + const fakeGlobal = { process: { on: jasmine.createSpy('process.on'), removeListener: jasmine.createSpy('process.removeListener'), @@ -150,7 +150,7 @@ describe('GlobalErrors', function() { errors.pushListener(handler); - var addedListener = fakeGlobal.process.on.calls.argsFor(0)[1]; + const addedListener = fakeGlobal.process.on.calls.argsFor(0)[1]; addedListener(new Error('bar')); expect(handler).toHaveBeenCalledWith(new Error('bar')); @@ -172,7 +172,7 @@ describe('GlobalErrors', function() { describe('Reporting unhandled promise rejections in node.js', function() { it('reports rejections with `Error` reasons', function() { - var fakeGlobal = { + const fakeGlobal = { process: { on: jasmine.createSpy('process.on'), removeListener: jasmine.createSpy('process.removeListener'), @@ -199,7 +199,7 @@ describe('GlobalErrors', function() { errors.pushListener(handler); - var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1]; + const addedListener = fakeGlobal.process.on.calls.argsFor(1)[1]; addedListener(new Error('bar')); expect(handler).toHaveBeenCalledWith(new Error('bar')); @@ -220,7 +220,7 @@ describe('GlobalErrors', function() { }); it('reports rejections with non-`Error` reasons', function() { - var fakeGlobal = { + const fakeGlobal = { process: { on: jasmine.createSpy('process.on'), removeListener: function() {}, @@ -239,7 +239,7 @@ describe('GlobalErrors', function() { expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual( 'unhandledRejection' ); - var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1]; + const addedListener = fakeGlobal.process.on.calls.argsFor(1)[1]; addedListener(17); expect(handler).toHaveBeenCalledWith( @@ -252,7 +252,7 @@ describe('GlobalErrors', function() { }); it('reports rejections with no reason provided', function() { - var fakeGlobal = { + const fakeGlobal = { process: { on: jasmine.createSpy('process.on'), removeListener: function() {}, @@ -271,7 +271,7 @@ describe('GlobalErrors', function() { expect(fakeGlobal.process.on.calls.argsFor(1)[0]).toEqual( 'unhandledRejection' ); - var addedListener = fakeGlobal.process.on.calls.argsFor(1)[1]; + const addedListener = fakeGlobal.process.on.calls.argsFor(1)[1]; addedListener(undefined); expect(handler).toHaveBeenCalledWith( @@ -286,7 +286,7 @@ describe('GlobalErrors', function() { describe('Reporting unhandled promise rejections in the browser', function() { it('subscribes and unsubscribes from the unhandledrejection event', function() { - var fakeGlobal = jasmine.createSpyObj('globalErrors', [ + const fakeGlobal = jasmine.createSpyObj('globalErrors', [ 'addEventListener', 'removeEventListener', 'onerror' @@ -299,7 +299,7 @@ describe('GlobalErrors', function() { jasmine.any(Function) ); - var addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; + const addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; errors.uninstall(); expect(fakeGlobal.removeEventListener).toHaveBeenCalledWith( @@ -309,7 +309,7 @@ describe('GlobalErrors', function() { }); it('reports rejections whose reason is a string', function() { - var fakeGlobal = jasmine.createSpyObj('globalErrors', [ + const fakeGlobal = jasmine.createSpyObj('globalErrors', [ 'addEventListener', 'removeEventListener', 'onerror' @@ -320,14 +320,14 @@ describe('GlobalErrors', function() { errors.install(); errors.pushListener(handler); - var addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; + const addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; addedListener({ reason: 'nope' }); expect(handler).toHaveBeenCalledWith('Unhandled promise rejection: nope'); }); it('reports rejections whose reason is an Error', function() { - var fakeGlobal = jasmine.createSpyObj('globalErrors', [ + const fakeGlobal = jasmine.createSpyObj('globalErrors', [ 'addEventListener', 'removeEventListener', 'onerror' @@ -338,15 +338,8 @@ describe('GlobalErrors', function() { errors.install(); errors.pushListener(handler); - var addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; - var reason; - - try { - // Throwing ensures that we get a stack property in all browsers - throw new Error('bar'); - } catch (e) { - reason = e; - } + const addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; + const reason = new Error('bar'); addedListener({ reason: reason }); @@ -361,7 +354,7 @@ describe('GlobalErrors', function() { describe('Enabling external interception of reported rejections by overriding global.onerror', function() { it('overriding global.onerror intercepts rejections whose reason is a string', function() { - var fakeGlobal = jasmine.createSpyObj('globalErrors', [ + const fakeGlobal = jasmine.createSpyObj('globalErrors', [ 'addEventListener' ]), handler = jasmine.createSpy('errorHandler'), @@ -373,7 +366,7 @@ describe('GlobalErrors', function() { fakeGlobal.onerror = hijackHandler; - var addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; + const addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; addedListener({ reason: 'nope' }); expect(hijackHandler).toHaveBeenCalledWith( @@ -383,7 +376,7 @@ describe('GlobalErrors', function() { }); it('overriding global.onerror intercepts rejections whose reason is an Error', function() { - var fakeGlobal = jasmine.createSpyObj('globalErrors', [ + const fakeGlobal = jasmine.createSpyObj('globalErrors', [ 'addEventListener' ]), handler = jasmine.createSpy('errorHandler'), @@ -395,15 +388,8 @@ describe('GlobalErrors', function() { fakeGlobal.onerror = hijackHandler; - var addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; - var reason; - - try { - // Throwing ensures that we get a stack property in all browsers - throw new Error('bar'); - } catch (e) { - reason = e; - } + const addedListener = fakeGlobal.addEventListener.calls.argsFor(0)[1]; + const reason = new Error('bar'); addedListener({ reason: reason }); diff --git a/spec/core/JsApiReporterSpec.js b/spec/core/JsApiReporterSpec.js index ea3e67b7..28f9e3b8 100644 --- a/spec/core/JsApiReporterSpec.js +++ b/spec/core/JsApiReporterSpec.js @@ -1,6 +1,6 @@ describe('JsApiReporter', function() { it('knows when a full environment is started', function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); expect(reporter.started).toBe(false); expect(reporter.finished).toBe(false); @@ -12,7 +12,7 @@ describe('JsApiReporter', function() { }); it('knows when a full environment is done', function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); expect(reporter.started).toBe(false); expect(reporter.finished).toBe(false); @@ -24,13 +24,13 @@ describe('JsApiReporter', function() { }); it("defaults to 'loaded' status", function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); expect(reporter.status()).toEqual('loaded'); }); it("reports 'started' when Jasmine has started", function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); reporter.jasmineStarted(); @@ -38,7 +38,7 @@ describe('JsApiReporter', function() { }); it("reports 'done' when Jasmine is done", function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); reporter.jasmineDone({}); @@ -46,14 +46,14 @@ describe('JsApiReporter', function() { }); it('tracks a suite', function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); reporter.suiteStarted({ id: 123, description: 'A suite' }); - var suites = reporter.suites(); + const suites = reporter.suites(); expect(suites).toEqual({ 123: { id: 123, description: 'A suite' } }); @@ -69,7 +69,7 @@ describe('JsApiReporter', function() { }); describe('#specResults', function() { - var reporter, specResult1, specResult2; + let reporter, specResult1, specResult2; beforeEach(function() { reporter = new jasmineUnderTest.JsApiReporter({}); specResult1 = { @@ -99,7 +99,7 @@ describe('JsApiReporter', function() { }); describe('#suiteResults', function() { - var reporter, suiteStarted1, suiteResult1, suiteResult2; + let reporter, suiteStarted1, suiteResult1, suiteResult2; beforeEach(function() { reporter = new jasmineUnderTest.JsApiReporter({}); suiteStarted1 = { @@ -137,7 +137,7 @@ describe('JsApiReporter', function() { describe('#executionTime', function() { it('should start the timer when jasmine starts', function() { - var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), + const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), reporter = new jasmineUnderTest.JsApiReporter({ timer: timerSpy }); @@ -147,7 +147,7 @@ describe('JsApiReporter', function() { }); it('should return the time it took the specs to run, in ms', function() { - var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), + const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), reporter = new jasmineUnderTest.JsApiReporter({ timer: timerSpy }); @@ -159,7 +159,7 @@ describe('JsApiReporter', function() { describe("when the specs haven't finished being run", function() { it('should return undefined', function() { - var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), + const timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']), reporter = new jasmineUnderTest.JsApiReporter({ timer: timerSpy }); @@ -171,7 +171,7 @@ describe('JsApiReporter', function() { describe('#runDetails', function() { it('should have details about the run', function() { - var reporter = new jasmineUnderTest.JsApiReporter({}); + const reporter = new jasmineUnderTest.JsApiReporter({}); reporter.jasmineDone({ some: { run: 'details' } }); expect(reporter.runDetails).toEqual({ some: { run: 'details' } }); }); diff --git a/spec/core/MockDateSpec.js b/spec/core/MockDateSpec.js index aaeece54..b4ce40dd 100644 --- a/spec/core/MockDateSpec.js +++ b/spec/core/MockDateSpec.js @@ -1,6 +1,6 @@ describe('FakeDate', function() { it('does not fail if no global date is found', function() { - var fakeGlobal = {}, + const fakeGlobal = {}, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); expect(function() { @@ -11,11 +11,13 @@ describe('FakeDate', function() { }); it('replaces the global Date when it is installed', function() { - var globalDate = jasmine.createSpy('global Date').and.callFake(function() { - return { - getTime: function() {} - }; - }), + const globalDate = jasmine + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() {} + }; + }), fakeGlobal = { Date: globalDate }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); @@ -26,11 +28,13 @@ describe('FakeDate', function() { }); it('replaces the global Date on uninstall', function() { - var globalDate = jasmine.createSpy('global Date').and.callFake(function() { - return { - getTime: function() {} - }; - }), + const globalDate = jasmine + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() {} + }; + }), fakeGlobal = { Date: globalDate }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); @@ -41,13 +45,15 @@ describe('FakeDate', function() { }); it('takes the current time as the base when installing without parameters', function() { - var globalDate = jasmine.createSpy('global Date').and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), + const globalDate = jasmine + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }), fakeGlobal = { Date: globalDate }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); @@ -59,7 +65,7 @@ describe('FakeDate', function() { }); it('can accept a date as time base when installing', function() { - var fakeGlobal = { Date: Date }, + const fakeGlobal = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal), baseDate = new Date(); @@ -70,7 +76,7 @@ describe('FakeDate', function() { }); it('makes real dates', function() { - var fakeGlobal = { Date: Date }, + const fakeGlobal = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -79,17 +85,19 @@ describe('FakeDate', function() { }); it('fakes current time when using Date.now()', function() { - var globalDate = jasmine.createSpy('global Date').and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), + const globalDate = jasmine + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }), fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; - var mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + const mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -97,17 +105,19 @@ describe('FakeDate', function() { }); it('makes time passes using tick', function() { - var globalDate = jasmine.createSpy('global Date').and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), + const globalDate = jasmine + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }), fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; - var mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + const mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -121,17 +131,19 @@ describe('FakeDate', function() { }); it('allows to increase 0 milliseconds using tick', function() { - var globalDate = jasmine.createSpy('global Date').and.callFake(function() { - return { - getTime: function() { - return 1000; - } - }; - }), + const globalDate = jasmine + .createSpy('global Date') + .and.callFake(function() { + return { + getTime: function() { + return 1000; + } + }; + }), fakeGlobal = { Date: globalDate }; globalDate.now = function() {}; - var mockDate = new jasmineUnderTest.MockDate(fakeGlobal); + const mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); @@ -143,40 +155,40 @@ describe('FakeDate', function() { }); it('allows creation of a Date in a different time than the mocked time', function() { - var fakeGlobal = { Date: Date }, + const fakeGlobal = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); - var otherDate = new fakeGlobal.Date(2013, 9, 23, 0, 0, 1, 0); + const otherDate = new fakeGlobal.Date(2013, 9, 23, 0, 0, 1, 0); expect(otherDate.getTime()).toEqual( new Date(2013, 9, 23, 0, 0, 1, 0).getTime() ); }); it("allows creation of a Date that isn't fully specified", function() { - var fakeGlobal = { Date: Date }, + const fakeGlobal = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); - var otherDate = new fakeGlobal.Date(2013, 9, 23); + const otherDate = new fakeGlobal.Date(2013, 9, 23); expect(otherDate.getTime()).toEqual(new Date(2013, 9, 23).getTime()); }); it('allows creation of a Date with millis', function() { - var fakeGlobal = { Date: Date }, + const fakeGlobal = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal), now = new Date(2014, 3, 15).getTime(); mockDate.install(); - var otherDate = new fakeGlobal.Date(now); + const otherDate = new fakeGlobal.Date(now); expect(otherDate.getTime()).toEqual(now); }); it('copies all Date properties to the mocked date', function() { - var fakeGlobal = { Date: Date }, + const fakeGlobal = { Date: Date }, mockDate = new jasmineUnderTest.MockDate(fakeGlobal); mockDate.install(); diff --git a/spec/core/PrettyPrintSpec.js b/spec/core/PrettyPrintSpec.js index 0853b7ab..8d75c440 100644 --- a/spec/core/PrettyPrintSpec.js +++ b/spec/core/PrettyPrintSpec.js @@ -1,6 +1,6 @@ describe('PrettyPrinter', function() { it('should wrap strings in single quotes', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp('some string')).toEqual("'some string'"); expect(pp("som' string")).toEqual("'som' string'"); }); @@ -14,7 +14,7 @@ describe('PrettyPrinter', function() { }); it('should stringify primitives properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(true)).toEqual('true'); expect(pp(false)).toEqual('false'); expect(pp(null)).toEqual('null'); @@ -26,23 +26,23 @@ describe('PrettyPrinter', function() { describe('stringify sets', function() { it('should stringify sets properly', function() { - var set = new Set(); + const set = new Set(); set.add(1); set.add(2); - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(set)).toEqual('Set( 1, 2 )'); }); it('should truncate sets with more elements than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() { - var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; + const originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; - var set = new Set(); + const set = new Set(); set.add('a'); set.add('b'); set.add('c'); - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(set)).toEqual("Set( 'a', 'b', ... )"); } finally { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize; @@ -52,22 +52,22 @@ describe('PrettyPrinter', function() { describe('stringify maps', function() { it('should stringify maps properly', function() { - var map = new Map(); + const map = new Map(); map.set(1, 2); - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(map)).toEqual('Map( [ 1, 2 ] )'); }); it('should truncate maps with more elements than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() { - var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; + const originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; - var map = new Map(); + const map = new Map(); map.set('a', 1); map.set('b', 2); map.set('c', 3); - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(map)).toEqual("Map( [ 'a', 1 ], [ 'b', 2 ], ... )"); } finally { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize; @@ -77,7 +77,7 @@ describe('PrettyPrinter', function() { describe('stringify arrays', function() { it('should stringify arrays properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp([1, 2])).toEqual('[ 1, 2 ]'); expect(pp([1, 'foo', {}, jasmine.undefined, null])).toEqual( "[ 1, 'foo', Object({ }), undefined, null ]" @@ -85,9 +85,9 @@ describe('PrettyPrinter', function() { }); it('should truncate arrays that are longer than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH', function() { - var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; - var array = [1, 2, 3]; - var pp = jasmineUnderTest.makePrettyPrinter(); + const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; + const array = [1, 2, 3]; + const pp = jasmineUnderTest.makePrettyPrinter(); try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; @@ -98,25 +98,25 @@ describe('PrettyPrinter', function() { }); it('should stringify arrays with properties properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var arr = [1, 2]; + const pp = jasmineUnderTest.makePrettyPrinter(); + const arr = [1, 2]; arr.foo = 'bar'; arr.baz = {}; expect(pp(arr)).toEqual("[ 1, 2, foo: 'bar', baz: Object({ }) ]"); }); it('should stringify empty arrays with properties properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var empty = []; + const pp = jasmineUnderTest.makePrettyPrinter(); + const empty = []; empty.foo = 'bar'; empty.baz = {}; expect(pp(empty)).toEqual("[ foo: 'bar', baz: Object({ }) ]"); }); it('should stringify long arrays with properties properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; - var long = [1, 2, 3]; + const pp = jasmineUnderTest.makePrettyPrinter(); + const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; + const long = [1, 2, 3]; long.foo = 'bar'; long.baz = {}; @@ -131,22 +131,22 @@ describe('PrettyPrinter', function() { }); it('should indicate circular array references', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var array1 = [1, 2]; - var array2 = [array1]; + const pp = jasmineUnderTest.makePrettyPrinter(); + const array1 = [1, 2]; + const array2 = [array1]; array1.push(array2); expect(pp(array1)).toEqual('[ 1, 2, [ ] ]'); }); it('should not indicate circular references incorrectly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var array = [[1]]; + const pp = jasmineUnderTest.makePrettyPrinter(); + const array = [[1]]; expect(pp(array)).toEqual('[ [ 1 ] ]'); }); }); it('should stringify objects properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp({ foo: 'bar' })).toEqual("Object({ foo: 'bar' })"); expect( pp({ @@ -164,14 +164,14 @@ describe('PrettyPrinter', function() { }); it('should stringify objects that almost look like DOM nodes', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp({ nodeType: 1 })).toEqual('Object({ nodeType: 1 })'); }); it('should truncate objects with too many keys', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; - var long = { a: 1, b: 2, c: 3 }; + const pp = jasmineUnderTest.makePrettyPrinter(); + const originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH; + const long = { a: 1, b: 2, c: 3 }; try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; @@ -182,7 +182,7 @@ describe('PrettyPrinter', function() { }); function withMaxChars(maxChars, fn) { - var originalMaxChars = jasmineUnderTest.MAX_PRETTY_PRINT_CHARS; + const originalMaxChars = jasmineUnderTest.MAX_PRETTY_PRINT_CHARS; try { jasmineUnderTest.MAX_PRETTY_PRINT_CHARS = maxChars; @@ -193,8 +193,8 @@ describe('PrettyPrinter', function() { } it('should truncate outputs that are too long', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var big = [{ a: 1, b: 'a long string' }, {}]; + const pp = jasmineUnderTest.makePrettyPrinter(); + const big = [{ a: 1, b: 'a long string' }, {}]; withMaxChars(34, function() { expect(pp(big)).toEqual("[ Object({ a: 1, b: 'a long st ..."); @@ -202,7 +202,7 @@ describe('PrettyPrinter', function() { }); it('should not serialize more objects after hitting MAX_PRETTY_PRINT_CHARS', function() { - var a = { + const a = { jasmineToString: function() { return 'object a'; } @@ -232,25 +232,25 @@ describe('PrettyPrinter', function() { }); it("should print 'null' as the constructor of an object with its own constructor property", function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp({ constructor: function() {} })).toContain('null({'); expect(pp({ constructor: 'foo' })).toContain('null({'); }); it('should not include inherited properties when stringifying an object', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var SomeClass = function SomeClass() {}; + const pp = jasmineUnderTest.makePrettyPrinter(); + const SomeClass = function SomeClass() {}; SomeClass.prototype.foo = 'inherited foo'; - var instance = new SomeClass(); + const instance = new SomeClass(); instance.bar = 'my own bar'; expect(pp(instance)).toEqual("SomeClass({ bar: 'my own bar' })"); }); it('should not recurse objects and arrays more deeply than jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var originalMaxDepth = jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH; - var nestedObject = { level1: { level2: { level3: { level4: 'leaf' } } } }; - var nestedArray = [1, [2, [3, [4, 'leaf']]]]; + const pp = jasmineUnderTest.makePrettyPrinter(); + const originalMaxDepth = jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH; + const nestedObject = { level1: { level2: { level3: { level4: 'leaf' } } } }; + const nestedArray = [1, [2, [3, [4, 'leaf']]]]; try { jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 2; @@ -276,8 +276,8 @@ describe('PrettyPrinter', function() { }); it('should stringify immutable circular objects', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var frozenObject = { foo: { bar: 'baz' } }; + const pp = jasmineUnderTest.makePrettyPrinter(); + let frozenObject = { foo: { bar: 'baz' } }; frozenObject.circular = frozenObject; frozenObject = Object.freeze(frozenObject); expect(pp(frozenObject)).toEqual( @@ -286,13 +286,13 @@ describe('PrettyPrinter', function() { }); it('should stringify RegExp objects properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(/x|y|z/)).toEqual('/x|y|z/'); }); it('should indicate circular object references', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var sampleValue = { foo: 'hello' }; + const pp = jasmineUnderTest.makePrettyPrinter(); + const sampleValue = { foo: 'hello' }; sampleValue.nested = sampleValue; expect(pp(sampleValue)).toEqual( "Object({ foo: 'hello', nested: })" @@ -300,8 +300,8 @@ describe('PrettyPrinter', function() { }); it('should indicate getters on objects as such', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var sampleValue = { + const pp = jasmineUnderTest.makePrettyPrinter(); + const sampleValue = { id: 1, get calculatedValue() { throw new Error("don't call me!"); @@ -313,25 +313,25 @@ describe('PrettyPrinter', function() { }); it('should not do HTML escaping of strings', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp('some html string &', false)).toEqual( "'some html string &'" ); }); it('should abbreviate the global (usually window) object', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(jasmine.getGlobal())).toEqual(''); }); it('should stringify Date objects properly', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var now = new Date(); + const pp = jasmineUnderTest.makePrettyPrinter(); + const now = new Date(); expect(pp(now)).toEqual('Date(' + now.toString() + ')'); }); describe('with a spy object', function() { - var env, pp; + let env, pp; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -343,11 +343,11 @@ describe('PrettyPrinter', function() { }); it('should stringify spy objects properly', function() { - var TestObject = { + const TestObject = { someFunction: function() {} }; - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return []; }, @@ -363,13 +363,13 @@ describe('PrettyPrinter', function() { }); it('should stringify spyOn toString properly', function() { - var TestObject = { + const TestObject = { someFunction: function() {} }, env = new jasmineUnderTest.Env(), pp = jasmineUnderTest.makePrettyPrinter(); - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return []; }, @@ -379,15 +379,15 @@ describe('PrettyPrinter', function() { }); spyRegistry.spyOn(TestObject, 'toString'); - var testSpyObj = env.createSpyObj('TheClassName', ['toString']); + const testSpyObj = env.createSpyObj('TheClassName', ['toString']); expect(pp(testSpyObj)).toEqual('spy on TheClassName.toString'); }); }); it('should stringify objects that implement jasmineToString', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var obj = { + const pp = jasmineUnderTest.makePrettyPrinter(); + const obj = { jasmineToString: function() { return 'strung'; } @@ -397,8 +397,8 @@ describe('PrettyPrinter', function() { }); it('should pass itself to jasmineToString', function() { - var pp = jasmineUnderTest.makePrettyPrinter([]); - var obj = { + const pp = jasmineUnderTest.makePrettyPrinter([]); + const obj = { jasmineToString: jasmine.createSpy('jasmineToString').and.returnValue('') }; @@ -407,8 +407,8 @@ describe('PrettyPrinter', function() { }); it('should stringify objects that implement custom toString', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var obj = { + const pp = jasmineUnderTest.makePrettyPrinter(); + const obj = { toString: function() { return 'my toString'; } @@ -418,7 +418,7 @@ describe('PrettyPrinter', function() { // Simulate object from another global context (e.g. an iframe or Web Worker) that does not actually have a custom // toString despite obj.toString !== Object.prototype.toString - var objFromOtherContext = { + const objFromOtherContext = { foo: 'bar', toString: function() { return Object.prototype.toString.call(this); @@ -431,8 +431,8 @@ describe('PrettyPrinter', function() { }); it("should stringify objects have have a toString that isn't a function", function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var obj = { + const pp = jasmineUnderTest.makePrettyPrinter(); + const obj = { toString: 'foo' }; @@ -440,30 +440,30 @@ describe('PrettyPrinter', function() { }); it('should stringify objects from anonymous constructors with custom toString', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var MyAnonymousConstructor = (function() { + const pp = jasmineUnderTest.makePrettyPrinter(); + const MyAnonymousConstructor = (function() { return function() {}; })(); MyAnonymousConstructor.toString = function() { return ''; }; - var a = new MyAnonymousConstructor(); + const a = new MyAnonymousConstructor(); expect(pp(a)).toEqual('({ })'); }); it('should handle objects with null prototype', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var obj = Object.create(null); + const pp = jasmineUnderTest.makePrettyPrinter(); + const obj = Object.create(null); obj.foo = 'bar'; expect(pp(obj)).toEqual("null({ foo: 'bar' })"); }); it('should gracefully handle objects with invalid toString implementations', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var obj = { + const pp = jasmineUnderTest.makePrettyPrinter(); + const obj = { foo: { toString: function() { // Invalid: toString returning a number @@ -499,7 +499,7 @@ describe('PrettyPrinter', function() { describe('Custom object formatters', function() { it('should use the first custom object formatter that does not return undefined', function() { - var customObjectFormatters = [ + const customObjectFormatters = [ function() { return undefined; }, @@ -517,7 +517,7 @@ describe('PrettyPrinter', function() { }); it('should fall back to built in logic if all custom object formatters return undefined', function() { - var customObjectFormatters = [ + const customObjectFormatters = [ function() { return undefined; } @@ -531,7 +531,7 @@ describe('PrettyPrinter', function() { describe('#customFormat_', function() { it('should use the first custom object formatter that does not return undefined', function() { - var customObjectFormatters = [ + const customObjectFormatters = [ function() { return undefined; }, @@ -549,7 +549,7 @@ describe('PrettyPrinter', function() { }); it('should return undefined if all custom object formatters return undefined', function() { - var customObjectFormatters = [ + const customObjectFormatters = [ function() { return undefined; } diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index 40c83c99..67a82902 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -1,6 +1,6 @@ describe('QueueRunner', function() { it("runs all the functions it's passed", function() { - var calls = [], + const calls = [], queueableFn1 = { fn: jasmine.createSpy('fn1') }, queueableFn2 = { fn: jasmine.createSpy('fn2') }, queueRunner = new jasmineUnderTest.QueueRunner({ @@ -19,9 +19,10 @@ describe('QueueRunner', function() { }); it("calls each function with a consistent 'this'-- an empty object", function() { - var queueableFn1 = { fn: jasmine.createSpy('fn1') }, - queueableFn2 = { fn: jasmine.createSpy('fn2') }, - queueableFn3 = { + const queueableFn1 = { fn: jasmine.createSpy('fn1') }; + const queueableFn2 = { fn: jasmine.createSpy('fn2') }; + let asyncContext; + const queueableFn3 = { fn: function(done) { asyncContext = this; done(); @@ -29,12 +30,11 @@ describe('QueueRunner', function() { }, queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [queueableFn1, queueableFn2, queueableFn3] - }), - asyncContext; + }); queueRunner.execute(); - var context = queueableFn1.fn.calls.first().object; + const context = queueableFn1.fn.calls.first().object; expect(context).toEqual(new jasmineUnderTest.UserContext()); expect(queueableFn2.fn.calls.first().object).toBe(context); expect(asyncContext).toBe(context); @@ -53,7 +53,7 @@ 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) {}); - var onComplete = jasmine.createSpy('onComplete'), + const onComplete = jasmine.createSpy('onComplete'), beforeCallback = jasmine.createSpy('beforeCallback'), fnCallback = jasmine.createSpy('fnCallback'), afterCallback = jasmine.createSpy('afterCallback'), @@ -104,7 +104,7 @@ describe('QueueRunner', function() { }); it('explicitly fails an async function with a provided fail function and moves to the next function', function() { - var queueableFn1 = { + const queueableFn1 = { fn: function(done) { setTimeout(function() { done.fail('foo'); @@ -131,7 +131,7 @@ describe('QueueRunner', function() { describe('When next is called with an argument', function() { it('explicitly fails and moves to the next function', function() { - var err = 'anything except undefined', + const err = 'anything except undefined', queueableFn1 = { fn: function(done) { setTimeout(function() { @@ -165,7 +165,7 @@ 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) { - var err = new Error('foo'), + const err = new Error('foo'), queueableFn1 = { fn: function() { return Promise.resolve(err); @@ -187,7 +187,7 @@ describe('QueueRunner', function() { }); it('does not log a deprecation', function(done) { - var err = new Error('foo'), + const err = new Error('foo'), queueableFn1 = { fn: function() { return Promise.resolve(err); @@ -209,7 +209,7 @@ describe('QueueRunner', function() { describe('and the argument is not an Error', function() { it('does not log a deprecation or report a failure', function(done) { - var queueableFn1 = { + const queueableFn1 = { fn: function() { return Promise.resolve('not an error'); } @@ -234,7 +234,7 @@ describe('QueueRunner', function() { }); it('does not cause an explicit fail if execution is being stopped', function() { - var err = new jasmineUnderTest.StopExecutionError('foo'), + const err = new jasmineUnderTest.StopExecutionError('foo'), queueableFn1 = { fn: function(done) { setTimeout(function() { @@ -261,7 +261,7 @@ describe('QueueRunner', function() { }); it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() { - var timeout = 3, + const timeout = 3, // eslint-disable-next-line no-unused-vars beforeFn = { fn: function(done) {}, type: 'before', timeout: timeout }, queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' }, @@ -284,22 +284,22 @@ describe('QueueRunner', function() { }); it('does not call onMultipleDone if an asynchrnous function completes after timing out', function() { - var timeout = 3, - queueableFn = { - fn: function(done) { - queueableFnDone = done; - }, - type: 'queueable', - timeout: timeout + const timeout = 3; + let queueableFnDone; + const queueableFn = { + fn: function(done) { + queueableFnDone = done; }, - onComplete = jasmine.createSpy('onComplete'), - onMultipleDone = jasmine.createSpy('onMultipleDone'), - queueRunner = new jasmineUnderTest.QueueRunner({ - queueableFns: [queueableFn], - onComplete: onComplete, - onMultipleDone: onMultipleDone - }), - queueableFnDone; + type: 'queueable', + timeout: timeout + }; + const onComplete = jasmine.createSpy('onComplete'); + const onMultipleDone = jasmine.createSpy('onMultipleDone'); + const queueRunner = new jasmineUnderTest.QueueRunner({ + queueableFns: [queueableFn], + onComplete: onComplete, + onMultipleDone: onMultipleDone + }); queueRunner.execute(); jasmine.clock().tick(timeout); @@ -311,7 +311,7 @@ describe('QueueRunner', function() { it('by default does not set a timeout for asynchronous functions', function() { // eslint-disable-next-line no-unused-vars - var beforeFn = { fn: function(done) {} }, + const beforeFn = { fn: function(done) {} }, queueableFn = { fn: jasmine.createSpy('fn') }, onComplete = jasmine.createSpy('onComplete'), onException = jasmine.createSpy('onException'), @@ -332,7 +332,7 @@ describe('QueueRunner', function() { }); it('clears the timeout when an async function throws an exception, to prevent additional exception reporting', function() { - var queueableFn = { + const queueableFn = { // eslint-disable-next-line no-unused-vars fn: function(done) { throw new Error('error!'); @@ -356,7 +356,7 @@ describe('QueueRunner', function() { }); it('clears the timeout when the done callback is called', function() { - var queueableFn = { + const queueableFn = { fn: function(done) { done(); } @@ -379,7 +379,7 @@ describe('QueueRunner', function() { }); it('only moves to the next spec the first time you call done', function() { - var queueableFn = { + const queueableFn = { fn: function(done) { done(); done(); @@ -399,7 +399,7 @@ describe('QueueRunner', function() { }); it('does not move to the next spec if done is called after an exception has ended the spec', function() { - var queueableFn = { + const queueableFn = { fn: function(done) { setTimeout(done, 1); throw new Error('error!'); @@ -421,22 +421,22 @@ describe('QueueRunner', function() { it('should return a null when you call done', function() { // Some promises want handlers to return anything but undefined to help catch "forgotten returns". - var doneReturn, - queueableFn = { - fn: function(done) { - doneReturn = done(); - } - }, - queueRunner = new jasmineUnderTest.QueueRunner({ - queueableFns: [queueableFn] - }); + let doneReturn; + const queueableFn = { + fn: function(done) { + doneReturn = done(); + } + }; + const queueRunner = new jasmineUnderTest.QueueRunner({ + queueableFns: [queueableFn] + }); queueRunner.execute(); expect(doneReturn).toBe(null); }); it('continues running functions when an exception is thrown in async code without timing out', function() { - var queueableFn = { + const queueableFn = { // eslint-disable-next-line no-unused-vars fn: function(done) { throwAsync(); @@ -488,7 +488,7 @@ describe('QueueRunner', function() { }); it('handles exceptions thrown while waiting for the stack to clear', function() { - var queueableFn = { + const queueableFn = { fn: function(done) { done(); } @@ -539,7 +539,7 @@ describe('QueueRunner', function() { }); it('runs the function asynchronously, advancing once the promise is settled', function() { - var onComplete = jasmine.createSpy('onComplete'), + const onComplete = jasmine.createSpy('onComplete'), fnCallback = jasmine.createSpy('fnCallback'), p1 = new StubPromise(), p2 = new StubPromise(), @@ -580,7 +580,7 @@ describe('QueueRunner', function() { }); it('handles a rejected promise like an unhandled exception', function() { - var promise = new StubPromise(), + const promise = new StubPromise(), queueableFn1 = { fn: function() { setTimeout(function() { @@ -608,7 +608,7 @@ describe('QueueRunner', function() { }); it('issues an error if the function also takes a parameter', function() { - var queueableFn = { + const queueableFn = { // eslint-disable-next-line no-unused-vars fn: function(done) { return new StubPromise(); @@ -633,7 +633,7 @@ describe('QueueRunner', function() { it('issues a more specific error if the function is `async`', function() { eval('var fn = async function(done){};'); - var onException = jasmine.createSpy('onException'), + const onException = jasmine.createSpy('onException'), queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [{ fn: fn }], onException: onException @@ -651,7 +651,7 @@ describe('QueueRunner', function() { }); it('passes the error instance to exception handlers in HTML browsers', function() { - var error = new Error('fake error'), + const error = new Error('fake error'), onExceptionCallback = jasmine.createSpy('on exception callback'), queueRunner = new jasmineUnderTest.QueueRunner({ onException: onExceptionCallback @@ -664,7 +664,7 @@ describe('QueueRunner', function() { }); it('passes the first argument to exception handlers for compatibility', function() { - var error = new Error('fake error'), + const error = new Error('fake error'), onExceptionCallback = jasmine.createSpy('on exception callback'), queueRunner = new jasmineUnderTest.QueueRunner({ onException: onExceptionCallback @@ -677,7 +677,7 @@ describe('QueueRunner', function() { }); it('calls exception handlers when an exception is thrown in a fn', function() { - var queueableFn = { + const queueableFn = { type: 'queueable', fn: function() { throw new Error('fake error'); @@ -695,7 +695,7 @@ describe('QueueRunner', function() { }); it('continues running the functions even after an exception is thrown in an async spec', function() { - var queueableFn = { + const queueableFn = { // eslint-disable-next-line no-unused-vars fn: function(done) { throw new Error('error'); @@ -773,7 +773,7 @@ describe('QueueRunner', function() { describe('When configured to complete on first error', function() { it('skips to cleanup functions on the first exception', function() { - var queueableFn = { + const queueableFn = { fn: function() { throw new Error('error'); } @@ -799,7 +799,7 @@ describe('QueueRunner', function() { }); it('does not skip when a cleanup function throws', function() { - var queueableFn = { fn: function() {} }, + const queueableFn = { fn: function() {} }, cleanupFn1 = { fn: function() { throw new Error('error'); @@ -829,27 +829,30 @@ describe('QueueRunner', function() { }); it('skips to cleanup functions once the fn completes after an unhandled exception', function() { - var errorListeners = [], - queueableFn = { - fn: function(done) { - queueableFnDone = done; + const errorListeners = []; + let queueableFnDone; + const queueableFn = { + fn: function(done) { + queueableFnDone = done; + } + }; + const nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }; + const cleanupFn = { + fn: jasmine.createSpy('cleanup'), + type: 'specCleanup' + }; + const queueRunner = new jasmineUnderTest.QueueRunner({ + globalErrors: { + pushListener: function(f) { + errorListeners.push(f); + }, + popListener: function() { + errorListeners.pop(); } }, - nextQueueableFn = { fn: jasmine.createSpy('nextFunction') }, - cleanupFn = { fn: jasmine.createSpy('cleanup'), type: 'specCleanup' }, - queueRunner = new jasmineUnderTest.QueueRunner({ - globalErrors: { - pushListener: function(f) { - errorListeners.push(f); - }, - popListener: function() { - errorListeners.pop(); - } - }, - queueableFns: [queueableFn, nextQueueableFn, cleanupFn], - SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy - }), - queueableFnDone; + queueableFns: [queueableFn, nextQueueableFn, cleanupFn], + SkipPolicy: jasmineUnderTest.CompleteOnFirstErrorSkipPolicy + }); queueRunner.execute(); errorListeners[errorListeners.length - 1](new Error('error')); @@ -860,7 +863,7 @@ describe('QueueRunner', function() { }); it('skips to cleanup functions when next.fail is called', function() { - var queueableFn = { + const queueableFn = { fn: function(done) { done.fail('nope'); } @@ -879,7 +882,7 @@ describe('QueueRunner', function() { }); it('skips to cleanup functions when next is called with an Error', function() { - var queueableFn = { + const queueableFn = { fn: function(done) { done(new Error('nope')); } @@ -903,7 +906,7 @@ describe('QueueRunner', function() { }); it('calls a provided complete callback when done', function() { - var queueableFn = { fn: jasmine.createSpy('fn') }, + const queueableFn = { fn: jasmine.createSpy('fn') }, completeCallback = jasmine.createSpy('completeCallback'), queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [queueableFn], @@ -925,7 +928,7 @@ describe('QueueRunner', function() { }); it('calls a provided stack clearing function when done', function() { - var asyncFn = { + const asyncFn = { fn: function(done) { done(); } @@ -954,16 +957,16 @@ describe('QueueRunner', function() { describe('when user context has not been defined', function() { beforeEach(function() { - var fn; + const fn = jasmine.createSpy('fn1'); - this.fn = fn = jasmine.createSpy('fn1'); + this.fn = fn; this.queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [{ fn: fn }] }); }); it('runs the functions on the scope of a UserContext', function() { - var context; + let context; this.fn.and.callFake(function() { context = this; }); @@ -976,9 +979,10 @@ describe('QueueRunner', function() { describe('when user context has been defined', function() { beforeEach(function() { - var fn, context; + const fn = jasmine.createSpy('fn1'); + let context; - this.fn = fn = jasmine.createSpy('fn1'); + this.fn = fn; this.context = context = new jasmineUnderTest.UserContext(); this.queueRunner = new jasmineUnderTest.QueueRunner({ queueableFns: [{ fn: fn }], @@ -987,7 +991,7 @@ describe('QueueRunner', function() { }); it('runs the functions on the scope of a UserContext', function() { - var context; + let context; this.fn.and.callFake(function() { context = this; }); diff --git a/spec/core/ReportDispatcherSpec.js b/spec/core/ReportDispatcherSpec.js index 2b569844..d435239e 100644 --- a/spec/core/ReportDispatcherSpec.js +++ b/spec/core/ReportDispatcherSpec.js @@ -1,6 +1,6 @@ describe('ReportDispatcher', function() { it('builds an interface of requested methods', function() { - var dispatcher = new jasmineUnderTest.ReportDispatcher([ + const dispatcher = new jasmineUnderTest.ReportDispatcher([ 'foo', 'bar', 'baz' @@ -12,7 +12,7 @@ describe('ReportDispatcher', function() { }); it('dispatches requested methods to added reporters', function() { - var queueRunnerFactory = jasmine.createSpy('queueRunner'), + const queueRunnerFactory = jasmine.createSpy('queueRunner'), dispatcher = new jasmineUnderTest.ReportDispatcher( ['foo', 'bar'], queueRunnerFactory @@ -36,7 +36,7 @@ describe('ReportDispatcher', function() { }) ); - var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; + let fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; fns[0].fn(); expect(reporter.foo).toHaveBeenCalledWith(123, 456); expect(reporter.foo.calls.mostRecent().object).toBe(reporter); @@ -68,7 +68,7 @@ describe('ReportDispatcher', function() { }); it("does not dispatch to a reporter if the reporter doesn't accept the method", function() { - var queueRunnerFactory = jasmine.createSpy('queueRunner'), + const queueRunnerFactory = jasmine.createSpy('queueRunner'), dispatcher = new jasmineUnderTest.ReportDispatcher( ['foo'], queueRunnerFactory @@ -86,7 +86,7 @@ describe('ReportDispatcher', function() { }); it("allows providing a fallback reporter in case there's no other reporter", function() { - var queueRunnerFactory = jasmine.createSpy('queueRunner'), + const queueRunnerFactory = jasmine.createSpy('queueRunner'), dispatcher = new jasmineUnderTest.ReportDispatcher( ['foo', 'bar'], queueRunnerFactory @@ -104,13 +104,13 @@ describe('ReportDispatcher', function() { }) ); - var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; + const fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; fns[0].fn(); expect(reporter.foo).toHaveBeenCalledWith(123, 456); }); it('does not call fallback reporting methods when another reporter is provided', function() { - var queueRunnerFactory = jasmine.createSpy('queueRunner'), + const queueRunnerFactory = jasmine.createSpy('queueRunner'), dispatcher = new jasmineUnderTest.ReportDispatcher( ['foo', 'bar'], queueRunnerFactory @@ -130,14 +130,14 @@ describe('ReportDispatcher', function() { }) ); - var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; + const fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; fns[0].fn(); expect(reporter.foo).toHaveBeenCalledWith(123, 456); expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456); }); it('allows registered reporters to be cleared', function() { - var queueRunnerFactory = jasmine.createSpy('queueRunner'), + const queueRunnerFactory = jasmine.createSpy('queueRunner'), dispatcher = new jasmineUnderTest.ReportDispatcher( ['foo', 'bar'], queueRunnerFactory @@ -155,7 +155,7 @@ describe('ReportDispatcher', function() { }) ); - var fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; + let fns = queueRunnerFactory.calls.mostRecent().args[0].queueableFns; fns[0].fn(); expect(reporter1.foo).toHaveBeenCalledWith(123); diff --git a/spec/core/SpecSpec.js b/spec/core/SpecSpec.js index 9efebbdf..2d93aec6 100644 --- a/spec/core/SpecSpec.js +++ b/spec/core/SpecSpec.js @@ -1,12 +1,12 @@ describe('Spec', function() { it('#isPendingSpecException returns true for a pending spec exception', function() { - var e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage); + const e = new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage); expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(true); }); it('#isPendingSpecException returns true for a pending spec exception (even when FF bug is present)', function() { - var fakeError = { + const fakeError = { toString: function() { return 'Error: ' + jasmineUnderTest.Spec.pendingSpecExceptionMessage; } @@ -24,7 +24,7 @@ describe('Spec', function() { }); it('#isPendingSpecException returns false for not a pending spec exception', function() { - var e = new Error('foo'); + const e = new Error('foo'); expect(jasmineUnderTest.Spec.isPendingSpecException(e)).toBe(false); }); @@ -34,7 +34,7 @@ describe('Spec', function() { }); it('delegates execution to a QueueRunner', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), spec = new jasmineUnderTest.Spec({ description: 'my test', id: 'some-id', @@ -48,7 +48,7 @@ describe('Spec', function() { }); it('should call the start callback on execution', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), startCallback = jasmine.createSpy('startCallback'), spec = new jasmineUnderTest.Spec({ id: 123, @@ -66,25 +66,25 @@ describe('Spec', function() { }); it('should call the start callback on execution but before any befores are called', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), - beforesWereCalled = false, - startCallback = jasmine - .createSpy('start-callback') - .and.callFake(function() { - expect(beforesWereCalled).toBe(false); - }), - spec = new jasmineUnderTest.Spec({ - queueableFn: { fn: function() {} }, - beforeFns: function() { - return [ - function() { - beforesWereCalled = true; - } - ]; - }, - onStart: startCallback, - queueRunnerFactory: fakeQueueRunner + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'); + let beforesWereCalled = false; + const startCallback = jasmine + .createSpy('start-callback') + .and.callFake(function() { + expect(beforesWereCalled).toBe(false); }); + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: function() {} }, + beforeFns: function() { + return [ + function() { + beforesWereCalled = true; + } + ]; + }, + onStart: startCallback, + queueRunnerFactory: fakeQueueRunner + }); spec.execute(); @@ -93,7 +93,7 @@ describe('Spec', function() { }); it('provides all before fns and after fns to be run', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), before = jasmine.createSpy('before'), after = jasmine.createSpy('after'), queueableFn = { @@ -112,7 +112,7 @@ describe('Spec', function() { spec.execute(); - var options = fakeQueueRunner.calls.mostRecent().args[0]; + const options = fakeQueueRunner.calls.mostRecent().args[0]; expect(options.queueableFns).toEqual([ { fn: jasmine.any(Function) }, before, @@ -126,7 +126,7 @@ describe('Spec', function() { }); it("tells the queue runner that it's a leaf node", function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, beforeAndAfterFns: function() { @@ -145,7 +145,7 @@ describe('Spec', function() { }); it('is marked pending if created without a function body', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), startCallback = jasmine.createSpy('startCallback'), resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ @@ -159,7 +159,7 @@ describe('Spec', function() { }); it('can be excluded at execution time by a parent', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), startCallback = jasmine.createSpy('startCallback'), specBody = jasmine.createSpy('specBody'), resultCallback = jasmine.createSpy('resultCallback'), @@ -186,7 +186,7 @@ describe('Spec', function() { ); expect(specBody).not.toHaveBeenCalled(); - var args = fakeQueueRunner.calls.mostRecent().args[0]; + const args = fakeQueueRunner.calls.mostRecent().args[0]; args.queueableFns[0].fn(); expect(startCallback).toHaveBeenCalled(); args.queueableFns[args.queueableFns.length - 1].fn(); @@ -196,7 +196,7 @@ describe('Spec', function() { }); it('can be marked pending, but still calls callbacks when executed', function() { - var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), + const fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'), startCallback = jasmine.createSpy('startCallback'), resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ @@ -218,7 +218,7 @@ describe('Spec', function() { expect(fakeQueueRunner).toHaveBeenCalled(); - var args = fakeQueueRunner.calls.mostRecent().args[0]; + const args = fakeQueueRunner.calls.mostRecent().args[0]; args.queueableFns[0].fn(); expect(startCallback).toHaveBeenCalled(); args.queueableFns[1].fn('things'); @@ -241,7 +241,7 @@ describe('Spec', function() { }); it('should call the done callback on execution complete', function() { - var done = jasmine.createSpy('done callback'), + const done = jasmine.createSpy('done callback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, catchExceptions: function() { @@ -259,7 +259,7 @@ describe('Spec', function() { }); it('should call the done callback with an error if the spec is failed', function() { - var done = jasmine.createSpy('done callback'), + const done = jasmine.createSpy('done callback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, catchExceptions: function() { @@ -280,31 +280,34 @@ describe('Spec', function() { }); it('should report the duration of the test', function() { - var timer = jasmine.createSpyObj('timer', { start: null, elapsed: 77000 }), - spec = new jasmineUnderTest.Spec({ - queueableFn: { fn: jasmine.createSpy('spec body') }, - catchExceptions: function() { - return false; - }, - resultCallback: function(result) { - duration = result.duration; - }, - queueRunnerFactory: function(config) { - config.queueableFns.forEach(function(qf) { - qf.fn(); - }); - config.onComplete(); - }, - timer: timer - }), - duration = undefined; + const timer = jasmine.createSpyObj('timer', { + start: null, + elapsed: 77000 + }); + let duration = undefined; + const spec = new jasmineUnderTest.Spec({ + queueableFn: { fn: jasmine.createSpy('spec body') }, + catchExceptions: function() { + return false; + }, + resultCallback: function(result) { + duration = result.duration; + }, + queueRunnerFactory: function(config) { + config.queueableFns.forEach(function(qf) { + qf.fn(); + }); + config.onComplete(); + }, + timer: timer + }); spec.execute(function() {}); expect(duration).toBe(77000); }); it('should report properties set during the test', function() { - var done = jasmine.createSpy('done callback'), + const done = jasmine.createSpy('done callback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: jasmine.createSpy('spec body') }, catchExceptions: function() { @@ -321,14 +324,14 @@ describe('Spec', function() { }); it('#status returns passing by default', function() { - var spec = new jasmineUnderTest.Spec({ + const spec = new jasmineUnderTest.Spec({ queueableFn: { fn: jasmine.createSpy('spec body') } }); expect(spec.status()).toBe('passed'); }); it('#status returns passed if all expectations in the spec have passed', function() { - var spec = new jasmineUnderTest.Spec({ + const spec = new jasmineUnderTest.Spec({ queueableFn: { fn: jasmine.createSpy('spec body') } }); spec.addExpectationResult(true); @@ -336,7 +339,7 @@ describe('Spec', function() { }); it('#status returns failed if any expectations in the spec have failed', function() { - var spec = new jasmineUnderTest.Spec({ + const spec = new jasmineUnderTest.Spec({ queueableFn: { fn: jasmine.createSpy('spec body') } }); spec.addExpectationResult(true); @@ -345,7 +348,7 @@ describe('Spec', function() { }); it('keeps track of passed and failed expectations', function() { - var fakeQueueRunner = jasmine.createSpy('queueRunner'), + const fakeQueueRunner = jasmine.createSpy('queueRunner'), resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: jasmine.createSpy('spec body') }, @@ -372,7 +375,7 @@ describe('Spec', function() { }); it("throws an ExpectationFailed error upon receiving a failed expectation when 'throwOnExpectationFailure' is set", function() { - var fakeQueueRunner = jasmine.createSpy('queueRunner'), + const fakeQueueRunner = jasmine.createSpy('queueRunner'), resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, @@ -402,7 +405,7 @@ describe('Spec', function() { }); it('does not throw an ExpectationFailed error when handling an error', function() { - var resultCallback = jasmine.createSpy('resultCallback'), + const resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, expectationResultFactory: function(data) { @@ -419,11 +422,11 @@ describe('Spec', function() { }); it('can return its full name', function() { - var specNameSpy = jasmine + const specNameSpy = jasmine .createSpy('specNameSpy') .and.returnValue('expected val'); - var spec = new jasmineUnderTest.Spec({ + const spec = new jasmineUnderTest.Spec({ getSpecName: specNameSpy, queueableFn: { fn: null } }); @@ -434,7 +437,7 @@ describe('Spec', function() { describe('when a spec is marked pending during execution', function() { it('should mark the spec as pending', function() { - var fakeQueueRunner = function(opts) { + const fakeQueueRunner = function(opts) { opts.onException( new Error(jasmineUnderTest.Spec.pendingSpecExceptionMessage) ); @@ -453,7 +456,7 @@ describe('Spec', function() { }); it('should set the pendingReason', function() { - var fakeQueueRunner = function(opts) { + const fakeQueueRunner = function(opts) { opts.onException( new Error( jasmineUnderTest.Spec.pendingSpecExceptionMessage + @@ -476,7 +479,7 @@ describe('Spec', function() { }); it('should log a failure when handling an exception', function() { - var fakeQueueRunner = jasmine.createSpy('queueRunner'), + const fakeQueueRunner = jasmine.createSpy('queueRunner'), resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, @@ -490,7 +493,7 @@ describe('Spec', function() { spec.onException('foo'); spec.execute(); - var args = fakeQueueRunner.calls.mostRecent().args[0]; + const args = fakeQueueRunner.calls.mostRecent().args[0]; args.queueableFns[args.queueableFns.length - 1].fn(); expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([ { @@ -504,7 +507,7 @@ describe('Spec', function() { }); it('should not log an additional failure when handling an ExpectationFailed error', function() { - var fakeQueueRunner = jasmine.createSpy('queueRunner'), + const fakeQueueRunner = jasmine.createSpy('queueRunner'), resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} }, @@ -518,13 +521,13 @@ describe('Spec', function() { spec.onException(new jasmineUnderTest.errors.ExpectationFailed()); spec.execute(); - var args = fakeQueueRunner.calls.mostRecent().args[0]; + const args = fakeQueueRunner.calls.mostRecent().args[0]; args.queueableFns[args.queueableFns.length - 1].fn(); expect(resultCallback.calls.first().args[0].failedExpectations).toEqual([]); }); it('treats multiple done calls as late errors', function() { - var queueRunnerFactory = jasmine.createSpy('queueRunnerFactory'), + const queueRunnerFactory = jasmine.createSpy('queueRunnerFactory'), onLateError = jasmine.createSpy('onLateError'), spec = new jasmineUnderTest.Spec({ onLateError: onLateError, @@ -550,7 +553,7 @@ describe('Spec', function() { describe('#trace', function() { it('adds the messages to the result', function() { - var timer = jasmine.createSpyObj('timer', ['start', 'elapsed']), + const timer = jasmine.createSpyObj('timer', ['start', 'elapsed']), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} @@ -578,7 +581,7 @@ describe('Spec', function() { describe('When the spec passes', function() { it('omits the messages from the reported result', function() { - var resultCallback = jasmine.createSpy('resultCallback'), + const resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} @@ -601,7 +604,7 @@ describe('Spec', function() { }); it('removes the messages to save memory', function() { - var resultCallback = jasmine.createSpy('resultCallback'), + const resultCallback = jasmine.createSpy('resultCallback'), spec = new jasmineUnderTest.Spec({ queueableFn: { fn: function() {} @@ -624,7 +627,7 @@ describe('Spec', function() { describe('When the spec fails', function() { it('includes the messages in the reported result', function() { - var resultCallback = jasmine.createSpy('resultCallback'), + const resultCallback = jasmine.createSpy('resultCallback'), timer = jasmine.createSpyObj('timer', ['start', 'elapsed']), spec = new jasmineUnderTest.Spec({ queueableFn: { diff --git a/spec/core/SpyRegistrySpec.js b/spec/core/SpyRegistrySpec.js index bfb66b99..eb20bebd 100644 --- a/spec/core/SpyRegistrySpec.js +++ b/spec/core/SpyRegistrySpec.js @@ -5,7 +5,7 @@ describe('SpyRegistry', function() { describe('#spyOn', function() { it('checks for the existence of the object', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }); expect(function() { @@ -14,7 +14,7 @@ describe('SpyRegistry', function() { }); it('checks that a method name was passed', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new jasmineUnderTest.SpyRegistry(), subject = {}; expect(function() { @@ -23,14 +23,14 @@ describe('SpyRegistry', function() { }); it('checks that the object is not `null`', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new jasmineUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOn(null, 'pants'); }).toThrowError(/could not find an object/); }); it('checks that the method name is not `null`', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new jasmineUnderTest.SpyRegistry(), subject = {}; expect(function() { @@ -39,7 +39,7 @@ describe('SpyRegistry', function() { }); it('checks for the existence of the method', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new jasmineUnderTest.SpyRegistry(), subject = {}; expect(function() { @@ -48,7 +48,7 @@ describe('SpyRegistry', function() { }); it('checks if it has already been spied upon', function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -65,7 +65,7 @@ describe('SpyRegistry', function() { }); it('checks if it can be spied upon', function() { - var scope = {}; + const scope = {}; function myFunc() { return 1; @@ -77,7 +77,7 @@ describe('SpyRegistry', function() { } }); - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -95,7 +95,7 @@ describe('SpyRegistry', function() { }); it('overrides the method on the object and returns the spy', function() { - var originalFunctionWasCalled = false, + const originalFunctionWasCalled = false, spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), @@ -105,7 +105,7 @@ describe('SpyRegistry', function() { } }; - var spy = spyRegistry.spyOn(subject, 'spiedFunc'); + const spy = spyRegistry.spyOn(subject, 'spiedFunc'); expect(subject.spiedFunc).toEqual(spy); subject.spiedFunc(); @@ -115,14 +115,14 @@ describe('SpyRegistry', function() { describe('#spyOnProperty', function() { it('checks for the existence of the object', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new jasmineUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOnProperty(void 0, 'pants'); }).toThrowError(/could not find an object/); }); it('checks that a property name was passed', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new jasmineUnderTest.SpyRegistry(), subject = {}; expect(function() { @@ -131,7 +131,7 @@ describe('SpyRegistry', function() { }); it('checks for the existence of the method', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new jasmineUnderTest.SpyRegistry(), subject = {}; expect(function() { @@ -140,7 +140,7 @@ describe('SpyRegistry', function() { }); it('checks for the existence of access type', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(), + const spyRegistry = new jasmineUnderTest.SpyRegistry(), subject = {}; Object.defineProperty(subject, 'pants', { @@ -156,7 +156,7 @@ describe('SpyRegistry', function() { }); it('checks if it can be spied upon', function() { - var subject = {}; + const subject = {}; Object.defineProperty(subject, 'myProp', { get: function() {} @@ -167,7 +167,7 @@ describe('SpyRegistry', function() { configurable: true }); - var spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new jasmineUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOnProperty(subject, 'myProp'); @@ -179,7 +179,7 @@ describe('SpyRegistry', function() { }); it('overrides the property getter on the object and returns the spy', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), subject = {}, @@ -194,8 +194,8 @@ describe('SpyRegistry', function() { expect(subject.spiedProperty).toEqual(returnValue); - var spy = spyRegistry.spyOnProperty(subject, 'spiedProperty'); - var getter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty') + const spy = spyRegistry.spyOnProperty(subject, 'spiedProperty'); + const getter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty') .get; expect(getter).toEqual(spy); @@ -203,7 +203,7 @@ describe('SpyRegistry', function() { }); it('overrides the property setter on the object and returns the spy', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), subject = {}, @@ -217,8 +217,8 @@ describe('SpyRegistry', function() { configurable: true }); - var spy = spyRegistry.spyOnProperty(subject, 'spiedProperty', 'set'); - var setter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty') + const spy = spyRegistry.spyOnProperty(subject, 'spiedProperty', 'set'); + const setter = Object.getOwnPropertyDescriptor(subject, 'spiedProperty') .set; expect(subject.spiedProperty).toEqual(returnValue); @@ -227,7 +227,7 @@ describe('SpyRegistry', function() { describe('when the property is already spied upon', function() { it('throws an error if respy is not allowed', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), subject = {}; @@ -247,7 +247,7 @@ describe('SpyRegistry', function() { }); it('returns the original spy if respy is allowed', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: createSpy }), subject = {}; @@ -261,7 +261,7 @@ describe('SpyRegistry', function() { configurable: true }); - var originalSpy = spyRegistry.spyOnProperty(subject, 'spiedProp'); + const originalSpy = spyRegistry.spyOnProperty(subject, 'spiedProp'); expect(spyRegistry.spyOnProperty(subject, 'spiedProp')).toBe( originalSpy @@ -272,33 +272,33 @@ describe('SpyRegistry', function() { describe('#spyOnAllFunctions', function() { it('checks for the existence of the object', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry(); + const spyRegistry = new jasmineUnderTest.SpyRegistry(); expect(function() { spyRegistry.spyOnAllFunctions(void 0); }).toThrowError(/spyOnAllFunctions could not find an object to spy upon/); }); it('overrides all writable and configurable functions of the object and its parents', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var createNoop = function() { + const createNoop = function() { return function() { /**/ }; }; - var noop1 = createNoop(); - var noop2 = createNoop(); - var noop3 = createNoop(); - var noop4 = createNoop(); - var noop5 = createNoop(); + const noop1 = createNoop(); + const noop2 = createNoop(); + const noop3 = createNoop(); + const noop4 = createNoop(); + const noop5 = createNoop(); - var parent = { + const parent = { parentSpied1: noop1 }; - var subject = Object.create(parent); + const subject = Object.create(parent); Object.defineProperty(subject, 'spied1', { value: noop1, writable: true, @@ -311,7 +311,7 @@ describe('SpyRegistry', function() { configurable: true, enumerable: true }); - var _spied3 = noop3; + let _spied3 = noop3; Object.defineProperty(subject, 'spied3', { configurable: true, set: function(val) { @@ -353,7 +353,7 @@ describe('SpyRegistry', function() { }); subject.notSpied6 = 6; - var spiedObject = spyRegistry.spyOnAllFunctions(subject); + const spiedObject = spyRegistry.spyOnAllFunctions(subject); expect(subject.parentSpied1).toBe('I am a spy'); expect(subject.notSpied2).toBe(noop2); @@ -369,21 +369,21 @@ describe('SpyRegistry', function() { }); it('overrides prototype methods on the object', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var noop1 = function() {}; - var noop2 = function() {}; + const noop1 = function() {}; + const noop2 = function() {}; - var MyClass = function() { + const MyClass = function() { this.spied1 = noop1; }; MyClass.prototype.spied2 = noop2; - var subject = new MyClass(); + const subject = new MyClass(); spyRegistry.spyOnAllFunctions(subject); expect(subject.spied1).toBe('I am a spy'); @@ -392,12 +392,12 @@ describe('SpyRegistry', function() { }); it('does not override non-enumerable properties (like Object.prototype methods)', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subject = { + const subject = { spied1: function() {} }; @@ -409,12 +409,12 @@ describe('SpyRegistry', function() { }); describe('when includeNonEnumerable is true', function() { it('does not override Object.prototype methods', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subject = { + const subject = { spied1: function() {} }; @@ -426,12 +426,12 @@ describe('SpyRegistry', function() { }); it('overrides non-enumerable properties', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subject = { + const subject = { spied1: function() {}, spied2: function() {} }; @@ -449,12 +449,12 @@ describe('SpyRegistry', function() { }); it('should not spy on non-enumerable functions named constructor', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subject = { + const subject = { constructor: function() {} }; @@ -470,12 +470,12 @@ describe('SpyRegistry', function() { }); it('should spy on enumerable functions named constructor', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subject = { + const subject = { constructor: function() {} }; @@ -485,13 +485,13 @@ describe('SpyRegistry', function() { }); it('should not throw an exception if we try and access strict mode restricted properties', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subject = function() {}; - var fn = function() { + const subject = function() {}; + const fn = function() { spyRegistry.spyOnAllFunctions(subject, true); }; @@ -499,24 +499,24 @@ describe('SpyRegistry', function() { }); it('should not spy on properties which are more permissable further up the prototype chain', function() { - var spyRegistry = new jasmineUnderTest.SpyRegistry({ + const spyRegistry = new jasmineUnderTest.SpyRegistry({ createSpy: function() { return 'I am a spy'; } }); - var subjectParent = Object.defineProperty({}, 'sharedProp', { + const subjectParent = Object.defineProperty({}, 'sharedProp', { value: function() {}, writable: true, configurable: true }); - var subject = Object.create(subjectParent); + const subject = Object.create(subjectParent); Object.defineProperty(subject, 'sharedProp', { value: function() {} }); - var fn = function() { + const fn = function() { spyRegistry.spyOnAllFunctions(subject, true); }; @@ -528,7 +528,7 @@ describe('SpyRegistry', function() { describe('#clearSpies', function() { it('restores the original functions on the spied-upon objects', function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -545,7 +545,7 @@ describe('SpyRegistry', function() { }); it('restores the original functions, even when that spy has been replace and re-spied upon', function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -569,7 +569,7 @@ describe('SpyRegistry', function() { }); it("does not add a property that the spied-upon object didn't originally have", function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -579,7 +579,7 @@ describe('SpyRegistry', function() { originalFunction = function() {}, subjectParent = { spiedFunc: originalFunction }; - var subject = Object.create(subjectParent); + const subject = Object.create(subjectParent); expect(subject.hasOwnProperty('spiedFunc')).toBe(false); @@ -591,7 +591,7 @@ describe('SpyRegistry', function() { }); it("restores the original function when it's inherited and cannot be deleted", function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -601,7 +601,7 @@ describe('SpyRegistry', function() { originalFunction = function() {}, subjectParent = { spiedFunc: originalFunction }; - var subject = Object.create(subjectParent); + const subject = Object.create(subjectParent); spyRegistry.spyOn(subject, 'spiedFunc'); @@ -619,7 +619,7 @@ describe('SpyRegistry', function() { function FakeWindow() {} FakeWindow.prototype.onerror = function() {}; - var spies = [], + const spies = [], global = new FakeWindow(), spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { @@ -638,7 +638,7 @@ describe('SpyRegistry', function() { describe('spying on properties', function() { it('restores the original properties on the spied-upon objects', function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -662,7 +662,7 @@ describe('SpyRegistry', function() { }); it("does not add a property that the spied-upon object didn't originally have", function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; @@ -679,7 +679,7 @@ describe('SpyRegistry', function() { configurable: true }); - var subject = Object.create(subjectParent); + const subject = Object.create(subjectParent); expect(subject.hasOwnProperty('spiedProp')).toBe(false); diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index 68fb29de..2390b4fc 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -1,5 +1,5 @@ describe('Spies', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -10,7 +10,7 @@ describe('Spies', function() { }); describe('createSpy', function() { - var TestClass; + let TestClass; beforeEach(function() { TestClass = function() {}; @@ -19,7 +19,7 @@ describe('Spies', function() { }); it('preserves the properties of the spied function', function() { - var spy = env.createSpy( + const spy = env.createSpy( TestClass.prototype, TestClass.prototype.someFunction ); @@ -28,8 +28,8 @@ describe('Spies', function() { }); it('should allow you to omit the name argument and only pass the originalFn argument', function() { - var fn = function test() {}; - var spy = env.createSpy(fn); + const fn = function test() {}; + const spy = env.createSpy(fn); expect(spy.and.identity).toEqual('test'); }); @@ -45,7 +45,7 @@ describe('Spies', function() { }); it('adds a spyStrategy and callTracker to the spy', function() { - var spy = env.createSpy( + const spy = env.createSpy( TestClass.prototype, TestClass.prototype.someFunction ); @@ -55,11 +55,11 @@ describe('Spies', function() { }); it('tracks the argument of calls', function() { - var spy = env.createSpy( + const spy = env.createSpy( TestClass.prototype, TestClass.prototype.someFunction ); - var trackSpy = spyOn(spy.calls, 'track'); + const trackSpy = spyOn(spy.calls, 'track'); spy('arg'); @@ -67,24 +67,24 @@ describe('Spies', function() { }); it('tracks the context of calls', function() { - var spy = env.createSpy( + const spy = env.createSpy( TestClass.prototype, TestClass.prototype.someFunction ); - var trackSpy = spyOn(spy.calls, 'track'); + const trackSpy = spyOn(spy.calls, 'track'); - var contextObject = { spyMethod: spy }; + const contextObject = { spyMethod: spy }; contextObject.spyMethod(); expect(trackSpy.calls.mostRecent().args[0].object).toEqual(contextObject); }); it('tracks the return value of calls', function() { - var spy = env.createSpy( + const spy = env.createSpy( TestClass.prototype, TestClass.prototype.someFunction ); - var trackSpy = spyOn(spy.calls, 'track'); + const trackSpy = spyOn(spy.calls, 'track'); spy.and.returnValue('return value'); spy(); @@ -95,7 +95,7 @@ describe('Spies', function() { }); it('preserves arity of original function', function() { - var functions = [ + const functions = [ function nullary() {}, // eslint-disable-next-line no-unused-vars function unary(arg) {}, @@ -111,8 +111,8 @@ describe('Spies', function() { function senary(arg1, arg2, arg3, arg4, arg5, arg6) {} ]; - for (var arity = 0; arity < functions.length; arity++) { - var someFunction = functions[arity], + for (let arity = 0; arity < functions.length; arity++) { + const someFunction = functions[arity], spy = env.createSpy(someFunction.name, someFunction); expect(spy.length).toEqual(arity); @@ -122,7 +122,7 @@ describe('Spies', function() { describe('createSpyObj', function() { it('should create an object with spy methods and corresponding return values when you call jasmine.createSpyObj() with an object', function() { - var spyObj = env.createSpyObj('BaseName', { + const spyObj = env.createSpyObj('BaseName', { method1: 42, method2: 'special sauce' }); @@ -135,7 +135,7 @@ describe('Spies', function() { }); it('should create an object with a bunch of spy methods when you call jasmine.createSpyObj()', function() { - var spyObj = env.createSpyObj('BaseName', ['method1', 'method2']); + const spyObj = env.createSpyObj('BaseName', ['method1', 'method2']); expect(spyObj).toEqual({ method1: jasmine.any(Function), @@ -146,7 +146,7 @@ describe('Spies', function() { }); it('should allow you to omit the baseName', function() { - var spyObj = env.createSpyObj(['method1', 'method2']); + const spyObj = env.createSpyObj(['method1', 'method2']); expect(spyObj).toEqual({ method1: jasmine.any(Function), @@ -181,20 +181,20 @@ describe('Spies', function() { }); it('creates an object with spy properties if a second list is passed', function() { - var spyObj = env.createSpyObj('base', ['method1'], ['prop1']); + const spyObj = env.createSpyObj('base', ['method1'], ['prop1']); expect(spyObj).toEqual({ method1: jasmine.any(Function), prop1: undefined }); - var descriptor = Object.getOwnPropertyDescriptor(spyObj, 'prop1'); + const descriptor = Object.getOwnPropertyDescriptor(spyObj, 'prop1'); expect(descriptor.get.and.identity).toEqual('base.prop1.get'); expect(descriptor.set.and.identity).toEqual('base.prop1.set'); }); it('creates an object with property names and return values if second object is passed', function() { - var spyObj = env.createSpyObj('base', ['method1'], { + const spyObj = env.createSpyObj('base', ['method1'], { prop1: 'foo', prop2: 37 }); @@ -215,7 +215,7 @@ describe('Spies', function() { }); it('allows base name to be omitted when assigning methods and properties', function() { - var spyObj = env.createSpyObj({ m: 3 }, { p: 4 }); + const spyObj = env.createSpyObj({ m: 3 }, { p: 4 }); expect(spyObj.m()).toEqual(3); expect(spyObj.p).toEqual(4); @@ -226,7 +226,7 @@ describe('Spies', function() { }); it('can use different strategies for different arguments', function() { - var spy = env.createSpy('foo'); + const spy = env.createSpy('foo'); spy.and.returnValue(42); spy.withArgs('baz', 'grault').and.returnValue(-1); spy.withArgs('thud').and.returnValue('bob'); @@ -238,7 +238,7 @@ describe('Spies', function() { }); it('uses asymmetric equality testers when selecting a strategy', function() { - var spy = env.createSpy('foo'); + const spy = env.createSpy('foo'); spy.and.returnValue(42); spy.withArgs(jasmineUnderTest.any(String)).and.returnValue(-1); @@ -264,7 +264,7 @@ describe('Spies', function() { }); it('can reconfigure an argument-specific strategy', function() { - var spy = env.createSpy('foo'); + const spy = env.createSpy('foo'); spy.withArgs('foo').and.returnValue(42); spy.withArgs('foo').and.returnValue(17); expect(spy('foo')).toEqual(17); @@ -272,7 +272,7 @@ describe('Spies', function() { describe('any promise-based strategy', function() { it('works with global Promise library', function(done) { - var spy = env.createSpy('foo').and.resolveTo(42); + const spy = env.createSpy('foo').and.resolveTo(42); spy() .then(function(result) { expect(result).toEqual(42); @@ -284,14 +284,14 @@ describe('Spies', function() { describe('when withArgs is used without a base strategy', function() { it('uses the matching strategy', function() { - var spy = env.createSpy('foo'); + const spy = env.createSpy('foo'); spy.withArgs('baz').and.returnValue(-1); expect(spy('baz')).toEqual(-1); }); it("throws if the args don't match", function() { - var spy = env.createSpy('foo'); + const spy = env.createSpy('foo'); spy.withArgs('bar').and.returnValue(-1); expect(function() { diff --git a/spec/core/SpyStrategySpec.js b/spec/core/SpyStrategySpec.js index f8f96920..b0681311 100644 --- a/spec/core/SpyStrategySpec.js +++ b/spec/core/SpyStrategySpec.js @@ -1,18 +1,18 @@ describe('SpyStrategy', function() { it('defaults its name to unknown', function() { - var spyStrategy = new jasmineUnderTest.SpyStrategy(); + const spyStrategy = new jasmineUnderTest.SpyStrategy(); expect(spyStrategy.identity).toEqual('unknown'); }); it('takes a name', function() { - var spyStrategy = new jasmineUnderTest.SpyStrategy({ name: 'foo' }); + const spyStrategy = new jasmineUnderTest.SpyStrategy({ name: 'foo' }); expect(spyStrategy.identity).toEqual('foo'); }); it('stubs an original function, if provided', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.exec(); @@ -21,12 +21,11 @@ describe('SpyStrategy', function() { }); it("allows an original function to be called, passed through the params and returns it's value", function() { - var originalFn = jasmine.createSpy('original').and.returnValue(42), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }), - returnValue; + const originalFn = jasmine.createSpy('original').and.returnValue(42), + spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callThrough(); - returnValue = spyStrategy.exec(null, ['foo']); + const returnValue = spyStrategy.exec(null, ['foo']); expect(originalFn).toHaveBeenCalled(); expect(originalFn.calls.mostRecent().args).toEqual(['foo']); @@ -34,19 +33,18 @@ describe('SpyStrategy', function() { }); it('can return a specified value when executed', function() { - var originalFn = jasmine.createSpy('original'), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }), - returnValue; + const originalFn = jasmine.createSpy('original'), + spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.returnValue(17); - returnValue = spyStrategy.exec(); + const returnValue = spyStrategy.exec(); expect(originalFn).not.toHaveBeenCalled(); expect(returnValue).toEqual(17); }); it('can return specified values in order specified when executed', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.returnValues('value1', 'value2', 'value3'); @@ -59,7 +57,7 @@ describe('SpyStrategy', function() { }); it('allows an exception to be thrown when executed', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError(new TypeError('bar')); @@ -71,7 +69,7 @@ describe('SpyStrategy', function() { }); it('allows a string to be thrown, wrapping it into an exception when executed', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError('bar'); @@ -83,7 +81,7 @@ describe('SpyStrategy', function() { }); it('allows a non-Error to be thrown when executed', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.throwError({ code: 'ESRCH' }); @@ -95,20 +93,19 @@ describe('SpyStrategy', function() { }); it('allows a fake function to be called instead', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), fakeFn = jasmine.createSpy('fake').and.returnValue(67), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }), - returnValue; + spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); - returnValue = spyStrategy.exec(); + const returnValue = spyStrategy.exec(); expect(originalFn).not.toHaveBeenCalled(); expect(returnValue).toEqual(67); }); it('allows a fake async function to be called instead', function(done) { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), fakeFn = jasmine .createSpy('fake') .and.callFake(eval('async () => { return 67; }')), @@ -130,7 +127,7 @@ describe('SpyStrategy', function() { describe('#resolveTo', function() { it('allows a resolved promise to be returned', function(done) { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); @@ -146,7 +143,7 @@ describe('SpyStrategy', function() { }); it('allows an empty resolved promise to be returned', function(done) { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); @@ -164,7 +161,7 @@ describe('SpyStrategy', function() { describe('#rejectWith', function() { it('allows a rejected promise to be returned', function(done) { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); @@ -181,7 +178,7 @@ describe('SpyStrategy', function() { }); it('allows an empty rejected promise to be returned', function(done) { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); @@ -198,7 +195,7 @@ describe('SpyStrategy', function() { }); it('allows a non-Error to be rejected', function(done) { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); @@ -216,7 +213,7 @@ describe('SpyStrategy', function() { }); it('allows a custom strategy to be used', function() { - var plan = jasmine + const plan = jasmine .createSpy('custom strategy') .and.returnValue('custom strategy result'), customStrategy = jasmine @@ -239,7 +236,7 @@ describe('SpyStrategy', function() { }); it("throws an error if a custom strategy doesn't return a function", function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn, customStrategies: { @@ -255,7 +252,7 @@ describe('SpyStrategy', function() { }); it('does not allow custom strategies to overwrite existing methods', function() { - var spyStrategy = new jasmineUnderTest.SpyStrategy({ + const spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {}, customStrategies: { exec: function() {} @@ -266,7 +263,7 @@ describe('SpyStrategy', function() { }); it('throws an error when a non-function is passed to callFake strategy', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyOn(jasmineUnderTest, 'isFunction_').and.returnValue(false); @@ -282,7 +279,7 @@ describe('SpyStrategy', function() { }); it('allows generator functions to be passed to callFake strategy', function() { - var generator = function*() { + const generator = function*() { yield 'ok'; }, spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: function() {} }); @@ -293,13 +290,12 @@ describe('SpyStrategy', function() { }); it('allows a return to plan stubbing after another strategy', function() { - var originalFn = jasmine.createSpy('original'), + const originalFn = jasmine.createSpy('original'), fakeFn = jasmine.createSpy('fake').and.returnValue(67), - spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }), - returnValue; + spyStrategy = new jasmineUnderTest.SpyStrategy({ fn: originalFn }); spyStrategy.callFake(fakeFn); - returnValue = spyStrategy.exec(); + let returnValue = spyStrategy.exec(); expect(originalFn).not.toHaveBeenCalled(); expect(returnValue).toEqual(67); @@ -311,7 +307,7 @@ describe('SpyStrategy', function() { }); it('returns the spy after changing the strategy', function() { - var spy = {}, + const spy = {}, spyFn = jasmine.createSpy('spyFn').and.returnValue(spy), spyStrategy = new jasmineUnderTest.SpyStrategy({ getSpy: spyFn }); diff --git a/spec/core/StackTraceSpec.js b/spec/core/StackTraceSpec.js index 32ccc090..9ffa2c6b 100644 --- a/spec/core/StackTraceSpec.js +++ b/spec/core/StackTraceSpec.js @@ -1,6 +1,6 @@ describe('StackTrace', function() { it('understands Chrome/Edge style traces', function() { - var error = { + const error = { message: 'nope', stack: 'Error: nope\n' + @@ -8,7 +8,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toEqual('Error: nope'); expect(result.style).toEqual('v8'); @@ -31,7 +31,7 @@ describe('StackTrace', function() { }); it('understands Chrome/Edge style traces with multiline messages', function() { - var error = { + const error = { message: 'line 1\nline 2', stack: 'Error: line 1\nline 2\n' + @@ -39,10 +39,10 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toEqual('Error: line 1\nline 2'); - var rawFrames = result.frames.map(function(f) { + const rawFrames = result.frames.map(function(f) { return f.raw; }); expect(rawFrames).toEqual([ @@ -52,7 +52,7 @@ describe('StackTrace', function() { }); it('understands Node style traces', function() { - var error = { + const error = { message: 'nope', stack: 'Error\n' + @@ -61,7 +61,7 @@ describe('StackTrace', function() { ' at Immediate. (/somewhere/jasmine/lib/jasmine-core/jasmine.js:4314:12)\n' + ' at runCallback (timers.js:672:20)' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toEqual('Error'); expect(result.style).toEqual('v8'); @@ -96,13 +96,13 @@ describe('StackTrace', function() { }); it('understands Safari <=14/Firefox/Phantom-OS X style traces', function() { - var error = { + const error = { message: 'nope', stack: 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' + 'run@http://localhost:8888/__jasmine__/jasmine.js:4320:27' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toBeFalsy(); expect(result.style).toEqual('webkit'); @@ -123,13 +123,13 @@ describe('StackTrace', function() { }); it('understands Safari 15 style traces', function() { - var error = { + const error = { message: 'nope', stack: '@http://localhost:8888/__spec__/core/FooSpec.js:164:24\n' + 'attempt@http://localhost:8888/__jasmine__/jasmine.js:8074:44\n' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toBeFalsy(); expect(result.style).toEqual('webkit'); @@ -150,24 +150,24 @@ describe('StackTrace', function() { }); it('does not mistake gibberish for Safari/Firefox/Phantom-OS X style traces', function() { - var error = { + const error = { message: 'nope', stack: 'randomcharsnotincludingwhitespace' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.style).toBeNull(); expect(result.frames).toEqual([{ raw: error.stack }]); }); it('understands Phantom-Linux style traces', function() { - var error = { + const error = { message: 'nope', stack: ' at UserContext. (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' + ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toBeFalsy(); expect(result.style).toEqual('v8'); @@ -190,13 +190,13 @@ describe('StackTrace', function() { }); it('ignores blank lines', function() { - var error = { + const error = { message: 'nope', stack: ' at UserContext. (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.frames).toEqual([ { @@ -210,7 +210,7 @@ describe('StackTrace', function() { }); it("omits properties except 'raw' for frames that are not understood", function() { - var error = { + const error = { message: 'nope', stack: ' at UserContext. (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' + @@ -218,7 +218,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.style).toEqual('v8'); expect(result.frames).toEqual([ { @@ -242,7 +242,7 @@ describe('StackTrace', function() { }); it('consideres different types of errors', function() { - var error = { + const error = { message: 'nope', stack: 'TypeError: nope\n' + @@ -250,7 +250,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - var result = new jasmineUnderTest.StackTrace(error); + const result = new jasmineUnderTest.StackTrace(error); expect(result.message).toEqual('TypeError: nope'); expect(result.frames).toEqual([ @@ -270,7 +270,7 @@ describe('StackTrace', function() { } ]); - var no_error = { + const no_error = { message: 'nope', stack: 'Type Error: nope\n' + @@ -278,7 +278,7 @@ describe('StackTrace', function() { ' at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4320:20)' }; - var result_no_error = new jasmineUnderTest.StackTrace(no_error); + const result_no_error = new jasmineUnderTest.StackTrace(no_error); expect(result_no_error.message).not.toEqual(jasmine.anything()); }); diff --git a/spec/core/SuiteSpec.js b/spec/core/SuiteSpec.js index 37317161..6813082a 100644 --- a/spec/core/SuiteSpec.js +++ b/spec/core/SuiteSpec.js @@ -1,5 +1,5 @@ describe('Suite', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -10,7 +10,7 @@ describe('Suite', function() { }); it('keeps its id', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ env: env, id: 456, description: 'I am a suite' @@ -20,7 +20,7 @@ describe('Suite', function() { }); it('returns blank full name for top level suite', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ env: env, description: 'I am a suite' }); @@ -29,7 +29,7 @@ describe('Suite', function() { }); it('returns its full name when it has parent suites', function() { - var parentSuite = new jasmineUnderTest.Suite({ + const parentSuite = new jasmineUnderTest.Suite({ env: env, description: 'I am a parent suite', parentSuite: jasmine.createSpy('pretend top level suite') @@ -44,7 +44,7 @@ describe('Suite', function() { }); it('adds beforeEach functions in order of needed execution', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -61,7 +61,7 @@ describe('Suite', function() { }); it('adds beforeAll functions in order of needed execution', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -89,7 +89,7 @@ describe('Suite', function() { }); it('adds afterEach functions in order of needed execution', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ env: env, description: 'I am a suite' }), @@ -123,7 +123,7 @@ describe('Suite', function() { }); it('has a status of failed if any expectations have failed', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ expectationResultFactory: function() { return 'hi'; } @@ -134,20 +134,20 @@ describe('Suite', function() { }); it('retrieves a result with updated status', function() { - var suite = new jasmineUnderTest.Suite({}); + const suite = new jasmineUnderTest.Suite({}); expect(suite.getResult().status).toBe('passed'); }); it('retrieves a result with pending status', function() { - var suite = new jasmineUnderTest.Suite({}); + const suite = new jasmineUnderTest.Suite({}); suite.pend(); expect(suite.getResult().status).toBe('pending'); }); it('throws an ExpectationFailed when receiving a failed expectation when throwOnExpectationFailure is set', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ expectationResultFactory: function(data) { return data; }, @@ -163,7 +163,7 @@ describe('Suite', function() { }); it('does not add an additional failure when an expectation fails', function() { - var suite = new jasmineUnderTest.Suite({}); + const suite = new jasmineUnderTest.Suite({}); suite.onException(new jasmineUnderTest.errors.ExpectationFailed()); @@ -171,7 +171,7 @@ describe('Suite', function() { }); it('calls timer to compute duration', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ env: env, id: 456, description: 'I am a suite', @@ -196,7 +196,7 @@ describe('Suite', function() { describe('attr.autoCleanClosures', function() { function arrangeSuite(attrs) { - var suite = new jasmineUnderTest.Suite(attrs); + const suite = new jasmineUnderTest.Suite(attrs); suite.beforeAll(function() {}); suite.beforeEach(function() {}); suite.afterEach(function() {}); @@ -205,7 +205,7 @@ describe('Suite', function() { } it('should clean closures when "attr.autoCleanClosures" is missing', function() { - var suite = arrangeSuite({}); + const suite = arrangeSuite({}); suite.cleanupBeforeAfter(); expect(suite.beforeAllFns[0].fn).toBe(null); expect(suite.beforeFns[0].fn).toBe(null); @@ -214,7 +214,7 @@ describe('Suite', function() { }); it('should clean closures when "attr.autoCleanClosures" is true', function() { - var suite = arrangeSuite({ autoCleanClosures: true }); + const suite = arrangeSuite({ autoCleanClosures: true }); suite.cleanupBeforeAfter(); expect(suite.beforeAllFns[0].fn).toBe(null); expect(suite.beforeFns[0].fn).toBe(null); @@ -223,7 +223,7 @@ describe('Suite', function() { }); it('should NOT clean closures when "attr.autoCleanClosures" is false', function() { - var suite = arrangeSuite({ autoCleanClosures: false }); + const suite = arrangeSuite({ autoCleanClosures: false }); suite.cleanupBeforeAfter(); expect(suite.beforeAllFns[0].fn).not.toBe(null); expect(suite.beforeFns[0].fn).not.toBe(null); @@ -234,23 +234,23 @@ describe('Suite', function() { describe('#reset', function() { it('should reset the "pending" status', function() { - var suite = new jasmineUnderTest.Suite({}); + const suite = new jasmineUnderTest.Suite({}); suite.pend(); suite.reset(); expect(suite.getResult().status).toBe('passed'); }); it('should not reset the "pending" status when the suite was excluded', function() { - var suite = new jasmineUnderTest.Suite({}); + const suite = new jasmineUnderTest.Suite({}); suite.exclude(); suite.reset(); expect(suite.getResult().status).toBe('pending'); }); it('should also reset the children', function() { - var suite = new jasmineUnderTest.Suite({}); - var child1 = jasmine.createSpyObj(['reset']); - var child2 = jasmine.createSpyObj(['reset']); + const suite = new jasmineUnderTest.Suite({}); + const child1 = jasmine.createSpyObj(['reset']); + const child2 = jasmine.createSpyObj(['reset']); suite.addChild(child1); suite.addChild(child2); @@ -261,7 +261,7 @@ describe('Suite', function() { }); it('should reset the failedExpectations', function() { - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ expectationResultFactory: function(error) { return error; } @@ -270,7 +270,7 @@ describe('Suite', function() { suite.reset(); - var result = suite.getResult(); + const result = suite.getResult(); expect(result.status).toBe('passed'); expect(result.failedExpectations).toHaveSize(0); }); @@ -296,7 +296,7 @@ describe('Suite', function() { it('reports an error including the suite name when it is a normal suite', function() { const onLateError = jasmine.createSpy('onLateError'); - var suite = new jasmineUnderTest.Suite({ + const suite = new jasmineUnderTest.Suite({ onLateError, description: 'the suite', parentSuite: { diff --git a/spec/core/TimerSpec.js b/spec/core/TimerSpec.js index 39d74dc6..7d23d10a 100644 --- a/spec/core/TimerSpec.js +++ b/spec/core/TimerSpec.js @@ -1,6 +1,6 @@ describe('Timer', function() { it('reports the time elapsed', function() { - var fakeNow = jasmine.createSpy('fake Date.now'), + const fakeNow = jasmine.createSpy('fake Date.now'), timer = new jasmineUnderTest.Timer({ now: fakeNow }); fakeNow.and.returnValue(100); @@ -12,7 +12,7 @@ describe('Timer', function() { }); describe('when date is stubbed, perhaps by other testing helpers', function() { - var origDate = Date; + const origDate = Date; beforeEach(function() { // eslint-disable-next-line no-implicit-globals Date = jasmine.createSpy('date spy'); @@ -24,7 +24,7 @@ describe('Timer', function() { }); it('does not throw even though Date was taken away', function() { - var timer = new jasmineUnderTest.Timer(); + const timer = new jasmineUnderTest.Timer(); expect(timer.start).not.toThrow(); expect(timer.elapsed()).toEqual(jasmine.any(Number)); diff --git a/spec/core/TreeProcessorSpec.js b/spec/core/TreeProcessorSpec.js index ac5b4ee4..4892a650 100644 --- a/spec/core/TreeProcessorSpec.js +++ b/spec/core/TreeProcessorSpec.js @@ -1,5 +1,5 @@ describe('TreeProcessor', function() { - var nodeNumber = 0, + let nodeNumber = 0, leafNumber = 0; function Node(attrs) { @@ -27,7 +27,7 @@ describe('TreeProcessor', function() { } it('processes a single leaf', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] @@ -44,7 +44,7 @@ describe('TreeProcessor', function() { }); it('processes a single pending leaf', function() { - var leaf = new Leaf({ markedPending: true }), + const leaf = new Leaf({ markedPending: true }), processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] @@ -61,7 +61,7 @@ describe('TreeProcessor', function() { }); it('processes a single non-specified leaf', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [] @@ -78,7 +78,7 @@ describe('TreeProcessor', function() { }); it('processes a single excluded leaf', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id], @@ -98,7 +98,7 @@ describe('TreeProcessor', function() { }); it('processes a tree with a single leaf with the root specified', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), parent = new Node({ children: [leaf] }), processor = new jasmineUnderTest.TreeProcessor({ tree: parent, @@ -122,7 +122,7 @@ describe('TreeProcessor', function() { }); it('processes a tree with a single pending leaf, with the root specified', function() { - var leaf = new Leaf({ markedPending: true }), + const leaf = new Leaf({ markedPending: true }), parent = new Node({ children: [leaf] }), processor = new jasmineUnderTest.TreeProcessor({ tree: parent, @@ -146,7 +146,7 @@ describe('TreeProcessor', function() { }); it('processes a complicated tree with the root specified', function() { - var pendingLeaf = new Leaf({ markedPending: true }), + const pendingLeaf = new Leaf({ markedPending: true }), executableLeaf = new Leaf({ markedPending: false }), parent = new Node({ children: [pendingLeaf, executableLeaf] }), childless = new Node(), @@ -218,7 +218,7 @@ describe('TreeProcessor', function() { }); it('marks the run order invalid if it would re-enter a node that does not allow re-entry', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }), @@ -233,7 +233,7 @@ describe('TreeProcessor', function() { }); it('marks the run order valid if a node being re-entered allows re-entry', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), reentered = new Node({ children: [leaf1, leaf2] }), @@ -248,7 +248,7 @@ describe('TreeProcessor', function() { }); it("marks the run order valid if a node which can't be re-entered is only entered once", function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), noReentry = new Node({ noReenter: true }), @@ -263,7 +263,7 @@ describe('TreeProcessor', function() { }); it("marks the run order valid if a node which can't be re-entered is run directly", function() { - var noReentry = new Node({ noReenter: true }), + const noReentry = new Node({ noReenter: true }), root = new Node({ children: [noReentry] }), processor = new jasmineUnderTest.TreeProcessor({ tree: root, @@ -275,7 +275,7 @@ describe('TreeProcessor', function() { }); it('runs a single leaf', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), node = new Node({ children: [leaf], userContext: { root: 'context' } }), queueRunner = jasmine.createSpy('queueRunner'), processor = new jasmineUnderTest.TreeProcessor({ @@ -301,7 +301,7 @@ describe('TreeProcessor', function() { }); it('runs a node with no children', function() { - var node = new Node({ userContext: { node: 'context' } }), + const node = new Node({ userContext: { node: 'context' } }), root = new Node({ children: [node], userContext: { root: 'context' } }), nodeStart = jasmine.createSpy('nodeStart'), nodeComplete = jasmine.createSpy('nodeComplete'), @@ -351,7 +351,7 @@ describe('TreeProcessor', function() { }); it('runs a node with children', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), node = new Node({ children: [leaf1, leaf2] }), root = new Node({ children: [node] }), @@ -365,7 +365,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -379,7 +379,7 @@ describe('TreeProcessor', function() { }); it('cascades errors up the tree', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), node = new Node({ children: [leaf] }), root = new Node({ children: [node] }), queueRunner = jasmine.createSpy('queueRunner'), @@ -394,7 +394,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -410,7 +410,7 @@ describe('TreeProcessor', function() { }); it('runs an excluded node with leaf', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), node = new Node({ children: [leaf1] }), root = new Node({ children: [node] }), queueRunner = jasmine.createSpy('queueRunner'), @@ -427,7 +427,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -450,7 +450,7 @@ describe('TreeProcessor', function() { }); it('should execute node with correct arguments when failSpecWithNoExpectations option is set', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), node = new Node({ children: [leaf] }), root = new Node({ children: [node] }), queueRunner = jasmine.createSpy('queueRunner'), @@ -468,7 +468,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -479,7 +479,7 @@ describe('TreeProcessor', function() { }); it('runs beforeAlls for a node with children', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), node = new Node({ children: [leaf], beforeAllFns: [ @@ -498,7 +498,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -512,7 +512,7 @@ describe('TreeProcessor', function() { }); it('runs afterAlls for a node with children', function() { - var leaf = new Leaf(), + const leaf = new Leaf(), afterAllFns = [{ fn: 'afterAll1' }, { fn: 'afterAll2' }], node = new Node({ children: [leaf], @@ -529,7 +529,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -543,7 +543,7 @@ describe('TreeProcessor', function() { }); it('does not run beforeAlls or afterAlls for a node with no children', function() { - var node = new Node({ + const node = new Node({ beforeAllFns: [{ fn: 'before' }], afterAllFns: [{ fn: 'after' }] }), @@ -558,7 +558,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -567,7 +567,7 @@ describe('TreeProcessor', function() { }); it('does not run beforeAlls or afterAlls for a node with only pending children', function() { - var leaf = new Leaf({ markedPending: true }), + const leaf = new Leaf({ markedPending: true }), node = new Node({ children: [leaf], beforeAllFns: [{ fn: 'before' }], @@ -585,7 +585,7 @@ describe('TreeProcessor', function() { nodeDone = jasmine.createSpy('nodeDone'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(nodeDone); queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; @@ -597,7 +597,7 @@ describe('TreeProcessor', function() { }); it('runs leaves in the order specified', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), root = new Node({ children: [leaf1, leaf2] }), queueRunner = jasmine.createSpy('queueRunner'), @@ -609,7 +609,7 @@ describe('TreeProcessor', function() { treeComplete = jasmine.createSpy('treeComplete'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(); expect(leaf1.execute).not.toHaveBeenCalled(); @@ -621,7 +621,7 @@ describe('TreeProcessor', function() { }); it('runs specified leaves before non-specified leaves within a parent node', function() { - var specified = new Leaf(), + const specified = new Leaf(), nonSpecified = new Leaf(), root = new Node({ children: [nonSpecified, specified] }), queueRunner = jasmine.createSpy('queueRunner'), @@ -633,7 +633,7 @@ describe('TreeProcessor', function() { treeComplete = jasmine.createSpy('treeComplete'); processor.execute(treeComplete); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(); expect(nonSpecified.execute).not.toHaveBeenCalled(); @@ -645,7 +645,7 @@ describe('TreeProcessor', function() { }); it('runs nodes and leaves with a specified order', function() { - var specifiedLeaf = new Leaf(), + const specifiedLeaf = new Leaf(), childLeaf = new Leaf(), specifiedNode = new Node({ children: [childLeaf] }), root = new Node({ children: [specifiedLeaf, specifiedNode] }), @@ -657,11 +657,12 @@ describe('TreeProcessor', function() { }); processor.execute(); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; queueableFns[0].fn(); expect(specifiedLeaf.execute).not.toHaveBeenCalled(); - var nodeQueueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const nodeQueueableFns = queueRunner.calls.mostRecent().args[0] + .queueableFns; nodeQueueableFns[1].fn(); expect(childLeaf.execute).toHaveBeenCalled(); @@ -672,7 +673,7 @@ describe('TreeProcessor', function() { }); it('runs a node multiple times if the order specified leaves and re-enters it', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), leaf4 = new Leaf(), @@ -687,7 +688,7 @@ describe('TreeProcessor', function() { }); processor.execute(); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; expect(queueableFns.length).toBe(5); queueableFns[0].fn(); @@ -715,7 +716,7 @@ describe('TreeProcessor', function() { }); it('runs a parent of a node with segments correctly', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), leaf4 = new Leaf(), @@ -731,7 +732,7 @@ describe('TreeProcessor', function() { }); processor.execute(); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; expect(queueableFns.length).toBe(5); queueableFns[0].fn(); @@ -772,7 +773,7 @@ describe('TreeProcessor', function() { }); it('runs nodes in the order they were declared', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), parent = new Node({ children: [leaf2, leaf3] }), @@ -785,7 +786,7 @@ describe('TreeProcessor', function() { }); processor.execute(); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; expect(queueableFns.length).toBe(2); queueableFns[0].fn(); @@ -793,7 +794,7 @@ describe('TreeProcessor', function() { queueableFns[1].fn(); - var childFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const childFns = queueRunner.calls.mostRecent().args[0].queueableFns; expect(childFns.length).toBe(3); childFns[1].fn(); expect(leaf2.execute).toHaveBeenCalled(); @@ -803,7 +804,7 @@ describe('TreeProcessor', function() { }); it('runs large segments of nodes in the order they were declared', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), leaf4 = new Leaf(), @@ -837,7 +838,7 @@ describe('TreeProcessor', function() { }); processor.execute(); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; expect(queueableFns.length).toBe(11); queueableFns[0].fn(); @@ -875,7 +876,7 @@ describe('TreeProcessor', function() { }); it('runs nodes in a custom order when orderChildren is overridden', function() { - var leaf1 = new Leaf(), + const leaf1 = new Leaf(), leaf2 = new Leaf(), leaf3 = new Leaf(), leaf4 = new Leaf(), @@ -907,13 +908,13 @@ describe('TreeProcessor', function() { runnableIds: [root.id], queueRunnerFactory: queueRunner, orderChildren: function(node) { - var children = node.children.slice(); + const children = node.children.slice(); return children.reverse(); } }); processor.execute(); - var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; + const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns; expect(queueableFns.length).toBe(11); queueableFns[0].fn(); diff --git a/spec/core/UserContextSpec.js b/spec/core/UserContextSpec.js index d8e90f69..99caa37c 100644 --- a/spec/core/UserContextSpec.js +++ b/spec/core/UserContextSpec.js @@ -1,9 +1,9 @@ describe('UserContext', function() { it('Behaves just like an plain object', function() { - var context = new jasmineUnderTest.UserContext(), + const context = new jasmineUnderTest.UserContext(), properties = []; - for (var prop in context) { + for (const prop in context) { if (obj.hasOwnProperty(prop)) { properties.push(prop); } diff --git a/spec/core/UtilSpec.js b/spec/core/UtilSpec.js index d0c8fe32..ea933b95 100644 --- a/spec/core/UtilSpec.js +++ b/spec/core/UtilSpec.js @@ -1,4 +1,4 @@ -describe('jasmineUnderTest.util', function() { +describe('util', function() { describe('isArray_', function() { it('should return true if the argument is an array', function() { expect(jasmineUnderTest.isArray_([])).toBe(true); @@ -32,9 +32,9 @@ describe('jasmineUnderTest.util', function() { }); describe('promise utils', function() { - var mockNativePromise, mockPromiseLikeObject; + let mockNativePromise, mockPromiseLikeObject; - var mockPromiseLike = function() { + const mockPromiseLike = function() { this.then = function() {}; }; @@ -130,12 +130,12 @@ describe('jasmineUnderTest.util', function() { describe('isUndefined', function() { it('reports if a variable is defined', function() { - var a; + let a; expect(jasmineUnderTest.util.isUndefined(a)).toBe(true); expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(true); - var undefined = 'diz be undefined yo'; - expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(false); + const defined = 'diz be undefined yo'; + expect(jasmineUnderTest.util.isUndefined(defined)).toBe(false); }); }); @@ -150,12 +150,12 @@ describe('jasmineUnderTest.util', function() { }); it('clones Regexp objects as-is', function() { - var regex = /match/; + const regex = /match/; expect(jasmineUnderTest.util.cloneArgs([regex])).toEqual([regex]); }); it('clones Date objects as-is', function() { - var date = new Date(2022, 1, 1); + const date = new Date(2022, 1, 1); expect(jasmineUnderTest.util.cloneArgs([date])).toEqual([date]); }); @@ -167,7 +167,7 @@ describe('jasmineUnderTest.util', function() { describe('getPropertyDescriptor', function() { it('get property descriptor from object', function() { - var obj = { prop: 1 }, + const obj = { prop: 1 }, actual = jasmineUnderTest.util.getPropertyDescriptor(obj, 'prop'), expected = Object.getOwnPropertyDescriptor(obj, 'prop'); @@ -175,7 +175,7 @@ describe('jasmineUnderTest.util', function() { }); it('get property descriptor from object property', function() { - var proto = { prop: 1 }, + const proto = { prop: 1 }, actual = jasmineUnderTest.util.getPropertyDescriptor(proto, 'prop'), expected = Object.getOwnPropertyDescriptor(proto, 'prop'); @@ -185,13 +185,13 @@ describe('jasmineUnderTest.util', function() { describe('objectDifference', function() { it('given two objects A and B, returns the properties in A not present in B', function() { - var a = { + const a = { foo: 3, bar: 4, baz: 5 }; - var b = { + const b = { bar: 6, quux: 7 }; @@ -208,10 +208,10 @@ describe('jasmineUnderTest.util', function() { Foo.prototype.x = 1; Foo.prototype.y = 2; - var a = new Foo(); + const a = new Foo(); a.x = 1; - var b = new Foo(); + const b = new Foo(); b.y = 2; expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({ x: 1 }); diff --git a/spec/core/asymmetric_equality/AnySpec.js b/spec/core/asymmetric_equality/AnySpec.js index 7979dd7c..e23d93fd 100644 --- a/spec/core/asymmetric_equality/AnySpec.js +++ b/spec/core/asymmetric_equality/AnySpec.js @@ -1,73 +1,73 @@ describe('Any', function() { it('matches a string', function() { - var any = new jasmineUnderTest.Any(String); + const any = new jasmineUnderTest.Any(String); expect(any.asymmetricMatch('foo')).toBe(true); }); it('matches a number', function() { - var any = new jasmineUnderTest.Any(Number); + const any = new jasmineUnderTest.Any(Number); expect(any.asymmetricMatch(1)).toBe(true); }); it('matches a function', function() { - var any = new jasmineUnderTest.Any(Function); + const any = new jasmineUnderTest.Any(Function); expect(any.asymmetricMatch(function() {})).toBe(true); }); it('matches an Object', function() { - var any = new jasmineUnderTest.Any(Object); + const any = new jasmineUnderTest.Any(Object); expect(any.asymmetricMatch({})).toBe(true); }); it('matches a Boolean', function() { - var any = new jasmineUnderTest.Any(Boolean); + const any = new jasmineUnderTest.Any(Boolean); expect(any.asymmetricMatch(true)).toBe(true); }); it('matches a Map', function() { - var any = new jasmineUnderTest.Any(Map); + const any = new jasmineUnderTest.Any(Map); expect(any.asymmetricMatch(new Map())).toBe(true); }); it('matches a Set', function() { - var any = new jasmineUnderTest.Any(Set); + const any = new jasmineUnderTest.Any(Set); expect(any.asymmetricMatch(new Set())).toBe(true); }); it('matches a TypedArray', function() { - var any = new jasmineUnderTest.Any(Uint32Array); + const any = new jasmineUnderTest.Any(Uint32Array); expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); }); it('matches a Symbol', function() { - var any = new jasmineUnderTest.Any(Symbol); + const any = new jasmineUnderTest.Any(Symbol); expect(any.asymmetricMatch(Symbol())).toBe(true); }); it('matches another constructed object', function() { - var Thing = function() {}, + const Thing = function() {}, any = new jasmineUnderTest.Any(Thing); expect(any.asymmetricMatch(new Thing())).toBe(true); }); it('does not treat null as an Object', function() { - var any = new jasmineUnderTest.Any(Object); + const any = new jasmineUnderTest.Any(Object); expect(any.asymmetricMatch(null)).toBe(false); }); it("jasmineToString's itself", function() { - var any = new jasmineUnderTest.Any(Number); + const any = new jasmineUnderTest.Any(Number); expect(any.jasmineToString()).toEqual(''); expect(any.jasmineToString()).toEqual(''); diff --git a/spec/core/asymmetric_equality/AnythingSpec.js b/spec/core/asymmetric_equality/AnythingSpec.js index e4a3df5f..a894995a 100644 --- a/spec/core/asymmetric_equality/AnythingSpec.js +++ b/spec/core/asymmetric_equality/AnythingSpec.js @@ -1,67 +1,67 @@ describe('Anything', function() { it('matches a string', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch('foo')).toBe(true); }); it('matches a number', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch(42)).toBe(true); }); it('matches an object', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true); }); it('matches an array', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch([1, 2, 3])).toBe(true); }); it('matches a Map', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch(new Map())).toBe(true); }); it('matches a Set', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch(new Set())).toBe(true); }); it('matches a TypedArray', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true); }); it('matches a Symbol', function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch(Symbol())).toBe(true); }); it("doesn't match undefined", function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch()).toBe(false); expect(anything.asymmetricMatch(undefined)).toBe(false); }); it("doesn't match null", function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.asymmetricMatch(null)).toBe(false); }); it("jasmineToString's itself", function() { - var anything = new jasmineUnderTest.Anything(); + const anything = new jasmineUnderTest.Anything(); expect(anything.jasmineToString()).toEqual(''); }); diff --git a/spec/core/asymmetric_equality/ArrayContainingSpec.js b/spec/core/asymmetric_equality/ArrayContainingSpec.js index 8024b5bd..96b77143 100644 --- a/spec/core/asymmetric_equality/ArrayContainingSpec.js +++ b/spec/core/asymmetric_equality/ArrayContainingSpec.js @@ -1,12 +1,12 @@ describe('ArrayContaining', function() { it('matches any actual to an empty array', function() { - var containing = new jasmineUnderTest.ArrayContaining([]); + const containing = new jasmineUnderTest.ArrayContaining([]); expect(containing.asymmetricMatch('foo')).toBe(true); }); it('does not work when not passed an array', function() { - var containing = new jasmineUnderTest.ArrayContaining('foo'); + const containing = new jasmineUnderTest.ArrayContaining('foo'); expect(function() { containing.asymmetricMatch([]); @@ -14,35 +14,35 @@ describe('ArrayContaining', function() { }); it('matches when the item is in the actual', function() { - var containing = new jasmineUnderTest.ArrayContaining(['foo']); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ArrayContaining(['foo']); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(['foo'], matchersUtil)).toBe(true); }); it('matches when additional items are in the actual', function() { - var containing = new jasmineUnderTest.ArrayContaining(['foo']); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ArrayContaining(['foo']); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(['foo', 'bar'], matchersUtil)).toBe(true); }); it('does not match when the item is not in the actual', function() { - var containing = new jasmineUnderTest.ArrayContaining(['foo']); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ArrayContaining(['foo']); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(['bar'], matchersUtil)).toBe(false); }); it('does not match when the actual is not an array', function() { - var containing = new jasmineUnderTest.ArrayContaining(['foo']); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ArrayContaining(['foo']); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch('foo', matchersUtil)).toBe(false); }); it('jasmineToStrings itself', function() { - var sample = [], + const sample = [], matcher = new jasmineUnderTest.ArrayContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); @@ -53,7 +53,7 @@ describe('ArrayContaining', function() { }); it('uses custom equality testers', function() { - var tester = function(a, b) { + const tester = function(a, b) { // All "foo*" strings match each other. if ( typeof a == 'string' && @@ -64,8 +64,8 @@ describe('ArrayContaining', function() { return true; } }; - var containing = new jasmineUnderTest.ArrayContaining(['fooVal']); - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const containing = new jasmineUnderTest.ArrayContaining(['fooVal']); + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }); diff --git a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js index c6e111a0..d2197bbf 100644 --- a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +++ b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js @@ -1,13 +1,13 @@ describe('ArrayWithExactContents', function() { it('matches an array with the same items in a different order', function() { - var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matcher.asymmetricMatch([2, 'a', /a/], matchersUtil)).toBe(true); }); it('does not work when not passed an array', function() { - var matcher = new jasmineUnderTest.ArrayWithExactContents('foo'); + const matcher = new jasmineUnderTest.ArrayWithExactContents('foo'); expect(function() { matcher.asymmetricMatch([]); @@ -15,8 +15,8 @@ describe('ArrayWithExactContents', function() { }); it('does not match when an item is missing', function() { - var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false); expect(matcher.asymmetricMatch(['a', 2, undefined], matchersUtil)).toBe( @@ -25,14 +25,14 @@ describe('ArrayWithExactContents', function() { }); it('does not match when there is an extra item', function() { - var matcher = new jasmineUnderTest.ArrayWithExactContents(['a']); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matcher = new jasmineUnderTest.ArrayWithExactContents(['a']); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false); }); it('jasmineToStrings itself', function() { - var sample = [], + const sample = [], matcher = new jasmineUnderTest.ArrayWithExactContents(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); @@ -43,7 +43,7 @@ describe('ArrayWithExactContents', function() { }); it('uses custom equality testers', function() { - var tester = function(a, b) { + const tester = function(a, b) { // All "foo*" strings match each other. if ( typeof a == 'string' && @@ -54,8 +54,8 @@ describe('ArrayWithExactContents', function() { return true; } }; - var matcher = new jasmineUnderTest.ArrayWithExactContents(['fooVal']); - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matcher = new jasmineUnderTest.ArrayWithExactContents(['fooVal']); + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }); diff --git a/spec/core/asymmetric_equality/EmptySpec.js b/spec/core/asymmetric_equality/EmptySpec.js index a99f0458..25a467c5 100644 --- a/spec/core/asymmetric_equality/EmptySpec.js +++ b/spec/core/asymmetric_equality/EmptySpec.js @@ -1,20 +1,20 @@ describe('Empty', function() { it('matches an empty object', function() { - var empty = new jasmineUnderTest.Empty(); + const empty = new jasmineUnderTest.Empty(); expect(empty.asymmetricMatch({})).toBe(true); expect(empty.asymmetricMatch({ undefined: false })).toBe(false); }); it('matches an empty array', function() { - var empty = new jasmineUnderTest.Empty(); + const empty = new jasmineUnderTest.Empty(); expect(empty.asymmetricMatch([])).toBe(true); expect(empty.asymmetricMatch([1, 12, 3])).toBe(false); }); it('matches an empty string', function() { - var empty = new jasmineUnderTest.Empty(); + const empty = new jasmineUnderTest.Empty(); expect(empty.asymmetricMatch('')).toBe(true); expect(empty.asymmetricMatch('')).toBe(true); @@ -22,8 +22,8 @@ describe('Empty', function() { }); it('matches an empty map', function() { - var empty = new jasmineUnderTest.Empty(); - var fullMap = new Map(); + const empty = new jasmineUnderTest.Empty(); + const fullMap = new Map(); fullMap.set('thing', 2); expect(empty.asymmetricMatch(new Map())).toBe(true); @@ -31,8 +31,8 @@ describe('Empty', function() { }); it('matches an empty set', function() { - var empty = new jasmineUnderTest.Empty(); - var fullSet = new Set(); + const empty = new jasmineUnderTest.Empty(); + const fullSet = new Set(); fullSet.add(3); expect(empty.asymmetricMatch(new Set())).toBe(true); @@ -40,7 +40,7 @@ describe('Empty', function() { }); it('matches an empty typed array', function() { - var empty = new jasmineUnderTest.Empty(); + const empty = new jasmineUnderTest.Empty(); expect(empty.asymmetricMatch(new Int16Array())).toBe(true); expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false); diff --git a/spec/core/asymmetric_equality/FalsySpec.js b/spec/core/asymmetric_equality/FalsySpec.js index f511c145..01312d26 100644 --- a/spec/core/asymmetric_equality/FalsySpec.js +++ b/spec/core/asymmetric_equality/FalsySpec.js @@ -1,6 +1,6 @@ describe('Falsy', function() { it('is true for an empty string', function() { - var falsy = new jasmineUnderTest.Falsy(); + const falsy = new jasmineUnderTest.Falsy(); expect(falsy.asymmetricMatch('')).toBe(true); expect(falsy.asymmetricMatch('')).toBe(true); @@ -8,7 +8,7 @@ describe('Falsy', function() { }); it('is false for a number that is 0', function() { - var falsy = new jasmineUnderTest.Falsy(Number); + const falsy = new jasmineUnderTest.Falsy(Number); expect(falsy.asymmetricMatch(1)).toBe(false); expect(falsy.asymmetricMatch(0)).toBe(true); @@ -17,20 +17,20 @@ describe('Falsy', function() { }); it('is true for a null or undefined', function() { - var falsy = new jasmineUnderTest.Falsy(Function); + const falsy = new jasmineUnderTest.Falsy(Function); expect(falsy.asymmetricMatch(null)).toBe(true); expect(falsy.asymmetricMatch(undefined)).toBe(true); }); it('is true for NaN', function() { - var falsy = new jasmineUnderTest.Falsy(Object); + const falsy = new jasmineUnderTest.Falsy(Object); expect(falsy.asymmetricMatch(NaN)).toBe(true); }); it('is true for a false Boolean', function() { - var falsy = new jasmineUnderTest.Falsy(Boolean); + const falsy = new jasmineUnderTest.Falsy(Boolean); expect(falsy.asymmetricMatch(false)).toBe(true); expect(falsy.asymmetricMatch(true)).toBe(false); diff --git a/spec/core/asymmetric_equality/MapContainingSpec.js b/spec/core/asymmetric_equality/MapContainingSpec.js index dbee6bf5..934084b9 100644 --- a/spec/core/asymmetric_equality/MapContainingSpec.js +++ b/spec/core/asymmetric_equality/MapContainingSpec.js @@ -1,104 +1,110 @@ describe('MapContaining', function() { it('matches any actual map to an empty map', function() { - var actualMap = new Map([['foo', 'bar']]); - var containing = new jasmineUnderTest.MapContaining(new Map()); + const actualMap = new Map([['foo', 'bar']]); + const containing = new jasmineUnderTest.MapContaining(new Map()); expect(containing.asymmetricMatch(actualMap)).toBe(true); }); it('matches when all the key/value pairs in sample have matches in actual', function() { - var actualMap = new Map([ + const actualMap = new Map([ ['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz'], ['other', 'any'] ]); - var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containingMap = new Map([ + [{ foo: 'bar' }, 'baz'], + ['foo', [1, 2, 3]] + ]); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true); }); it('does not match when a key is not in actual', function() { - var actualMap = new Map([ + const actualMap = new Map([ ['foo', [1, 2, 3]], [{ foo: 'not a bar' }, 'baz'] ]); - var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containingMap = new Map([ + [{ foo: 'bar' }, 'baz'], + ['foo', [1, 2, 3]] + ]); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); it('does not match when a value is not in actual', function() { - var actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]); + const actualMap = new Map([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]); - var containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containingMap = new Map([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); it('matches when all the key/value pairs in sample have asymmetric matches in actual', function() { - var actualMap = new Map([ + const actualMap = new Map([ ['foo1', 'not a bar'], ['foo2', 'bar'], ['baz', [1, 2, 3, 4]] ]); - var containingMap = new Map([ + const containingMap = new Map([ [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], ['baz', jasmineUnderTest.arrayContaining([2, 3])] ]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true); }); it('does not match when a key in sample has no asymmetric matches in actual', function() { - var actualMap = new Map([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]); + const actualMap = new Map([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]); - var containingMap = new Map([ + const containingMap = new Map([ [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], ['baz', jasmineUnderTest.arrayContaining([2, 3])] ]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); it('does not match when a value in sample has no asymmetric matches in actual', function() { - var actualMap = new Map([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]); + const actualMap = new Map([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]); - var containingMap = new Map([ + const containingMap = new Map([ [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'], ['baz', jasmineUnderTest.arrayContaining([4, 5])] ]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(false); }); it('matches recursively', function() { - var actualMap = new Map([ + const actualMap = new Map([ ['foo', new Map([['foo1', 1], ['foo2', 2]])], [new Map([[1, 'bar1'], [2, 'bar2']]), 'bar'], ['other', 'any'] ]); - var containingMap = new Map([ + const containingMap = new Map([ ['foo', new jasmineUnderTest.MapContaining(new Map([['foo1', 1]]))], [new jasmineUnderTest.MapContaining(new Map([[2, 'bar2']])), 'bar'] ]); - var containing = new jasmineUnderTest.MapContaining(containingMap); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.MapContaining(containingMap); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true); }); @@ -110,9 +116,11 @@ describe('MapContaining', function() { ? a < 0 && b < 0 : a === b; } - var actualMap = new Map([['foo', -1]]); - var containing = new jasmineUnderTest.MapContaining(new Map([['foo', -2]])); - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const actualMap = new Map([['foo', -1]]); + const containing = new jasmineUnderTest.MapContaining( + new Map([['foo', -2]]) + ); + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }); @@ -120,7 +128,7 @@ describe('MapContaining', function() { }); it('does not match when actual is not a map', function() { - var containingMap = new Map([['foo', 'bar']]); + const containingMap = new Map([['foo', 'bar']]); expect( new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo') ).toBe(false); @@ -143,7 +151,7 @@ describe('MapContaining', function() { }); it('defines a `jasmineToString` method', function() { - var sample = new Map(), + const sample = new Map(), containing = new jasmineUnderTest.MapContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); diff --git a/spec/core/asymmetric_equality/NotEmptySpec.js b/spec/core/asymmetric_equality/NotEmptySpec.js index 52c4b692..7494135f 100644 --- a/spec/core/asymmetric_equality/NotEmptySpec.js +++ b/spec/core/asymmetric_equality/NotEmptySpec.js @@ -1,20 +1,20 @@ describe('NotEmpty', function() { it('matches a non empty object', function() { - var notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new jasmineUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch({ undefined: false })).toBe(true); expect(notEmpty.asymmetricMatch({})).toBe(false); }); it('matches a non empty array', function() { - var notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new jasmineUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch([1, 12, 3])).toBe(true); expect(notEmpty.asymmetricMatch([])).toBe(false); }); it('matches a non empty string', function() { - var notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new jasmineUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch('12312')).toBe(true); expect(notEmpty.asymmetricMatch('')).toBe(false); @@ -22,27 +22,27 @@ describe('NotEmpty', function() { }); it('matches a non empty map', function() { - var notEmpty = new jasmineUnderTest.NotEmpty(); - var fullMap = new Map(); + const notEmpty = new jasmineUnderTest.NotEmpty(); + const fullMap = new Map(); fullMap.set('one', 1); - var emptyMap = new Map(); + const emptyMap = new Map(); expect(notEmpty.asymmetricMatch(fullMap)).toBe(true); expect(notEmpty.asymmetricMatch(emptyMap)).toBe(false); }); it('matches a non empty set', function() { - var notEmpty = new jasmineUnderTest.NotEmpty(); - var filledSet = new Set(); + const notEmpty = new jasmineUnderTest.NotEmpty(); + const filledSet = new Set(); filledSet.add(1); - var emptySet = new Set(); + const emptySet = new Set(); expect(notEmpty.asymmetricMatch(filledSet)).toBe(true); expect(notEmpty.asymmetricMatch(emptySet)).toBe(false); }); it('matches a non empty typed array', function() { - var notEmpty = new jasmineUnderTest.NotEmpty(); + const notEmpty = new jasmineUnderTest.NotEmpty(); expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true); expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false); diff --git a/spec/core/asymmetric_equality/ObjectContainingSpec.js b/spec/core/asymmetric_equality/ObjectContainingSpec.js index 9b567892..98bf01b3 100644 --- a/spec/core/asymmetric_equality/ObjectContainingSpec.js +++ b/spec/core/asymmetric_equality/ObjectContainingSpec.js @@ -1,13 +1,13 @@ describe('ObjectContaining', function() { it('matches any object actual to an empty object', function() { - var containing = new jasmineUnderTest.ObjectContaining({}); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({}); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({ foo: 1 }, matchersUtil)).toBe(true); }); it('does not match when the actual is not an object', function() { - var containing = new jasmineUnderTest.ObjectContaining({}); + const containing = new jasmineUnderTest.ObjectContaining({}); [1, true, undefined, 'a string'].forEach(function(actual) { expect(containing.asymmetricMatch(actual)).toBe(false); @@ -15,7 +15,7 @@ describe('ObjectContaining', function() { }); it('does not match an empty object actual', function() { - var containing = new jasmineUnderTest.ObjectContaining('foo'); + const containing = new jasmineUnderTest.ObjectContaining('foo'); expect(function() { containing.asymmetricMatch({}); @@ -23,8 +23,8 @@ describe('ObjectContaining', function() { }); it('matches when the key/value pair is present in the actual', function() { - var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil) @@ -32,8 +32,8 @@ describe('ObjectContaining', function() { }); it('does not match when the key/value pair is not present in the actual', function() { - var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( containing.asymmetricMatch( @@ -44,8 +44,8 @@ describe('ObjectContaining', function() { }); it('does not match when the key is present but the value is different in the actual', function() { - var containing = new jasmineUnderTest.ObjectContaining({ foo: 'other' }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ foo: 'other' }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil) @@ -53,7 +53,7 @@ describe('ObjectContaining', function() { }); it("jasmineToString's itself", function() { - var sample = {}, + const sample = {}, matcher = new jasmineUnderTest.ObjectContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); @@ -64,10 +64,10 @@ describe('ObjectContaining', function() { }); it('matches recursively', function() { - var containing = new jasmineUnderTest.ObjectContaining({ + const containing = new jasmineUnderTest.ObjectContaining({ one: new jasmineUnderTest.ObjectContaining({ two: {} }) }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({ one: { two: {} } }, matchersUtil)).toBe( true @@ -75,8 +75,10 @@ describe('ObjectContaining', function() { }); it('matches when key is present with undefined value', function() { - var containing = new jasmineUnderTest.ObjectContaining({ one: undefined }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ + one: undefined + }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({ one: undefined }, matchersUtil)).toBe( true @@ -84,17 +86,19 @@ describe('ObjectContaining', function() { }); it('does not match when key with undefined value is not present', function() { - var containing = new jasmineUnderTest.ObjectContaining({ one: undefined }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ + one: undefined + }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch({}, matchersUtil)).toBe(false); }); it('matches defined properties', function() { - var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); - var definedPropertyObject = {}; + const definedPropertyObject = {}; Object.defineProperty(definedPropertyObject, 'foo', { get: function() { return 'fooVal'; @@ -106,17 +110,17 @@ describe('ObjectContaining', function() { }); it('matches prototype properties', function() { - var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); - var prototypeObject = { foo: 'fooVal' }; - var obj = Object.create(prototypeObject); + const prototypeObject = { foo: 'fooVal' }; + const obj = Object.create(prototypeObject); expect(containing.asymmetricMatch(obj, matchersUtil)).toBe(true); }); it('uses custom equality testers', function() { - var tester = function(a, b) { + const tester = function(a, b) { // All "foo*" strings match each other. if ( typeof a == 'string' && @@ -127,8 +131,8 @@ describe('ObjectContaining', function() { return true; } }; - var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' }); + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }); @@ -140,7 +144,7 @@ describe('ObjectContaining', function() { describe('valuesForDiff_', function() { describe('when other is not an object', function() { it('sets self to jasmineToString()', function() { - var containing = new jasmineUnderTest.ObjectContaining({}), + const containing = new jasmineUnderTest.ObjectContaining({}), pp = jasmineUnderTest.makePrettyPrinter(), result = containing.valuesForDiff_('a', pp); @@ -153,7 +157,7 @@ describe('ObjectContaining', function() { describe('when other is an object', function() { it('includes keys that are present in both other and sample', function() { - var sample = { a: 1, b: 2 }, + const sample = { a: 1, b: 2 }, other = { a: 3, b: 4 }, containing = new jasmineUnderTest.ObjectContaining(sample), result = containing.valuesForDiff_(other); @@ -168,7 +172,7 @@ describe('ObjectContaining', function() { }); it('includes keys that are present only in sample', function() { - var sample = { a: 1, b: 2 }, + const sample = { a: 1, b: 2 }, other = { a: 3 }, containing = new jasmineUnderTest.ObjectContaining(sample), result = containing.valuesForDiff_(other); @@ -186,7 +190,7 @@ describe('ObjectContaining', function() { }); it('omits keys that are present only in other', function() { - var sample = { a: 1, b: 2 }, + const sample = { a: 1, b: 2 }, other = { a: 3, b: 4, c: 5 }, containing = new jasmineUnderTest.ObjectContaining(sample), result = containing.valuesForDiff_(other); diff --git a/spec/core/asymmetric_equality/SetContainingSpec.js b/spec/core/asymmetric_equality/SetContainingSpec.js index 6c2efc2b..ab7654b6 100644 --- a/spec/core/asymmetric_equality/SetContainingSpec.js +++ b/spec/core/asymmetric_equality/SetContainingSpec.js @@ -1,66 +1,66 @@ describe('SetContaining', function() { it('matches any actual set to an empty set', function() { - var actualSet = new Set(['foo', 'bar']); - var containing = new jasmineUnderTest.SetContaining(new Set()); + const actualSet = new Set(['foo', 'bar']); + const containing = new jasmineUnderTest.SetContaining(new Set()); expect(containing.asymmetricMatch(actualSet)).toBe(true); }); it('matches when all the values in sample have matches in actual', function() { - var actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]); + const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]); - var containingSet = new Set([[1, 2, 3], { foo: 'bar' }]); - var containing = new jasmineUnderTest.SetContaining(containingSet); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containingSet = new Set([[1, 2, 3], { foo: 'bar' }]); + const containing = new jasmineUnderTest.SetContaining(containingSet); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true); }); it('does not match when a value is not in actual', function() { - var actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]); + const actualSet = new Set([{ foo: 'bar' }, 'baz', [1, 2, 3]]); - var containingSet = new Set([[1, 2], { foo: 'bar' }]); - var containing = new jasmineUnderTest.SetContaining(containingSet); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containingSet = new Set([[1, 2], { foo: 'bar' }]); + const containing = new jasmineUnderTest.SetContaining(containingSet); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false); }); it('matches when all the values in sample have asymmetric matches in actual', function() { - var actualSet = new Set([[1, 2, 3, 4], 'other', 'foo1']); + const actualSet = new Set([[1, 2, 3, 4], 'other', 'foo1']); - var containingSet = new Set([ + const containingSet = new Set([ jasmineUnderTest.stringMatching(/^foo\d/), jasmineUnderTest.arrayContaining([2, 3]) ]); - var containing = new jasmineUnderTest.SetContaining(containingSet); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.SetContaining(containingSet); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true); }); it('does not match when a value in sample has no asymmetric matches in actual', function() { - var actualSet = new Set(['a-foo1', [1, 2, 3, 4], 'other']); + const actualSet = new Set(['a-foo1', [1, 2, 3, 4], 'other']); - var containingSet = new Set([ + const containingSet = new Set([ jasmine.stringMatching(/^foo\d/), jasmine.arrayContaining([2, 3]) ]); - var containing = new jasmineUnderTest.SetContaining(containingSet); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.SetContaining(containingSet); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(false); }); it('matches recursively', function() { - var actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']); + const actualSet = new Set(['foo', new Set([1, 'bar', 2]), 'other']); - var containingSet = new Set([ + const containingSet = new Set([ new jasmineUnderTest.SetContaining(new Set(['bar'])), 'foo' ]); - var containing = new jasmineUnderTest.SetContaining(containingSet); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const containing = new jasmineUnderTest.SetContaining(containingSet); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true); }); @@ -72,9 +72,9 @@ describe('SetContaining', function() { ? a < 0 && b < 0 : a === b; } - var actualSet = new Set(['foo', -1]); - var containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo'])); - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const actualSet = new Set(['foo', -1]); + const containing = new jasmineUnderTest.SetContaining(new Set([-2, 'foo'])); + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }); @@ -82,7 +82,7 @@ describe('SetContaining', function() { }); it('does not match when actual is not a set', function() { - var containingSet = new Set(['foo']); + const containingSet = new Set(['foo']); expect( new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo') ).toBe(false); @@ -103,7 +103,7 @@ describe('SetContaining', function() { }); it('defines a `jasmineToString` method', function() { - var sample = new Set(), + const sample = new Set(), containing = new jasmineUnderTest.SetContaining(sample), pp = jasmine.createSpy('pp').and.returnValue('sample'); diff --git a/spec/core/asymmetric_equality/StringContainingSpec.js b/spec/core/asymmetric_equality/StringContainingSpec.js index aef1f48e..bae3b398 100644 --- a/spec/core/asymmetric_equality/StringContainingSpec.js +++ b/spec/core/asymmetric_equality/StringContainingSpec.js @@ -1,6 +1,6 @@ describe('StringContaining', function() { it('searches for a provided substring when the expected is a String', function() { - var matcher = new jasmineUnderTest.StringContaining('foo'); + const matcher = new jasmineUnderTest.StringContaining('foo'); expect(matcher.asymmetricMatch('barfoobaz')).toBe(true); expect(matcher.asymmetricMatch('barbaz')).toBe(false); @@ -13,12 +13,12 @@ describe('StringContaining', function() { }); it('fails when the actual is not a String', function() { - var matcher = new jasmineUnderTest.StringContaining('x'); + const matcher = new jasmineUnderTest.StringContaining('x'); expect(matcher.asymmetricMatch(['x'])).toBe(false); }); it("jasmineToString's itself", function() { - var matching = new jasmineUnderTest.StringContaining('foo'); + const matching = new jasmineUnderTest.StringContaining('foo'); expect(matching.jasmineToString()).toEqual( '' diff --git a/spec/core/asymmetric_equality/StringMatchingSpec.js b/spec/core/asymmetric_equality/StringMatchingSpec.js index 656b0e50..cec1ebe1 100644 --- a/spec/core/asymmetric_equality/StringMatchingSpec.js +++ b/spec/core/asymmetric_equality/StringMatchingSpec.js @@ -1,13 +1,13 @@ describe('StringMatching', function() { it('matches a string against a provided regexp', function() { - var matcher = new jasmineUnderTest.StringMatching(/foo/); + const matcher = new jasmineUnderTest.StringMatching(/foo/); expect(matcher.asymmetricMatch('barfoobaz')).toBe(true); expect(matcher.asymmetricMatch('barbaz')).toBe(false); }); it('matches a string against provided string', function() { - var matcher = new jasmineUnderTest.StringMatching('foo'); + const matcher = new jasmineUnderTest.StringMatching('foo'); expect(matcher.asymmetricMatch('barfoobaz')).toBe(true); expect(matcher.asymmetricMatch('barbaz')).toBe(false); @@ -20,7 +20,7 @@ describe('StringMatching', function() { }); it("jasmineToString's itself", function() { - var matching = new jasmineUnderTest.StringMatching(/^foo/); + const matching = new jasmineUnderTest.StringMatching(/^foo/); expect(matching.jasmineToString()).toEqual( '' diff --git a/spec/core/asymmetric_equality/TruthySpec.js b/spec/core/asymmetric_equality/TruthySpec.js index b2ac2775..755503f4 100644 --- a/spec/core/asymmetric_equality/TruthySpec.js +++ b/spec/core/asymmetric_equality/TruthySpec.js @@ -1,13 +1,13 @@ describe('Truthy', function() { it('is true for a non empty string', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch('foo')).toBe(true); expect(truthy.asymmetricMatch('')).toBe(false); }); it('is true for a number that is not 0', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch(1)).toBe(true); expect(truthy.asymmetricMatch(0)).toBe(false); @@ -16,44 +16,44 @@ describe('Truthy', function() { }); it('is true for a function', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch(function() {})).toBe(true); }); it('is true for an Object', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch({})).toBe(true); }); it('is true for a truthful Boolean', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch(true)).toBe(true); expect(truthy.asymmetricMatch(false)).toBe(false); }); it('is true for an empty object', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch({})).toBe(true); }); it('is true for an empty array', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch([])).toBe(true); }); it('is true for a date', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch(new Date())).toBe(true); }); it('is true for a infiniti', function() { - var truthy = new jasmineUnderTest.Truthy(); + const truthy = new jasmineUnderTest.Truthy(); expect(truthy.asymmetricMatch(Infinity)).toBe(true); expect(truthy.asymmetricMatch(-Infinity)).toBe(true); diff --git a/spec/core/baseSpec.js b/spec/core/baseSpec.js index 703a4f50..e0c828c5 100644 --- a/spec/core/baseSpec.js +++ b/spec/core/baseSpec.js @@ -6,9 +6,9 @@ describe('base helpers', function() { return; } - var obj = (function() { - var sock = new WebSocket('ws://localhost'); - var event; + const obj = (function() { + const sock = new WebSocket('ws://localhost'); + let event; sock.onerror = function(e) { event = e; }; @@ -16,11 +16,11 @@ describe('base helpers', function() { return event; }; })(); - var left = 20; + let left = 20; - var int = setInterval(function() { + const int = setInterval(function() { if (obj() || left === 0) { - var result = jasmineUnderTest.isError_(obj()); + const result = jasmineUnderTest.isError_(obj()); expect(result).toBe(false); clearInterval(int); done(); @@ -41,18 +41,16 @@ describe('base helpers', function() { }); it('returns true for an Error that originated from another frame', function() { - var iframe, error; - if (typeof window === 'undefined') { pending('This test only runs in browsers.'); } - iframe = document.createElement('iframe'); + const iframe = document.createElement('iframe'); iframe.style.display = 'none'; document.body.appendChild(iframe); try { - error = iframe.contentWindow.eval('new Error()'); + const error = iframe.contentWindow.eval('new Error()'); expect(jasmineUnderTest.isError_(error)).toBe(true); } finally { document.body.removeChild(iframe); @@ -74,17 +72,17 @@ describe('base helpers', function() { }); it('returns false when the argument does not have a asymmetricMatch property', function() { - var obj = {}; + const obj = {}; expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(false); }); it("returns false when the argument's asymmetricMatch is not a function", function() { - var obj = { asymmetricMatch: 'yes' }; + const obj = { asymmetricMatch: 'yes' }; expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(false); }); it("returns true when the argument's asymmetricMatch is a function", function() { - var obj = { asymmetricMatch: function() {} }; + const obj = { asymmetricMatch: function() {} }; expect(jasmineUnderTest.isAsymmetricEqualityTester_(obj)).toBe(true); }); }); @@ -133,21 +131,21 @@ describe('base helpers', function() { describe('isPending_', function() { it('returns a promise that resolves to true when the promise is pending', function() { - var promise = new Promise(function() {}); + const promise = new Promise(function() {}); return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( true ); }); it('returns a promise that resolves to false when the promise is resolved', function() { - var promise = Promise.resolve(); + const promise = Promise.resolve(); return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( false ); }); it('returns a promise that resolves to false when the promise is rejected', function() { - var promise = Promise.reject(); + const promise = Promise.reject(); return expectAsync(jasmineUnderTest.isPending_(promise)).toBeResolvedTo( false ); @@ -155,7 +153,7 @@ describe('base helpers', function() { }); describe('DEFAULT_TIMEOUT_INTERVAL setter', function() { - var max = 2147483647; + const max = 2147483647; beforeEach(function() { this.initialValue = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL; @@ -177,14 +175,13 @@ describe('base helpers', function() { }); it('is consistent with setTimeout in this environment', function(done) { - var f1 = jasmine.createSpy('setTimeout callback for ' + max), - f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1)), - id; + const f1 = jasmine.createSpy('setTimeout callback for ' + max), + f2 = jasmine.createSpy('setTimeout callback for ' + (max + 1)); // Suppress printing of TimeoutOverflowWarning in node spyOn(console, 'error'); - id = setTimeout(f1, max); + let id = setTimeout(f1, max); setTimeout(function() { clearTimeout(id); expect(f1).not.toHaveBeenCalled(); diff --git a/spec/core/formatErrorMsgSpec.js b/spec/core/formatErrorMsgSpec.js index a85665e9..aae60be1 100644 --- a/spec/core/formatErrorMsgSpec.js +++ b/spec/core/formatErrorMsgSpec.js @@ -1,12 +1,12 @@ describe('formatErrorMsg', function() { it('should format an error with a domain', function() { - var formator = jasmineUnderTest.formatErrorMsg('api'); + const formator = jasmineUnderTest.formatErrorMsg('api'); expect(formator('message')).toBe('api : message'); expect(formator('message2')).toBe('api : message2'); }); it('should format an error with a domain and usage', function() { - var formator = jasmineUnderTest.formatErrorMsg('api', 'with a param'); + const formator = jasmineUnderTest.formatErrorMsg('api', 'with a param'); expect(formator('message')).toBe('api : message\nUsage: with a param'); expect(formator('message2')).toBe('api : message2\nUsage: with a param'); }); diff --git a/spec/core/integration/AsymmetricEqualityTestersSpec.js b/spec/core/integration/AsymmetricEqualityTestersSpec.js index 4a6e761f..07c8fc58 100644 --- a/spec/core/integration/AsymmetricEqualityTestersSpec.js +++ b/spec/core/integration/AsymmetricEqualityTestersSpec.js @@ -1,12 +1,12 @@ describe('Asymmetric equality testers (Integration)', function() { function verifyPasses(expectations) { it('passes', function(done) { - var env = new jasmineUnderTest.Env(); + const env = new jasmineUnderTest.Env(); env.it('a spec', function() { expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); expect(result.passedExpectations.length) .withContext('Number of passed expectations') @@ -28,12 +28,12 @@ describe('Asymmetric equality testers (Integration)', function() { function verifyFails(expectations) { it('fails', function(done) { - var env = new jasmineUnderTest.Env(); + const env = new jasmineUnderTest.Env(); env.it('a spec', function() { expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -123,9 +123,9 @@ describe('Asymmetric equality testers (Integration)', function() { describe('mapContaining', function() { verifyPasses(function(env) { - var actual = new Map(); + const actual = new Map(); actual.set('a', '2'); - var expected = new Map(); + const expected = new Map(); expected.set('a', 2); env.addCustomEqualityTester(function(a, b) { @@ -170,9 +170,9 @@ describe('Asymmetric equality testers (Integration)', function() { describe('setContaining', function() { verifyPasses(function(env) { - var actual = new Set(); + const actual = new Set(); actual.add('1'); - var expected = new Set(); + const expected = new Set(); actual.add(1); env.addCustomEqualityTester(function(a, b) { diff --git a/spec/core/integration/CustomAsyncMatchersSpec.js b/spec/core/integration/CustomAsyncMatchersSpec.js index 637e348e..82c5e48e 100644 --- a/spec/core/integration/CustomAsyncMatchersSpec.js +++ b/spec/core/integration/CustomAsyncMatchersSpec.js @@ -1,5 +1,5 @@ describe('Custom Async Matchers (Integration)', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -25,7 +25,7 @@ describe('Custom Async Matchers (Integration)', function() { return env.expectAsync(true).toBeReal(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); }; @@ -51,7 +51,7 @@ describe('Custom Async Matchers (Integration)', function() { return env.expectAsync(true).not.toBeReal(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); }; @@ -74,7 +74,7 @@ describe('Custom Async Matchers (Integration)', function() { return env.expectAsync('a').toBeReal(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.failedExpectations[0].message).toEqual( "Expected 'a' to be real." ); @@ -85,7 +85,7 @@ describe('Custom Async Matchers (Integration)', function() { }); it('passes the jasmine utility to the matcher factory', function(done) { - var matcherFactory = function() { + const matcherFactory = function() { return { compare: function() { return Promise.resolve({ pass: true }); @@ -105,7 +105,7 @@ describe('Custom Async Matchers (Integration)', function() { return env.expectAsync(true).toBeReal(); }); - var specExpectations = function() { + const specExpectations = function() { expect(matcherFactorySpy).toHaveBeenCalledWith( jasmine.any(jasmineUnderTest.MatchersUtil) ); @@ -116,7 +116,7 @@ describe('Custom Async Matchers (Integration)', function() { }); it('provides custom equality testers to the matcher factory via matchersUtil', function(done) { - var matcherFactory = function(matchersUtil) { + const matcherFactory = function(matchersUtil) { return { compare: function(actual, expected) { return Promise.resolve({ @@ -140,7 +140,7 @@ describe('Custom Async Matchers (Integration)', function() { return env.expectAsync([1, 2]).toBeArrayWithFirstElement('1'); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(customEqualityFn).toHaveBeenCalledWith(1, '1'); expect(result.failedExpectations).toEqual([]); }; diff --git a/spec/core/integration/CustomMatchersSpec.js b/spec/core/integration/CustomMatchersSpec.js index a5b8ac62..eba7bd16 100644 --- a/spec/core/integration/CustomMatchersSpec.js +++ b/spec/core/integration/CustomMatchersSpec.js @@ -1,5 +1,5 @@ describe('Custom Matchers (Integration)', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -36,9 +36,9 @@ describe('Custom Matchers (Integration)', function() { expect(env.expect('zzz').matcherForSpec).toBeUndefined(); }); - var specDoneSpy = jasmine.createSpy('specDoneSpy'); - var expectations = function() { - var firstSpecResult = specDoneSpy.calls.first().args[0]; + const specDoneSpy = jasmine.createSpy('specDoneSpy'); + const expectations = function() { + const firstSpecResult = specDoneSpy.calls.first().args[0]; expect(firstSpecResult.status).toEqual('failed'); expect(firstSpecResult.failedExpectations[0].message).toEqual( 'matcherForSpec: actual: zzz; expected: yyy' @@ -65,7 +65,7 @@ describe('Custom Matchers (Integration)', function() { env.expect(true).toBeReal(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); }; @@ -75,7 +75,7 @@ describe('Custom Matchers (Integration)', function() { it('passes the spec if the custom equality matcher passes for types nested inside asymmetric equality testers', function(done) { env.it('spec using custom equality matcher', function() { - var customEqualityFn = function(a, b) { + const customEqualityFn = function(a, b) { // All "foo*" strings match each other. if ( typeof a == 'string' && @@ -99,7 +99,7 @@ describe('Custom Matchers (Integration)', function() { .toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar'])); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); }; @@ -109,7 +109,7 @@ describe('Custom Matchers (Integration)', function() { it('displays an appropriate failure message if a custom equality matcher fails', function(done) { env.it('spec using custom equality matcher', function() { - var customEqualityFn = function(a, b) { + const customEqualityFn = function(a, b) { // "foo" is not equal to anything if (a === 'foo' || b === 'foo') { return false; @@ -120,7 +120,7 @@ describe('Custom Matchers (Integration)', function() { env.expect({ foo: 'foo' }).toEqual({ foo: 'foo' }); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations[0].message).toEqual( "Expected $.foo = 'foo' to equal 'foo'." @@ -149,7 +149,7 @@ describe('Custom Matchers (Integration)', function() { env.expect(true).not.toBeReal(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); }; @@ -172,7 +172,7 @@ describe('Custom Matchers (Integration)', function() { env.expect('a').toBeReal(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.failedExpectations[0].message).toEqual( "Expected 'a' to be real." ); @@ -183,7 +183,7 @@ describe('Custom Matchers (Integration)', function() { }); it('passes the expected and actual arguments to the comparison function', function(done) { - var argumentSpy = jasmine + const argumentSpy = jasmine .createSpy('argument spy') .and.returnValue({ pass: true }); @@ -199,7 +199,7 @@ describe('Custom Matchers (Integration)', function() { env.expect(true).toBeReal('arg1', 'arg2'); }); - var specExpectations = function() { + const specExpectations = function() { expect(argumentSpy).toHaveBeenCalledWith(true); expect(argumentSpy).toHaveBeenCalledWith(true, 'arg'); expect(argumentSpy).toHaveBeenCalledWith(true, 'arg1', 'arg2'); @@ -210,7 +210,7 @@ describe('Custom Matchers (Integration)', function() { }); it('passes the jasmine utility to the matcher factory', function(done) { - var matcherFactory = function() { + const matcherFactory = function() { return { compare: function() { return { pass: true }; @@ -229,7 +229,7 @@ describe('Custom Matchers (Integration)', function() { env.expect(true).toBeReal(); }); - var specExpectations = function() { + const specExpectations = function() { expect(matcherFactorySpy).toHaveBeenCalledWith( jasmine.any(jasmineUnderTest.MatchersUtil) ); @@ -240,7 +240,7 @@ describe('Custom Matchers (Integration)', function() { }); it('provides custom equality testers to the matcher factory via matchersUtil', function(done) { - var matcherFactory = function(matchersUtil) { + const matcherFactory = function(matchersUtil) { return { compare: function(actual, expected) { return { pass: matchersUtil.equals(actual[0], expected) }; @@ -262,7 +262,7 @@ describe('Custom Matchers (Integration)', function() { env.expect([1, 2]).toBeArrayWithFirstElement('1'); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(customEqualityFn).toHaveBeenCalledWith(1, '1'); expect(result.failedExpectations).toEqual([]); }; diff --git a/spec/core/integration/CustomObjectFormatterSpec.js b/spec/core/integration/CustomObjectFormatterSpec.js index eec264dc..5a696b82 100644 --- a/spec/core/integration/CustomObjectFormatterSpec.js +++ b/spec/core/integration/CustomObjectFormatterSpec.js @@ -1,5 +1,5 @@ describe('Custom object formatters', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -18,11 +18,11 @@ describe('Custom object formatters', function() { env.expect(42).toBeUndefined(); }); - var specResults = []; - var specDone = function(result) { + const specResults = []; + const specDone = function(result) { specResults.push(result); }; - var expectations = function() { + const expectations = function() { expect(specResults[0].failedExpectations[0].message).toEqual( 'Expected custom(42) to be undefined.' ); @@ -53,11 +53,11 @@ describe('Custom object formatters', function() { }); }); - var specResults = []; - var specDone = function(result) { + const specResults = []; + const specDone = function(result) { specResults.push(result); }; - var expectations = function() { + const expectations = function() { expect(specResults[0].failedExpectations[0].message).toEqual( 'Expected 42 to be undefined.' ); diff --git a/spec/core/integration/CustomSpyStrategiesSpec.js b/spec/core/integration/CustomSpyStrategiesSpec.js index 676b00a7..5fdd3e1c 100644 --- a/spec/core/integration/CustomSpyStrategiesSpec.js +++ b/spec/core/integration/CustomSpyStrategiesSpec.js @@ -1,5 +1,5 @@ describe('Custom Spy Strategies (Integration)', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -11,8 +11,8 @@ describe('Custom Spy Strategies (Integration)', function() { }); it('allows adding more strategies local to a suite', async function() { - var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42); - var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan); + const plan = jasmine.createSpy('custom strategy plan').and.returnValue(42); + const strategy = jasmine.createSpy('custom strategy').and.returnValue(plan); env.describe('suite defining a custom spy strategy', function() { env.beforeAll(function() { @@ -20,7 +20,7 @@ describe('Custom Spy Strategies (Integration)', function() { }); env.it('spec in the suite', function() { - var spy = env.createSpy('something').and.frobnicate(17); + const spy = env.createSpy('something').and.frobnicate(17); expect(spy(1, 2, 3)).toEqual(42); expect(strategy).toHaveBeenCalledWith(17); expect(plan).toHaveBeenCalledWith(1, 2, 3); @@ -36,12 +36,12 @@ describe('Custom Spy Strategies (Integration)', function() { }); it('allows adding more strategies local to a spec', async function() { - var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42); - var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan); + const plan = jasmine.createSpy('custom strategy plan').and.returnValue(42); + const strategy = jasmine.createSpy('custom strategy').and.returnValue(plan); env.it('spec defining a custom spy strategy', function() { env.addSpyStrategy('frobnicate', strategy); - var spy = env.createSpy('something').and.frobnicate(17); + const spy = env.createSpy('something').and.frobnicate(17); expect(spy(1, 2, 3)).toEqual(42); expect(strategy).toHaveBeenCalledWith(17); expect(plan).toHaveBeenCalledWith(1, 2, 3); @@ -56,12 +56,12 @@ describe('Custom Spy Strategies (Integration)', function() { }); it('allows using custom strategies on a per-argument basis', async function() { - var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42); - var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan); + const plan = jasmine.createSpy('custom strategy plan').and.returnValue(42); + const strategy = jasmine.createSpy('custom strategy').and.returnValue(plan); env.it('spec defining a custom spy strategy', function() { env.addSpyStrategy('frobnicate', strategy); - var spy = env + const spy = env .createSpy('something') .and.returnValue('no args return') .withArgs(1, 2, 3) @@ -82,7 +82,7 @@ describe('Custom Spy Strategies (Integration)', function() { }); it('allows multiple custom strategies to be used', async function() { - var plan1 = jasmine.createSpy('plan 1').and.returnValue(42), + 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), @@ -96,7 +96,7 @@ describe('Custom Spy Strategies (Integration)', function() { env.it('frobnicates', function() { plan1.calls.reset(); plan2.calls.reset(); - var spy = env.createSpy('spy').and.frobnicate(); + const spy = env.createSpy('spy').and.frobnicate(); expect(spy()).toEqual(42); expect(plan1).toHaveBeenCalled(); expect(plan2).not.toHaveBeenCalled(); @@ -105,7 +105,7 @@ describe('Custom Spy Strategies (Integration)', function() { env.it('jiggles', function() { plan1.calls.reset(); plan2.calls.reset(); - var spy = env.createSpy('spy').and.jiggle(); + const spy = env.createSpy('spy').and.jiggle(); expect(spy()).toEqual(24); expect(plan1).not.toHaveBeenCalled(); expect(plan2).toHaveBeenCalled(); diff --git a/spec/core/integration/DefaultSpyStrategySpec.js b/spec/core/integration/DefaultSpyStrategySpec.js index 87325817..5f86bab1 100644 --- a/spec/core/integration/DefaultSpyStrategySpec.js +++ b/spec/core/integration/DefaultSpyStrategySpec.js @@ -1,5 +1,5 @@ describe('Default Spy Strategy (Integration)', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -19,13 +19,13 @@ describe('Default Spy Strategy (Integration)', function() { }); env.it('spec in suite', function() { - var spy = env.createSpy('something'); + const spy = env.createSpy('something'); expect(spy()).toBe(42); }); }); env.it('spec not in suite', function() { - var spy = env.createSpy('something'); + const spy = env.createSpy('something'); expect(spy()).toBeUndefined(); }); @@ -35,17 +35,17 @@ describe('Default Spy Strategy (Integration)', function() { it('uses the default spy strategy defined when the spy is created', async function() { env.it('spec', function() { - var a = env.createSpy('a'); + const a = env.createSpy('a'); env.setDefaultSpyStrategy(function(and) { and.returnValue(42); }); - var b = env.createSpy('b'); + const b = env.createSpy('b'); env.setDefaultSpyStrategy(function(and) { and.stub(); }); - var c = env.createSpy('c'); + const c = env.createSpy('c'); env.setDefaultSpyStrategy(); - var d = env.createSpy('d'); + const d = env.createSpy('d'); expect(a()).toBeUndefined(); expect(b()).toBe(42); diff --git a/spec/core/integration/DeprecationSpec.js b/spec/core/integration/DeprecationSpec.js index 5f9fb454..29748b84 100644 --- a/spec/core/integration/DeprecationSpec.js +++ b/spec/core/integration/DeprecationSpec.js @@ -1,6 +1,6 @@ /* eslint no-console: 0 */ describe('Deprecation (integration)', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -11,7 +11,7 @@ describe('Deprecation (integration)', function() { }); it('reports a deprecation on the top suite', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); + const reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); env.addReporter(reporter); spyOn(console, 'error'); @@ -38,7 +38,7 @@ describe('Deprecation (integration)', function() { }); it('reports a deprecation on a descendent suite', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['suiteDone']); + const reporter = jasmine.createSpyObj('reporter', ['suiteDone']); env.addReporter(reporter); spyOn(console, 'error'); @@ -69,7 +69,7 @@ describe('Deprecation (integration)', function() { }); it('reports a deprecation on a spec', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['specDone']); + const reporter = jasmine.createSpyObj('reporter', ['specDone']); env.addReporter(reporter); spyOn(console, 'error'); @@ -99,7 +99,7 @@ describe('Deprecation (integration)', function() { }); it('omits the suite or spec context when ignoreRunnable is true', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); + const reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); env.addReporter(reporter); spyOn(console, 'error'); @@ -128,7 +128,7 @@ describe('Deprecation (integration)', function() { }); it('includes the stack trace', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['specDone']); + const reporter = jasmine.createSpyObj('reporter', ['specDone']); env.addReporter(reporter); spyOn(console, 'error'); @@ -157,7 +157,7 @@ describe('Deprecation (integration)', function() { }); it('excludes the stack trace when omitStackTrace is true', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['specDone']); + const reporter = jasmine.createSpyObj('reporter', ['specDone']); env.addReporter(reporter); spyOn(console, 'error'); @@ -186,7 +186,10 @@ describe('Deprecation (integration)', function() { }); it('emits a given deprecation only once', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['specDone', 'suiteDone']); + const reporter = jasmine.createSpyObj('reporter', [ + 'specDone', + 'suiteDone' + ]); env.addReporter(reporter); spyOn(console, 'error'); @@ -239,7 +242,10 @@ describe('Deprecation (integration)', function() { }); it('emits a given deprecation each time when config.verboseDeprecations is true', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['specDone', 'suiteDone']); + const reporter = jasmine.createSpyObj('reporter', [ + 'specDone', + 'suiteDone' + ]); env.addReporter(reporter); spyOn(console, 'error'); @@ -296,7 +302,7 @@ describe('Deprecation (integration)', function() { }); it('handles deprecations that occur before execute() is called', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); + const reporter = jasmine.createSpyObj('reporter', ['jasmineDone']); env.addReporter(reporter); spyOn(console, 'error'); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index fe169fb5..e7b3477f 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1,5 +1,5 @@ describe('Env integration', function() { - var env; + let env; beforeEach(function() { jasmine.getEnv().registerIntegrationMatchers(); @@ -11,9 +11,9 @@ describe('Env integration', function() { }); it('Suites execute as expected (no nesting)', function(done) { - var calls = []; + const calls = []; - var assertions = function() { + const assertions = function() { expect(calls).toEqual(['with a spec', 'and another spec']); done(); @@ -34,9 +34,9 @@ describe('Env integration', function() { }); it('Nested Suites execute as expected', function(done) { - var calls = []; + const calls = []; - var assertions = function() { + const assertions = function() { expect(calls).toEqual([ 'an outer spec', 'an inner spec', @@ -66,9 +66,9 @@ describe('Env integration', function() { }); it('Multiple top-level Suites execute as expected', function(done) { - var calls = []; + const calls = []; - var assertions = function() { + const assertions = function() { expect(calls).toEqual([ 'an outer spec', 'an inner spec', @@ -105,7 +105,7 @@ describe('Env integration', function() { }); it('explicitly fails a spec', function(done) { - var specDone = jasmine.createSpy('specDone'); + const specDone = jasmine.createSpy('specDone'); env.addReporter({ specDone: specDone }); @@ -156,8 +156,8 @@ describe('Env integration', function() { message: 'Failed: error message', stack: { asymmetricMatch: function(other) { - var split = other.split('\n'), - firstLine = split[0]; + const split = other.split('\n'); + let firstLine = split[0]; if (firstLine.indexOf('error message') >= 0) { // Chrome inserts the message and a newline before the first stacktrace line. firstLine = split[1]; @@ -202,9 +202,9 @@ describe('Env integration', function() { it("calls associated befores/specs/afters with the same 'this'", function(done) { env.configure({ random: false }); env.describe('tests', function() { - var firstTimeThrough = true, - firstSpecContext, - secondSpecContext; + let firstTimeThrough = true; + let firstSpecContext; + let secondSpecContext; env.beforeEach(function() { if (firstTimeThrough) { @@ -238,7 +238,7 @@ describe('Env integration', function() { it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) { env.describe('with an async spec', function() { - var specContext; + let specContext; env.beforeEach(function() { specContext = this; @@ -259,7 +259,7 @@ describe('Env integration', function() { }); it('calls associated beforeAlls/afterAlls only once per suite', function(done) { - var before = jasmine.createSpy('beforeAll'), + const before = jasmine.createSpy('beforeAll'), after = jasmine.createSpy('afterAll'); env.describe('with beforeAll and afterAll', function() { @@ -286,7 +286,7 @@ describe('Env integration', function() { }); it('calls associated beforeAlls/afterAlls only once per suite for async', function(done) { - var before = jasmine.createSpy('beforeAll'), + const before = jasmine.createSpy('beforeAll'), after = jasmine.createSpy('afterAll'); env.describe('with beforeAll and afterAll', function() { @@ -370,7 +370,7 @@ describe('Env integration', function() { }); it('tags top-level afterAll failures with a type', function(done) { - var jasmineDone = jasmine.createSpy('jasmineDone'); + const jasmineDone = jasmine.createSpy('jasmineDone'); env.it('has a spec', function() {}); @@ -381,7 +381,7 @@ describe('Env integration', function() { env.addReporter({ jasmineDone: jasmineDone }); env.execute(null, function() { { - var result = jasmineDone.calls.argsFor(0)[0]; + const result = jasmineDone.calls.argsFor(0)[0]; expect(result.failedExpectations[0].globalErrorType).toEqual( 'afterAll' ); @@ -391,7 +391,7 @@ describe('Env integration', function() { }); it('does not tag suite afterAll failures with a type', function(done) { - var reporter = { + const reporter = { suiteDone: jasmine.createSpy('suiteDone').and.callFake(function(result) { expect(result.failedExpectations[0].globalErrorType).toBeFalsy(); }) @@ -414,12 +414,12 @@ describe('Env integration', function() { }); it('when the beforeAll fails, error at suite level', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'suiteDone' ]); - var assertions = function() { + const assertions = function() { expect(reporter.specDone.calls.count()).toEqual(2); expect(reporter.specDone).toHaveFailedExpectationsForRunnable( 'A suite spec that will pass', @@ -455,7 +455,7 @@ describe('Env integration', function() { }); it('copes with async failures after done has been called', function(done) { - var global = { + const global = { setTimeout: function(fn, delay) { return setTimeout(fn, delay); }, @@ -466,12 +466,12 @@ describe('Env integration', function() { spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); env.cleanup_(); env = new jasmineUnderTest.Env(); - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'suiteDone' ]); - var assertions = function() { + const assertions = function() { expect(reporter.specDone).not.toHaveFailedExpectationsForRunnable( 'A suite fails', ['fail thrown'] @@ -506,8 +506,8 @@ describe('Env integration', function() { }); it('reports multiple calls to done in the top suite as errors', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); - var message = + const reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); + const message = 'A top-level beforeAll or afterAll function called its ' + "'done' callback more than once."; @@ -540,8 +540,8 @@ describe('Env integration', function() { }); it('reports multiple calls to done in a non-top suite as errors', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); - var message = + const reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); + const message = "An asynchronous beforeAll or afterAll function called its 'done' " + 'callback more than once.\n(in suite: a suite)'; @@ -576,8 +576,8 @@ describe('Env integration', function() { }); it('reports multiple calls to done in a spec as errors', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); - var message = + const reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); + const message = 'An asynchronous spec, beforeEach, or afterEach function called its ' + "'done' callback more than once.\n(in spec: a suite a spec)"; @@ -619,10 +619,10 @@ describe('Env integration', function() { }); it('reports multiple calls to done in reporters as errors', function(done) { - var message = + const message = "An asynchronous reporter callback called its 'done' callback more " + 'than once.'; - var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone']); + const reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone']); reporter.specDone = function(result, done) { done(); done(); @@ -643,8 +643,8 @@ describe('Env integration', function() { }); it('does not report an error for a call to done that comes after a timeout', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']), - firstSpecDone; + const reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']); + let firstSpecDone; reporter.specDone = function(result, reporterDone) { setTimeout(function() { @@ -674,9 +674,9 @@ describe('Env integration', function() { describe('suiteDone reporting', function() { it('reports when an afterAll fails an expectation', function(done) { - var reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); + const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); - var assertions = function() { + const assertions = function() { expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable( 'my suite', ['Expected 1 to equal 2.', 'Expected 2 to equal 3.'] @@ -699,9 +699,9 @@ describe('Env integration', function() { }); it('if there are no specs, it still reports correctly', function(done) { - var reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); + const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); - var assertions = function() { + const assertions = function() { expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable( 'outer suite', ['Expected 1 to equal 2.', 'Expected 2 to equal 3.'] @@ -726,10 +726,10 @@ describe('Env integration', function() { }); it('reports when afterAll throws an exception', function(done) { - var error = new Error('After All Exception'), + const error = new Error('After All Exception'), reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); - var assertions = function() { + const assertions = function() { expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable( 'my suite', [/^Error: After All Exception/] @@ -751,9 +751,9 @@ describe('Env integration', function() { }); it('reports when an async afterAll fails an expectation', function(done) { - var reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); + const reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); - var assertions = function() { + const assertions = function() { expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable( 'my suite', ['Expected 1 to equal 2.'] @@ -776,10 +776,10 @@ describe('Env integration', function() { }); it('reports when an async afterAll throws an exception', function(done) { - var error = new Error('After All Exception'), + const error = new Error('After All Exception'), reporter = jasmine.createSpyObj('fakeReport', ['suiteDone']); - var assertions = function() { + const assertions = function() { expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable( 'my suite', [/^Error: After All Exception/] @@ -802,7 +802,7 @@ describe('Env integration', function() { }); it('reports the duration of the suite', function(done) { - var duration; + let duration; env.addReporter({ suiteDone: function(result) { @@ -829,7 +829,7 @@ describe('Env integration', function() { describe('specDone reporting', function() { it('reports the duration of the spec', function(done) { - var duration; + let duration; env.addReporter({ specDone: function(result) { @@ -855,7 +855,7 @@ describe('Env integration', function() { }); it('reports expectation failures in global beforeAll', function(done) { - var reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']); + const reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']); env.beforeAll(function() { env.expect(1).toBe(0); @@ -868,7 +868,7 @@ describe('Env integration', function() { env.addReporter(reporter); env.execute(null, function() { - var results = reporter.jasmineDone.calls.argsFor(0)[0]; + const results = reporter.jasmineDone.calls.argsFor(0)[0]; expect(results.failedExpectations).toEqual([ jasmine.objectContaining({ message: 'Expected 1 to be 0.' }) ]); @@ -881,7 +881,7 @@ describe('Env integration', function() { }); it('reports expectation failures in global afterAll', function(done) { - var reporter = jasmine.createSpyObj(['jasmineDone']); + const reporter = jasmine.createSpyObj(['jasmineDone']); env.afterAll(function() { env.expect(1).toBe(0); @@ -894,7 +894,7 @@ describe('Env integration', function() { env.addReporter(reporter); env.execute(null, function() { - var results = reporter.jasmineDone.calls.argsFor(0)[0]; + const results = reporter.jasmineDone.calls.argsFor(0)[0]; expect(results.failedExpectations).toEqual([ jasmine.objectContaining({ message: 'Expected 1 to be 0.' }) ]); @@ -903,10 +903,10 @@ describe('Env integration', function() { }); it('Allows specifying which specs and suites to run', function(done) { - var calls = [], - suiteCallback = jasmine.createSpy('suite callback'), - firstSpec, - secondSuite; + const calls = [], + suiteCallback = jasmine.createSpy('suite callback'); + let firstSpec; + let secondSuite; env.addReporter({ suiteDone: suiteCallback }); @@ -933,9 +933,9 @@ describe('Env integration', function() { }); it('runs before and after all functions for runnables provided to .execute()', function(done) { - var calls = [], - first_spec, - second_spec; + const calls = []; + let first_spec; + let second_spec; env.describe('first suite', function() { env.beforeAll(function() { @@ -959,7 +959,7 @@ describe('Env integration', function() { }); it('Allows filtering out specs and suites to run programmatically', function(done) { - var calls = [], + const calls = [], suiteCallback = jasmine.createSpy('suite callback'); env.addReporter({ suiteDone: suiteCallback }); @@ -996,8 +996,8 @@ describe('Env integration', function() { }); it('Functions can be spied on and have their calls tracked', function(done) { - var originalFunctionWasCalled = false; - var subject = { + let originalFunctionWasCalled = false; + const subject = { spiedFunc: function() { originalFunctionWasCalled = true; return 'original result'; @@ -1005,7 +1005,7 @@ describe('Env integration', function() { }; env.it('works with spies', function() { - var spy = env + const spy = env .spyOn(subject, 'spiedFunc') .and.returnValue('stubbed result'); @@ -1042,17 +1042,17 @@ describe('Env integration', function() { throw new Error('You must use the new keyword.'); this.foo = foo; } - var subject = { MyClass: MyClass }; - var spy = env.spyOn(subject, 'MyClass').and.callThrough(); + const subject = { MyClass: MyClass }; + const spy = env.spyOn(subject, 'MyClass').and.callThrough(); expect(function() { - var result = new spy('hello world'); + const result = new spy('hello world'); expect(result instanceof MyClass).toBeTruthy(); expect(result.foo).toEqual('hello world'); }).not.toThrow(); expect(function() { - var result = new spy( + const result = new spy( 'passing', 'extra', 'arguments', @@ -1073,7 +1073,7 @@ describe('Env integration', function() { }); it('can be configured to allow respying on functions', function(done) { - var foo = { + const foo = { bar: function() { return 1; } @@ -1095,7 +1095,7 @@ describe('Env integration', function() { }); it('removes all spies added in a spec after the spec is complete', function(done) { - var originalFoo = function() {}, + const originalFoo = function() {}, testObj = { foo: originalFoo }, @@ -1118,7 +1118,7 @@ describe('Env integration', function() { }); it('removes all spies added in a suite after the suite is complete', function(done) { - var originalFoo = function() {}, + const originalFoo = function() {}, testObj = { foo: originalFoo }; @@ -1147,7 +1147,7 @@ describe('Env integration', function() { }); it('removes a spy from the top suite after the run is complete', function(done) { - var originalFoo = function() {}, + const originalFoo = function() {}, testObj = { foo: originalFoo }; @@ -1167,7 +1167,7 @@ describe('Env integration', function() { }); it('Mock clock can be installed and used in tests', function(done) { - var globalSetTimeout = jasmine + const globalSetTimeout = jasmine .createSpy('globalSetTimeout') .and.callFake(function(cb, t) { return setTimeout(cb, t); @@ -1218,7 +1218,7 @@ describe('Env integration', function() { }); it('should run async specs in order, waiting for them to complete', function(done) { - var mutatedVar; + let mutatedVar; env.describe('tests', function() { env.beforeEach(function() { @@ -1241,7 +1241,7 @@ describe('Env integration', function() { }); describe('with a mock clock', function() { - var realSetTimeout; + let realSetTimeout; function createMockedEnv() { env.cleanup_(); // explicitly pass in timing functions so we can make sure that clear stack always works @@ -1249,7 +1249,7 @@ describe('Env integration', function() { env = new jasmineUnderTest.Env({ global: { setTimeout: function(cb, t) { - var stack = jasmine.util.errorWithStack().stack; + const stack = jasmine.util.errorWithStack().stack; if (stack.indexOf('ClearStack') >= 0) { return realSetTimeout(cb, t); } else { @@ -1281,7 +1281,7 @@ describe('Env integration', function() { it("should wait a default interval before failing specs that haven't called done yet", function(done) { createMockedEnv(); - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); reporter.specDone.and.callFake(function(result) { expect(result).toEqual(jasmine.objectContaining({ status: 'failed' })); @@ -1309,7 +1309,7 @@ describe('Env integration', function() { it('should not use the mock clock for asynchronous timeouts', function(done) { createMockedEnv(); - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']), + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']), clock = env.clock; reporter.specDone.and.callFake(function() { @@ -1352,7 +1352,7 @@ describe('Env integration', function() { it('should wait a custom interval before reporting async functions that fail to complete', function(done) { createMockedEnv(); - var reporter = jasmine.createSpyObj('fakeReport', [ + const reporter = jasmine.createSpyObj('fakeReport', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -1448,7 +1448,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var r = reporter.jasmineDone.calls.argsFor(0)[0]; + const r = reporter.jasmineDone.calls.argsFor(0)[0]; expect(r.failedExpectations).toEqual([]); expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable( 'suite beforeAll', @@ -1488,7 +1488,7 @@ describe('Env integration', function() { }); it('explicitly fails an async spec', function(done) { - var specDone = jasmine.createSpy('specDone'); + const specDone = jasmine.createSpy('specDone'); env.addReporter({ specDone: specDone }); @@ -1555,7 +1555,7 @@ describe('Env integration', function() { describe('focused tests', function() { it('should only run the focused tests', function(done) { - var calls = []; + const calls = []; env.describe('a suite', function() { env.fit('is focused', function() { @@ -1574,7 +1574,7 @@ describe('Env integration', function() { }); it('should only run focused suites', function(done) { - var calls = []; + const calls = []; env.fdescribe('a focused suite', function() { env.it('is focused', function() { @@ -1595,7 +1595,7 @@ describe('Env integration', function() { }); it('should run focused tests inside an xdescribe', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'jasmineStarted', 'suiteStarted', 'suiteDone', @@ -1629,7 +1629,7 @@ describe('Env integration', function() { }); it('should run focused suites inside an xdescribe', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'jasmineStarted', 'suiteStarted', 'suiteDone', @@ -1666,7 +1666,7 @@ describe('Env integration', function() { }); it('should report as expected', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'jasmineStarted', 'suiteStarted', 'suiteDone', @@ -1733,10 +1733,10 @@ describe('Env integration', function() { }) ); - var suiteDone = reporter.suiteDone.calls.argsFor(0)[0]; + const suiteDone = reporter.suiteDone.calls.argsFor(0)[0]; expect(typeof suiteDone.duration).toBe('number'); - var suiteResult = reporter.suiteStarted.calls.argsFor(0)[0]; + const suiteResult = reporter.suiteStarted.calls.argsFor(0)[0]; expect(suiteResult.description).toEqual('A Suite'); done(); @@ -1744,7 +1744,7 @@ describe('Env integration', function() { }); it('should report the random seed at the beginning and end of execution', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'jasmineStarted', 'jasmineDone', 'suiteStarted', @@ -1758,11 +1758,11 @@ describe('Env integration', function() { env.configure({ random: true }); env.execute(null, function() { expect(reporter.jasmineStarted).toHaveBeenCalled(); - var startedArg = reporter.jasmineStarted.calls.argsFor(0)[0]; + const startedArg = reporter.jasmineStarted.calls.argsFor(0)[0]; expect(startedArg.order.random).toEqual(true); expect(startedArg.order.seed).toEqual('123456'); - var doneArg = reporter.jasmineDone.calls.argsFor(0)[0]; + const doneArg = reporter.jasmineDone.calls.argsFor(0)[0]; expect(doneArg.order.random).toEqual(true); expect(doneArg.order.seed).toEqual('123456'); done(); @@ -1770,7 +1770,7 @@ describe('Env integration', function() { }); it('should report pending spec messages', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); env.addReporter(reporter); @@ -1779,7 +1779,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var specStatus = reporter.specDone.calls.argsFor(0)[0]; + const specStatus = reporter.specDone.calls.argsFor(0)[0]; expect(specStatus.status).toBe('pending'); expect(specStatus.pendingReason).toBe('with a message'); @@ -1801,7 +1801,7 @@ describe('Env integration', function() { reject(this.exception); }; - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); env.addReporter(reporter); @@ -1812,7 +1812,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var specStatus = reporter.specDone.calls.argsFor(0)[0]; + const specStatus = reporter.specDone.calls.argsFor(0)[0]; expect(specStatus.status).toBe('pending'); expect(specStatus.pendingReason).toBe('with a message'); @@ -1822,7 +1822,7 @@ describe('Env integration', function() { }); it('should report using fallback reporter', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'specDone', 'jasmineDone' ]); @@ -1843,7 +1843,7 @@ describe('Env integration', function() { }); it('should report xdescribes as expected', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', [ + const reporter = jasmine.createSpyObj('fakeReporter', [ 'jasmineStarted', 'suiteStarted', 'suiteDone', @@ -1884,7 +1884,7 @@ describe('Env integration', function() { }); it('should be possible to get full name from a spec', function() { - var topLevelSpec, nestedSpec, doublyNestedSpec; + let topLevelSpec, nestedSpec, doublyNestedSpec; env.describe('my tests', function() { topLevelSpec = env.it('are sometimes top level', function() {}); @@ -1906,7 +1906,7 @@ describe('Env integration', function() { }); it('Custom equality testers should be per spec', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); env.addReporter(reporter); env.configure({ random: false }); @@ -1925,7 +1925,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var firstSpecResult = reporter.specDone.calls.first().args[0], + const firstSpecResult = reporter.specDone.calls.first().args[0], secondSpecResult = reporter.specDone.calls.mostRecent().args[0]; expect(firstSpecResult.status).toEqual('passed'); @@ -1936,7 +1936,7 @@ describe('Env integration', function() { }); it('Custom equality testers should be per suite', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); env.addReporter(reporter); env.configure({ random: false }); @@ -1964,7 +1964,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var firstSpecResult = reporter.specDone.calls.first().args[0], + const firstSpecResult = reporter.specDone.calls.first().args[0], secondSpecResult = reporter.specDone.calls.argsFor(0)[0], thirdSpecResult = reporter.specDone.calls.mostRecent().args[0]; @@ -1977,7 +1977,7 @@ describe('Env integration', function() { }); it('Custom equality testers for toContain should be per spec', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); env.addReporter(reporter); env.configure({ random: false }); @@ -1996,7 +1996,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var firstSpecResult = reporter.specDone.calls.first().args[0], + const firstSpecResult = reporter.specDone.calls.first().args[0], secondSpecResult = reporter.specDone.calls.mostRecent().args[0]; expect(firstSpecResult.status).toEqual('passed'); @@ -2022,7 +2022,7 @@ describe('Env integration', function() { }); it('Custom equality testers for toContain should be per suite', function(done) { - var reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); + const reporter = jasmine.createSpyObj('fakeReporter', ['specDone']); env.addReporter(reporter); env.configure({ random: false }); @@ -2050,7 +2050,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var firstSpecResult = reporter.specDone.calls.first().args[0], + const firstSpecResult = reporter.specDone.calls.first().args[0], secondSpecResult = reporter.specDone.calls.argsFor(1)[0], thirdSpecResult = reporter.specDone.calls.mostRecent().args[0]; @@ -2063,7 +2063,7 @@ describe('Env integration', function() { }); it('Custom matchers should be per spec', function(done) { - var matchers = { + const matchers = { toFoo: function() {} }; @@ -2082,7 +2082,7 @@ describe('Env integration', function() { }); it('Custom matchers should be per suite', function(done) { - var matchers = { + const matchers = { toFoo: function() {} }; @@ -2110,8 +2110,8 @@ describe('Env integration', function() { }); it('throws an exception if you try to create a spy outside of a runnable', function(done) { - var obj = { fn: function() {} }, - exception; + const obj = { fn: function() {} }; + let exception; env.describe('a suite', function() { try { @@ -2177,7 +2177,7 @@ describe('Env integration', function() { }); it('reports test properties on specs', function(done) { - var env = new jasmineUnderTest.Env(), + const env = new jasmineUnderTest.Env(), reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']); reporter.specDone.and.callFake(function(e) { @@ -2195,8 +2195,8 @@ describe('Env integration', function() { }); it('throws an exception if you try to setSpecProperty outside of a spec', function(done) { - var env = new jasmineUnderTest.Env(), - exception; + const env = new jasmineUnderTest.Env(); + let exception; env.describe('a suite', function() { env.it('a spec'); @@ -2217,7 +2217,7 @@ describe('Env integration', function() { }); it('reports test properties on suites', function(done) { - var env = new jasmineUnderTest.Env(), + const env = new jasmineUnderTest.Env(), reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', @@ -2245,7 +2245,7 @@ describe('Env integration', function() { }); it('throws an exception if you try to setSuiteProperty outside of a suite', function(done) { - var env = new jasmineUnderTest.Env(); + const env = new jasmineUnderTest.Env(); try { env.setSuiteProperty('a', 'Bee'); @@ -2258,7 +2258,7 @@ describe('Env integration', function() { }); it('should associate errors thrown from async code with the correct runnable', function(done) { - var reporter = jasmine.createSpyObj('fakeReport', [ + const reporter = jasmine.createSpyObj('fakeReport', [ 'suiteDone', 'specDone' ]); @@ -2305,7 +2305,10 @@ describe('Env integration', function() { }); it("should throw on suites/specs/befores/afters nested in methods other than 'describe'", function(done) { - var reporter = jasmine.createSpyObj('reporter', ['suiteDone', 'specDone']); + const reporter = jasmine.createSpyObj('reporter', [ + 'suiteDone', + 'specDone' + ]); env.addReporter(reporter); @@ -2362,7 +2365,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var msg = /\'.*\' should only be used in \'describe\' function/; + const msg = /\'.*\' should only be used in \'describe\' function/; expect(reporter.specDone).toHaveFailedExpectationsForRunnable( 'suite describe', @@ -2412,7 +2415,7 @@ describe('Env integration', function() { }); it('reports errors that occur during loading', function(done) { - var global = { + const global = { setTimeout: function(fn, delay) { return setTimeout(fn, delay); }, @@ -2425,7 +2428,7 @@ describe('Env integration', function() { env.cleanup_(); env = new jasmineUnderTest.Env(); - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2442,7 +2445,7 @@ describe('Env integration', function() { global.onerror('Uncaught Error: ENOCHEESE'); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.failedExpectations).toEqual([ { passed: false, @@ -2468,8 +2471,8 @@ describe('Env integration', function() { describe('If suppressLoadErrors: true was passed', function() { it('does not install a global error handler during loading', function(done) { - var originalOnerror = jasmine.createSpy('original onerror'); - var global = { + const originalOnerror = jasmine.createSpy('original onerror'); + const global = { setTimeout: function(fn, delay) { return setTimeout(fn, delay); }, @@ -2479,14 +2482,14 @@ describe('Env integration', function() { onerror: originalOnerror }; spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global); - var globalErrors = new jasmineUnderTest.GlobalErrors(global); - var onerror = jasmine.createSpy('onerror'); + const globalErrors = new jasmineUnderTest.GlobalErrors(global); + const onerror = jasmine.createSpy('onerror'); globalErrors.pushListener(onerror); spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors); env.cleanup_(); env = new jasmineUnderTest.Env({ suppressLoadErrors: true }); - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2496,7 +2499,7 @@ describe('Env integration', function() { global.onerror('Uncaught Error: ENOCHEESE'); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.failedExpectations).toEqual([]); expect(originalOnerror).toHaveBeenCalledWith( 'Uncaught Error: ENOCHEESE' @@ -2509,7 +2512,7 @@ describe('Env integration', function() { describe('Overall status in the jasmineDone event', function() { describe('When everything passes', function() { it('is "passed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2518,7 +2521,7 @@ describe('Env integration', function() { env.addReporter(reporter); env.it('passes', function() {}); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('passed'); done(); }); @@ -2527,7 +2530,7 @@ describe('Env integration', function() { describe('When a spec fails', function() { it('is "failed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2538,7 +2541,7 @@ describe('Env integration', function() { env.expect(true).toBe(false); }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); done(); }); @@ -2546,7 +2549,7 @@ describe('Env integration', function() { }); describe('when spec has no expectations', function() { - var reporter; + let reporter; beforeEach(function() { reporter = jasmine.createSpyObj('reporter', [ @@ -2564,7 +2567,7 @@ describe('Env integration', function() { it('should report "failed" status if "failSpecWithNoExpectations" is enabled', function(done) { env.configure({ failSpecWithNoExpectations: true }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); done(); }); @@ -2573,7 +2576,7 @@ describe('Env integration', function() { it('should report "passed" status if "failSpecWithNoExpectations" is disabled', function(done) { env.configure({ failSpecWithNoExpectations: false }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('passed'); done(); }); @@ -2582,7 +2585,7 @@ describe('Env integration', function() { describe('When a top-level beforeAll fails', function() { it('is "failed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2594,7 +2597,7 @@ describe('Env integration', function() { }); env.it('does not run', function() {}); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); done(); }); @@ -2603,7 +2606,7 @@ describe('Env integration', function() { describe('When a suite beforeAll fails', function() { it('is "failed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2617,7 +2620,7 @@ describe('Env integration', function() { env.it('does not run', function() {}); }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); done(); }); @@ -2626,7 +2629,7 @@ describe('Env integration', function() { describe('When a top-level afterAll fails', function() { it('is "failed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2638,7 +2641,7 @@ describe('Env integration', function() { }); env.it('does not run', function() {}); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); done(); }); @@ -2647,7 +2650,7 @@ describe('Env integration', function() { describe('When a suite afterAll fails', function() { it('is "failed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2661,7 +2664,7 @@ describe('Env integration', function() { env.it('does not run', function() {}); }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); done(); }); @@ -2670,7 +2673,7 @@ describe('Env integration', function() { describe('When there are load errors', function() { it('is "failed"', function(done) { - var global = { + const global = { setTimeout: function(fn, delay) { return setTimeout(fn, delay); }, @@ -2682,7 +2685,7 @@ describe('Env integration', function() { env.cleanup_(); env = new jasmineUnderTest.Env(); - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2704,7 +2707,7 @@ describe('Env integration', function() { describe('When there are no specs', function() { it('is "incomplete"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2712,7 +2715,7 @@ describe('Env integration', function() { env.addReporter(reporter); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('incomplete'); expect(e.incompleteReason).toEqual('No specs found'); done(); @@ -2722,7 +2725,7 @@ describe('Env integration', function() { describe('When a spec is focused', function() { it('is "incomplete"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2730,8 +2733,8 @@ describe('Env integration', function() { env.addReporter(reporter); env.fit('is focused', function() {}); - env.execute(null, function(e) { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + env.execute(null, function() { + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('incomplete'); expect(e.incompleteReason).toEqual('fit() or fdescribe() was found'); done(); @@ -2741,7 +2744,7 @@ describe('Env integration', function() { describe('When a suite is focused', function() { it('is "incomplete"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2752,7 +2755,7 @@ describe('Env integration', function() { env.it('does a thing', function() {}); }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('incomplete'); expect(e.incompleteReason).toEqual('fit() or fdescribe() was found'); done(); @@ -2762,7 +2765,7 @@ describe('Env integration', function() { describe('When there are both failures and focused specs', function() { it('is "failed"', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' @@ -2773,7 +2776,7 @@ describe('Env integration', function() { env.expect(true).toBe(false); }); env.execute(null, function() { - var e = reporter.jasmineDone.calls.argsFor(0)[0]; + const e = reporter.jasmineDone.calls.argsFor(0)[0]; expect(e.overallStatus).toEqual('failed'); expect(e.incompleteReason).toBeUndefined(); done(); @@ -2783,31 +2786,15 @@ describe('Env integration', function() { }); it('should report deprecation stack with an error object', function(done) { - var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + const exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), reporter = jasmine.createSpyObj('reporter', [ 'jasmineDone', 'suiteDone', 'specDone' ]), - topLevelError, - suiteLevelError, - specLevelError; - - try { - throw new Error('top level deprecation'); - } catch (err) { - topLevelError = err; - } - try { - throw new Error('suite level deprecation'); - } catch (err) { - suiteLevelError = err; - } - try { - throw new Error('spec level deprecation'); - } catch (err) { - specLevelError = err; - } + topLevelError = new Error('top level deprecation'), + suiteLevelError = new Error('suite level deprecation'), + specLevelError = new Error('spec level deprecation'); // prevent deprecation from being displayed spyOn(console, 'error'); @@ -2827,7 +2814,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var result = reporter.jasmineDone.calls.argsFor(0)[0]; + const result = reporter.jasmineDone.calls.argsFor(0)[0]; expect(result.deprecationWarnings).toEqual([ jasmine.objectContaining({ message: topLevelError.message, @@ -2868,7 +2855,7 @@ describe('Env integration', function() { }); it('supports async matchers', function(done) { - var specDone = jasmine.createSpy('specDone'), + const specDone = jasmine.createSpy('specDone'), suiteDone = jasmine.createSpy('suiteDone'), jasmineDone = jasmine.createSpy('jasmineDone'); @@ -2879,8 +2866,8 @@ describe('Env integration', function() { }); function fail(innerDone) { - var resolve; - var p = new Promise(function(res) { + let resolve; + const p = new Promise(function(res) { resolve = res; }); env @@ -2897,7 +2884,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var result = jasmineDone.calls.argsFor(0)[0]; + const result = jasmineDone.calls.argsFor(0)[0]; expect(result.failedExpectations).toEqual([ jasmine.objectContaining({ message: 'Expected [object Promise] to be rejected.' @@ -2931,7 +2918,7 @@ describe('Env integration', function() { }); it('provides custom equality testers to async matchers', function(done) { - var specDone = jasmine.createSpy('specDone'); + const specDone = jasmine.createSpy('specDone'); env.addReporter({ specDone: specDone }); @@ -2939,7 +2926,7 @@ describe('Env integration', function() { env.addCustomEqualityTester(function() { return true; }); - var p = Promise.resolve('something'); + const p = Promise.resolve('something'); return env.expectAsync(p).toBeResolvedTo('something else'); }); @@ -2955,7 +2942,7 @@ describe('Env integration', function() { }); it('includes useful stack frames in async matcher failures', function(done) { - var specDone = jasmine.createSpy('specDone'); + const specDone = jasmine.createSpy('specDone'); env.addReporter({ specDone: specDone }); @@ -2963,7 +2950,7 @@ describe('Env integration', function() { env.addCustomEqualityTester(function() { return true; }); - var p = Promise.resolve(); + const p = Promise.resolve(); return env.expectAsync(p).toBeRejected(); }); @@ -2982,11 +2969,11 @@ describe('Env integration', function() { }); it('reports an error when an async expectation occurs after the spec finishes', function(done) { - var resolve, - jasmineDone = jasmine.createSpy('jasmineDone'), - promise = new Promise(function(res) { - resolve = res; - }); + const jasmineDone = jasmine.createSpy('jasmineDone'); + let resolve; + const promise = new Promise(function(res) { + resolve = res; + }); env.configure({ random: false }); @@ -3013,7 +3000,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var result = jasmineDone.calls.argsFor(0)[0]; + const result = jasmineDone.calls.argsFor(0)[0]; expect(result.failedExpectations).toEqual([ jasmine.objectContaining({ passed: false, @@ -3046,11 +3033,11 @@ describe('Env integration', function() { }); it('reports an error when an async expectation occurs after the suite finishes', function(done) { - var resolve, - jasmineDone = jasmine.createSpy('jasmineDone'), - promise = new Promise(function(res) { - resolve = res; - }); + const jasmineDone = jasmine.createSpy('jasmineDone'); + let resolve; + const promise = new Promise(function(res) { + resolve = res; + }); env.configure({ random: false }); @@ -3078,7 +3065,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var result = jasmineDone.calls.argsFor(0)[0]; + const result = jasmineDone.calls.argsFor(0)[0]; expect(result.failedExpectations).toEqual([ jasmine.objectContaining({ passed: false, @@ -3098,15 +3085,15 @@ describe('Env integration', function() { }); it('supports asymmetric equality testers that take a matchersUtil', function(done) { - var env = new jasmineUnderTest.Env(); + const env = new jasmineUnderTest.Env(); env.it('spec using custom asymmetric equality tester', function() { - var customEqualityFn = function(a, b) { + const customEqualityFn = function(a, b) { if (a === 2 && b === 'two') { return true; } }; - var arrayWithFirstElement = function(sample) { + const arrayWithFirstElement = function(sample) { return { asymmetricMatch: function(actual, matchersUtil) { return matchersUtil.equals(sample, actual[0]); @@ -3118,7 +3105,7 @@ describe('Env integration', function() { env.expect(['two']).toEqual(arrayWithFirstElement(2)); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); }; @@ -3136,7 +3123,7 @@ describe('Env integration', function() { }); it('is resolved after reporter events are dispatched', function() { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'specDone', 'suiteDone', 'jasmineDone' @@ -3155,7 +3142,7 @@ describe('Env integration', function() { }); it('is resolved after the stack is cleared', function(done) { - var realClearStack = jasmineUnderTest.getClearStack( + const realClearStack = jasmineUnderTest.getClearStack( jasmineUnderTest.getGlobal() ), clearStackSpy = jasmine @@ -3182,11 +3169,11 @@ describe('Env integration', function() { }); it('is resolved after QueueRunner timeouts are cleared', function() { - var setTimeoutSpy = spyOn( + const setTimeoutSpy = spyOn( jasmineUnderTest.getGlobal(), 'setTimeout' ).and.callThrough(); - var clearTimeoutSpy = spyOn( + const clearTimeoutSpy = spyOn( jasmineUnderTest.getGlobal(), 'clearTimeout' ).and.callThrough(); @@ -3200,7 +3187,7 @@ describe('Env integration', function() { }); return env.execute(null).then(function() { - var timeoutIds = setTimeoutSpy.calls + const timeoutIds = setTimeoutSpy.calls .all() .filter(function(call) { return call.args[1] === 123456; @@ -3245,7 +3232,7 @@ describe('Env integration', function() { }); it('is called after reporter events are dispatched', function(done) { - var reporter = jasmine.createSpyObj('reporter', [ + const reporter = jasmine.createSpyObj('reporter', [ 'specDone', 'suiteDone', 'jasmineDone' @@ -3265,7 +3252,7 @@ describe('Env integration', function() { }); it('is called after the stack is cleared', function(done) { - var realClearStack = jasmineUnderTest.getClearStack( + const realClearStack = jasmineUnderTest.getClearStack( jasmineUnderTest.getGlobal() ), clearStackSpy = jasmine @@ -3292,11 +3279,11 @@ describe('Env integration', function() { }); it('is called after QueueRunner timeouts are cleared', function(done) { - var setTimeoutSpy = spyOn( + const setTimeoutSpy = spyOn( jasmineUnderTest.getGlobal(), 'setTimeout' ).and.callThrough(); - var clearTimeoutSpy = spyOn( + const clearTimeoutSpy = spyOn( jasmineUnderTest.getGlobal(), 'clearTimeout' ).and.callThrough(); @@ -3310,7 +3297,7 @@ describe('Env integration', function() { }); env.execute(null, function() { - var timeoutIds = setTimeoutSpy.calls + const timeoutIds = setTimeoutSpy.calls .all() .filter(function(call) { return call.args[1] === 123456; @@ -3358,10 +3345,8 @@ describe('Env integration', function() { }; } - var duration; - expect(reporter.specDone).toHaveBeenCalledTimes(2); - duration = reporter.specDone.calls.argsFor(0)[0].duration; + const duration = reporter.specDone.calls.argsFor(0)[0].duration; expect(reporter.specDone.calls.argsFor(0)[0]).toEqual( jasmine.objectContaining({ debugLogs: [ @@ -3382,7 +3367,7 @@ describe('Env integration', function() { }); it('reports an error when debugLog is used when a spec is not running', function(done) { - var reporter = jasmine.createSpyObj('reporter', ['suiteDone']); + const reporter = jasmine.createSpyObj('reporter', ['suiteDone']); env.describe('a suite', function() { env.beforeAll(function() { diff --git a/spec/core/integration/MatchersSpec.js b/spec/core/integration/MatchersSpec.js index ce5e370e..0ab3379d 100755 --- a/spec/core/integration/MatchersSpec.js +++ b/spec/core/integration/MatchersSpec.js @@ -1,5 +1,5 @@ describe('Matchers (Integration)', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -15,7 +15,7 @@ describe('Matchers (Integration)', function() { expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); expect(result.passedExpectations.length) .withContext('Number of passed expectations') @@ -41,7 +41,7 @@ describe('Matchers (Integration)', function() { expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -73,7 +73,7 @@ describe('Matchers (Integration)', function() { config.expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -94,7 +94,7 @@ describe('Matchers (Integration)', function() { return expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('passed'); expect(result.passedExpectations.length) .withContext('Number of passed expectations') @@ -120,7 +120,7 @@ describe('Matchers (Integration)', function() { return expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -142,13 +142,13 @@ describe('Matchers (Integration)', function() { function verifyFailsWithCustomObjectFormattersAsync(config) { it('uses custom object formatters', function(done) { - var env = new jasmineUnderTest.Env(); + const env = new jasmineUnderTest.Env(); env.it('a spec', function() { env.addCustomObjectFormatter(config.formatter); return config.expectations(env); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -519,20 +519,20 @@ describe('Matchers (Integration)', function() { describe('toHaveBeenCalled', function() { verifyPasses(function(env) { - var spy = env.createSpy('spy'); + const spy = env.createSpy('spy'); spy(); env.expect(spy).toHaveBeenCalled(); }); verifyFails(function(env) { - var spy = env.createSpy('spy'); + const spy = env.createSpy('spy'); env.expect(spy).toHaveBeenCalled(); }); }); describe('toHaveBeenCalledBefore', function() { verifyPasses(function(env) { - var a = env.createSpy('a'), + const a = env.createSpy('a'), b = env.createSpy('b'); a(); b(); @@ -540,7 +540,7 @@ describe('Matchers (Integration)', function() { }); verifyFails(function(env) { - var a = env.createSpy('a'), + const a = env.createSpy('a'), b = env.createSpy('b'); b(); a(); @@ -550,20 +550,20 @@ describe('Matchers (Integration)', function() { describe('toHaveBeenCalledTimes', function() { verifyPasses(function(env) { - var spy = env.createSpy('spy'); + const spy = env.createSpy('spy'); spy(); env.expect(spy).toHaveBeenCalledTimes(1); }); verifyFails(function(env) { - var spy = env.createSpy('spy'); + const spy = env.createSpy('spy'); env.expect(spy).toHaveBeenCalledTimes(1); }); }); describe('toHaveBeenCalledWith', function() { verifyPasses(function(env) { - var spy = env.createSpy(); + const spy = env.createSpy(); spy('5'); env.addCustomEqualityTester(function(a, b) { return a.toString() === b.toString(); @@ -572,7 +572,7 @@ describe('Matchers (Integration)', function() { }); verifyFails(function(env) { - var spy = env.createSpy(); + const spy = env.createSpy(); env.expect(spy).toHaveBeenCalledWith('foo'); }); @@ -581,7 +581,7 @@ describe('Matchers (Integration)', function() { return '|' + val + '|'; }, expectations: function(env) { - var spy = env.createSpy('foo'); + const spy = env.createSpy('foo'); env.expect(spy).toHaveBeenCalledWith('x'); }, expectedMessage: @@ -593,7 +593,7 @@ describe('Matchers (Integration)', function() { describe('toHaveBeenCalledOnceWith', function() { verifyPasses(function(env) { - var spy = env.createSpy(); + const spy = env.createSpy(); spy('5', 3); env.addCustomEqualityTester(function(a, b) { return a.toString() === b.toString(); @@ -602,7 +602,7 @@ describe('Matchers (Integration)', function() { }); verifyFails(function(env) { - var spy = env.createSpy(); + const spy = env.createSpy(); env.expect(spy).toHaveBeenCalledOnceWith(5, 3); }); }); @@ -613,14 +613,14 @@ describe('Matchers (Integration)', function() { }); verifyPasses(function(env) { - var domHelpers = jasmine.getEnv().domHelpers(); - var el = domHelpers.createElementWithClassName('foo'); + const domHelpers = jasmine.getEnv().domHelpers(); + const el = domHelpers.createElementWithClassName('foo'); env.expect(el).toHaveClass('foo'); }); verifyFails(function(env) { - var domHelpers = jasmine.getEnv().domHelpers(); - var el = domHelpers.createElementWithClassName('foo'); + const domHelpers = jasmine.getEnv().domHelpers(); + const el = domHelpers.createElementWithClassName('foo'); env.expect(el).toHaveClass('bar'); }); }); @@ -758,7 +758,7 @@ describe('Matchers (Integration)', function() { return env.expectAsync(Promise.resolve()).already.toBeRejected(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -782,7 +782,7 @@ describe('Matchers (Integration)', function() { .already.toBeResolved(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') @@ -801,13 +801,13 @@ describe('Matchers (Integration)', function() { }); it('fails when the promise is pending', function(done) { - var promise = new Promise(function() {}); + const promise = new Promise(function() {}); env.it('a spec', function() { return env.expectAsync(promise).already.toBeResolved(); }); - var specExpectations = function(result) { + const specExpectations = function(result) { expect(result.status).toEqual('failed'); expect(result.failedExpectations.length) .withContext('Number of failed expectations') diff --git a/spec/core/integration/SpecRunningSpec.js b/spec/core/integration/SpecRunningSpec.js index 77c4762b..c9adc35d 100644 --- a/spec/core/integration/SpecRunningSpec.js +++ b/spec/core/integration/SpecRunningSpec.js @@ -1,5 +1,5 @@ describe('spec running', function() { - var env; + let env; beforeEach(function() { jasmine.getEnv().registerIntegrationMatchers(); @@ -12,7 +12,7 @@ describe('spec running', function() { }); it('should assign spec ids sequentially', function() { - var it0, it1, it2, it3, it4; + let it0, it1, it2, it3, it4; env.describe('test suite', function() { it0 = env.it('spec 0', function() {}); it1 = env.it('spec 1', function() {}); @@ -31,10 +31,10 @@ describe('spec running', function() { }); it('nested suites', function(done) { - var foo = 0; - var bar = 0; - var baz = 0; - var quux = 0; + let foo = 0; + let bar = 0; + let baz = 0; + let quux = 0; env.describe('suite', function() { env.describe('nested', function() { env.it('should run nested suites', function() { @@ -71,7 +71,7 @@ describe('spec running', function() { }); it('should permit nested describes', function(done) { - var actions = []; + const actions = []; env.beforeEach(function() { actions.push('topSuite beforeEach'); @@ -128,7 +128,7 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = [ + const expected = [ 'topSuite beforeEach', 'outer beforeEach', 'outer it 1', @@ -163,7 +163,7 @@ describe('spec running', function() { }); it('should run multiple befores and afters ordered so functions declared later are treated as more specific', function(done) { - var actions = []; + const actions = []; env.beforeAll(function() { actions.push('runner beforeAll1'); @@ -220,7 +220,7 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = [ + const expected = [ 'runner beforeAll1', 'runner beforeAll2', 'runner beforeEach1', @@ -241,7 +241,7 @@ describe('spec running', function() { }); it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) { - var actions = []; + const actions = []; env.beforeAll(function() { actions.push('runner beforeAll'); @@ -282,7 +282,7 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = [ + const expected = [ 'runner beforeAll', 'inner beforeAll', 'runner beforeEach', @@ -299,9 +299,9 @@ describe('spec running', function() { }); it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) { - var actions = [], - spec, - spec2; + const actions = []; + let spec; + let spec2; env.beforeAll(function() { actions.push('runner beforeAll'); @@ -346,7 +346,7 @@ describe('spec running', function() { }); env.execute([spec2.id, spec.id], function() { - var expected = [ + const expected = [ 'runner beforeAll', 'inner beforeAll', 'runner beforeEach', @@ -369,7 +369,7 @@ describe('spec running', function() { }); it('only runs *Alls once in a focused suite', function(done) { - var actions = []; + const actions = []; env.fdescribe('Suite', function() { env.beforeAll(function() { @@ -391,7 +391,7 @@ describe('spec running', function() { describe('focused runnables', function() { it('runs the relevant alls and eachs for each runnable', function(done) { - var actions = []; + const actions = []; env.beforeAll(function() { actions.push('beforeAll'); }); @@ -418,7 +418,7 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = [ + const expected = [ 'beforeAll', 'beforeEach', 'spec in fdescribe', @@ -435,7 +435,7 @@ describe('spec running', function() { }); it('focused specs in focused suites cause non-focused siblings to not run', function(done) { - var actions = []; + const actions = []; env.fdescribe('focused suite', function() { env.it('unfocused spec', function() { @@ -447,14 +447,14 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = ['focused spec']; + const expected = ['focused spec']; expect(actions).toEqual(expected); done(); }); }); it('focused suites in focused suites cause non-focused siblings to not run', function(done) { - var actions = []; + const actions = []; env.fdescribe('focused suite', function() { env.it('unfocused spec', function() { @@ -468,14 +468,14 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = ['inner spec']; + const expected = ['inner spec']; expect(actions).toEqual(expected); done(); }); }); it('focused runnables unfocus ancestor focused suites', function(done) { - var actions = []; + const actions = []; env.fdescribe('focused suite', function() { env.it('unfocused spec', function() { @@ -489,7 +489,7 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = ['focused spec']; + const expected = ['focused spec']; expect(actions).toEqual(expected); done(); }); @@ -511,7 +511,7 @@ describe('spec running', function() { }); it("shouldn't run before/after functions in disabled suites", function(done) { - var shouldNotRun = jasmine.createSpy('shouldNotRun'); + const shouldNotRun = jasmine.createSpy('shouldNotRun'); env.xdescribe('A disabled Suite', function() { // None of the before/after functions should run. env.beforeAll(shouldNotRun); @@ -529,7 +529,7 @@ describe('spec running', function() { }); it('should allow top level suites to be disabled', function(done) { - var specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'), + const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'), otherSpec = jasmine.createSpy('otherSpec'); env.xdescribe('A disabled suite', function() { @@ -565,7 +565,7 @@ describe('spec running', function() { }); it('should recover gracefully when there are errors in describe functions', function(done) { - var specs = [], + const specs = [], reporter = jasmine.createSpyObj(['specDone', 'suiteDone']); reporter.specDone.and.callFake(function(result) { @@ -617,10 +617,10 @@ describe('spec running', function() { }); it('re-enters suites that have no *Alls', function(done) { - var actions = [], - spec1, - spec2, - spec3; + const actions = []; + let spec1; + let spec2; + let spec3; env.describe('top', function() { spec1 = env.it('spec1', function() { @@ -643,10 +643,10 @@ describe('spec running', function() { }); it('refuses to re-enter suites with a beforeAll', function() { - var actions = [], - spec1, - spec2, - spec3; + const actions = []; + let spec1; + let spec2; + let spec3; env.describe('top', function() { env.beforeAll(function() {}); @@ -671,10 +671,10 @@ describe('spec running', function() { }); it('refuses to re-enter suites with a afterAll', function() { - var actions = [], - spec1, - spec2, - spec3; + const actions = []; + let spec1; + let spec2; + let spec3; env.describe('top', function() { env.afterAll(function() {}); @@ -699,7 +699,7 @@ describe('spec running', function() { }); it('should run the tests in a consistent order when a seed is supplied', function(done) { - var actions = []; + const actions = []; env.configure({ random: true, seed: '123456' }); env.beforeEach(function() { @@ -757,7 +757,7 @@ describe('spec running', function() { }); env.execute(null, function() { - var expected = [ + const expected = [ 'topSuite beforeEach', 'outer beforeEach', 'outer it 2', @@ -985,7 +985,7 @@ describe('spec running', function() { hasStandardErrorHandlingBehavior(); it('skips to cleanup functions after an expectation failure', async function() { - var actions = []; + const actions = []; env.describe('Something', function() { env.beforeEach(function() { @@ -1026,7 +1026,7 @@ describe('spec running', function() { hasStandardErrorHandlingBehavior(); it('does not skip anything after an expectation failure', async function() { - var actions = []; + const actions = []; env.describe('Something', function() { env.beforeEach(function() { @@ -1365,7 +1365,7 @@ describe('spec running', function() { }); it('should be able to run multiple times', function(done) { - var actions = []; + const actions = []; env.describe('Suite', function() { env.it('spec1', function() { @@ -1388,9 +1388,9 @@ describe('spec running', function() { }); it('should reset results between runs', function(done) { - var specResults = {}; - var suiteResults = {}; - var firstExecution = true; + const specResults = {}; + const suiteResults = {}; + let firstExecution = true; env.addReporter({ specDone: function(spec) { @@ -1482,13 +1482,13 @@ describe('spec running', function() { }); it('should execute before and after hooks per run', function(done) { - var timeline = []; - var timelineFn = function(hookName) { + let timeline = []; + const timelineFn = function(hookName) { return function() { timeline.push(hookName); }; }; - var expectedTimeLine = [ + const expectedTimeLine = [ 'beforeAll', 'beforeEach', 'spec1', @@ -1518,8 +1518,8 @@ describe('spec running', function() { }); it('should be able to filter out different tests in subsequent runs', function(done) { - var specResults = {}; - var focussedSpec = 'spec1'; + const specResults = {}; + let focussedSpec = 'spec1'; env.configure({ specFilter: function(spec) { diff --git a/spec/core/matchers/DiffBuilderSpec.js b/spec/core/matchers/DiffBuilderSpec.js index 840eff68..69753bf5 100644 --- a/spec/core/matchers/DiffBuilderSpec.js +++ b/spec/core/matchers/DiffBuilderSpec.js @@ -1,6 +1,6 @@ describe('DiffBuilder', function() { it('records the actual and expected objects', function() { - var diffBuilder = jasmineUnderTest.DiffBuilder(); + const diffBuilder = jasmineUnderTest.DiffBuilder(); diffBuilder.setRoots({ x: 'actual' }, { x: 'expected' }); diffBuilder.recordMismatch(); @@ -10,7 +10,7 @@ describe('DiffBuilder', function() { }); it('prints the path at which the difference was found', function() { - var diffBuilder = jasmineUnderTest.DiffBuilder(); + const diffBuilder = jasmineUnderTest.DiffBuilder(); diffBuilder.setRoots({ foo: { x: 'actual' } }, { foo: { x: 'expected' } }); diffBuilder.withPath('foo', function() { @@ -23,7 +23,7 @@ describe('DiffBuilder', function() { }); it('prints multiple messages, separated by newlines', function() { - var diffBuilder = jasmineUnderTest.DiffBuilder(); + const diffBuilder = jasmineUnderTest.DiffBuilder(); diffBuilder.setRoots({ foo: 1, bar: 3 }, { foo: 2, bar: 4 }); diffBuilder.withPath('foo', function() { @@ -33,14 +33,14 @@ describe('DiffBuilder', function() { diffBuilder.recordMismatch(); }); - var message = + const message = 'Expected $.foo = 1 to equal 2.\n' + 'Expected $.bar = 3 to equal 4.'; expect(diffBuilder.getMessage()).toEqual(message); }); it('allows customization of the message', function() { - var diffBuilder = jasmineUnderTest.DiffBuilder(); + const diffBuilder = jasmineUnderTest.DiffBuilder(); diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' }); function darthVaderFormatter(actual, expected, path) { @@ -65,7 +65,7 @@ describe('DiffBuilder', function() { }); it('uses the injected pretty-printer', function() { - var prettyPrinter = function(val) { + const prettyPrinter = function(val) { return '|' + val + '|'; }, diffBuilder = jasmineUnderTest.DiffBuilder({ @@ -84,7 +84,7 @@ describe('DiffBuilder', function() { }); it('passes the injected pretty-printer to the diff formatter', function() { - var diffFormatter = jasmine.createSpy('diffFormatter'), + const diffFormatter = jasmine.createSpy('diffFormatter'), prettyPrinter = function() {}, diffBuilder = jasmineUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter @@ -107,13 +107,13 @@ describe('DiffBuilder', function() { }); it('uses custom object formatters on leaf nodes', function() { - var formatter = function(x) { + const formatter = function(x) { if (typeof x === 'number') { return '[number:' + x + ']'; } }; const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - var diffBuilder = new jasmineUnderTest.DiffBuilder({ + const diffBuilder = new jasmineUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); @@ -126,16 +126,16 @@ describe('DiffBuilder', function() { }); it('uses custom object formatters on non leaf nodes', function() { - var formatter = function(x) { + const formatter = function(x) { if (x.hasOwnProperty('a')) { return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']'; } }; const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]); - var diffBuilder = new jasmineUnderTest.DiffBuilder({ + const diffBuilder = new jasmineUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }); - var expectedMsg = + const expectedMsg = 'Expected $[0].foo = [thing with a=1, b={"x":42}] to equal [thing with a=1, b={"x":43}].\n' + "Expected $[0].bar = 'yes' to equal 'no'."; @@ -162,7 +162,7 @@ describe('DiffBuilder', function() { }); it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() { - var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]), + const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]), diffBuilder = new jasmineUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }), @@ -186,7 +186,7 @@ describe('DiffBuilder', function() { }); it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() { - var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]), + const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]), diffBuilder = new jasmineUnderTest.DiffBuilder({ prettyPrinter: prettyPrinter }), diff --git a/spec/core/matchers/MismatchTreeSpec.js b/spec/core/matchers/MismatchTreeSpec.js index 8a158df4..ad35ed84 100644 --- a/spec/core/matchers/MismatchTreeSpec.js +++ b/spec/core/matchers/MismatchTreeSpec.js @@ -2,7 +2,7 @@ describe('MismatchTree', function() { describe('#add', function() { describe('When the path is empty', function() { it('flags the root node as mismatched', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath([])); expect(tree.isMismatch).toBe(true); }); @@ -10,7 +10,7 @@ describe('MismatchTree', function() { describe('When the path is not empty', function() { it('flags the node as mismatched', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); @@ -18,7 +18,7 @@ describe('MismatchTree', function() { }); it('does not flag ancestors as mismatched', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); @@ -28,7 +28,7 @@ describe('MismatchTree', function() { }); it('stores the formatter on only the target node', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter); @@ -38,7 +38,7 @@ describe('MismatchTree', function() { }); it('stores the path to the node', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter); @@ -48,10 +48,10 @@ describe('MismatchTree', function() { describe('#traverse', function() { it('calls the callback for all nodes that are or contain mismatches', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter); tree.add(new jasmineUnderTest.ObjectPath(['c'])); - var visit = jasmine.createSpy('visit').and.returnValue(true); + const visit = jasmine.createSpy('visit').and.returnValue(true); tree.traverse(visit); @@ -78,8 +78,8 @@ describe('MismatchTree', function() { }); it('does not call the callback if there are no mismatches', function() { - var tree = new jasmineUnderTest.MismatchTree(); - var visit = jasmine.createSpy('visit'); + const tree = new jasmineUnderTest.MismatchTree(); + const visit = jasmine.createSpy('visit'); tree.traverse(visit); @@ -87,9 +87,9 @@ describe('MismatchTree', function() { }); it('visits parents before children', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); - var visited = []; + const visited = []; tree.traverse(function(path) { visited.push(path); @@ -104,10 +104,10 @@ describe('MismatchTree', function() { }); it('visits children in the order they were recorded', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['length'])); tree.add(new jasmineUnderTest.ObjectPath([1])); - var visited = []; + const visited = []; tree.traverse(function(path) { visited.push(path); @@ -122,9 +122,9 @@ describe('MismatchTree', function() { }); it('does not visit children if the callback returns falsy', function() { - var tree = new jasmineUnderTest.MismatchTree(); + const tree = new jasmineUnderTest.MismatchTree(); tree.add(new jasmineUnderTest.ObjectPath(['a', 'b'])); - var visited = []; + const visited = []; tree.traverse(function(path) { visited.push(path); diff --git a/spec/core/matchers/NullDiffBuilderSpec.js b/spec/core/matchers/NullDiffBuilderSpec.js index fa9ed299..41fb1f97 100644 --- a/spec/core/matchers/NullDiffBuilderSpec.js +++ b/spec/core/matchers/NullDiffBuilderSpec.js @@ -1,6 +1,6 @@ describe('NullDiffBuilder', function() { it('responds to withPath() by calling the passed function', function() { - var spy = jasmine.createSpy('callback'); + const spy = jasmine.createSpy('callback'); jasmineUnderTest.NullDiffBuilder().withPath('does not matter', spy); expect(spy).toHaveBeenCalled(); }); diff --git a/spec/core/matchers/ObjectPathSpec.js b/spec/core/matchers/ObjectPathSpec.js index 4e0d99fa..b83c61c7 100644 --- a/spec/core/matchers/ObjectPathSpec.js +++ b/spec/core/matchers/ObjectPathSpec.js @@ -1,5 +1,5 @@ describe('ObjectPath', function() { - var ObjectPath = jasmineUnderTest.ObjectPath; + const ObjectPath = jasmineUnderTest.ObjectPath; it('represents the path to a node in an object tree', function() { expect(new ObjectPath(['foo', 'bar']).toString()).toEqual('$.foo.bar'); @@ -34,8 +34,8 @@ describe('ObjectPath', function() { }); it('can be created based on another path', function() { - var root = new ObjectPath(); - var path = root.add('foo'); + const root = new ObjectPath(); + const path = root.add('foo'); expect(path.toString()).toEqual('$.foo'); expect(root.toString()).toEqual(''); diff --git a/spec/core/matchers/async/toBePendingSpec.js b/spec/core/matchers/async/toBePendingSpec.js index 385a08be..22a0f6ce 100644 --- a/spec/core/matchers/async/toBePendingSpec.js +++ b/spec/core/matchers/async/toBePendingSpec.js @@ -1,6 +1,6 @@ describe('toBePending', function() { it('passes if the actual promise is pending', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), actual = new Promise(function() {}); @@ -10,7 +10,7 @@ describe('toBePending', function() { }); it('fails if the actual promise is resolved', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), actual = Promise.resolve(); @@ -20,7 +20,7 @@ describe('toBePending', function() { }); it('fails if the actual promise is rejected', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), actual = Promise.reject(new Error('promise was rejected')); @@ -30,7 +30,7 @@ describe('toBePending', function() { }); it('fails if actual is not a promise', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil), actual = 'not a promise'; diff --git a/spec/core/matchers/async/toBeRejectedSpec.js b/spec/core/matchers/async/toBeRejectedSpec.js index e69f0044..56b827ab 100644 --- a/spec/core/matchers/async/toBeRejectedSpec.js +++ b/spec/core/matchers/async/toBeRejectedSpec.js @@ -1,6 +1,6 @@ describe('toBeRejected', function() { it('passes if the actual is rejected', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), actual = Promise.reject('AsyncExpectationSpec rejection'); @@ -10,7 +10,7 @@ describe('toBeRejected', function() { }); it('fails if the actual is resolved', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), actual = Promise.resolve(); @@ -20,7 +20,7 @@ describe('toBeRejected', function() { }); it('fails if actual is not a promise', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeRejected(matchersUtil), actual = 'not a promise'; diff --git a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js index 32a25ada..db505ea6 100644 --- a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js @@ -1,6 +1,6 @@ describe('#toBeRejectedWithError', function() { it('passes when Error type matches', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -20,7 +20,7 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error type and message matches', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -40,7 +40,7 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error matches and is exactly Error', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -60,7 +60,7 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error message matches a string', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -80,7 +80,7 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error message matches a RegExp', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -100,7 +100,7 @@ describe('#toBeRejectedWithError', function() { }); it('passes when Error message is empty', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -120,7 +120,7 @@ describe('#toBeRejectedWithError', function() { }); it('passes when no arguments', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -140,7 +140,7 @@ describe('#toBeRejectedWithError', function() { }); it('fails when resolved', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -159,7 +159,7 @@ describe('#toBeRejectedWithError', function() { }); it('fails when rejected with non Error type', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -179,7 +179,7 @@ describe('#toBeRejectedWithError', function() { }); it('fails when Error type mismatches', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -199,7 +199,7 @@ describe('#toBeRejectedWithError', function() { }); it('fails when Error message mismatches', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( @@ -219,7 +219,7 @@ describe('#toBeRejectedWithError', function() { }); it('fails if actual is not a promise', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError( diff --git a/spec/core/matchers/async/toBeRejectedWithSpec.js b/spec/core/matchers/async/toBeRejectedWithSpec.js index af96719f..f2657d3c 100644 --- a/spec/core/matchers/async/toBeRejectedWithSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithSpec.js @@ -1,6 +1,6 @@ describe('#toBeRejectedWith', function() { it('should return true if the promise is rejected with the expected value', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.reject({ error: 'PEBCAK' }); @@ -10,7 +10,7 @@ describe('#toBeRejectedWith', function() { }); it('should fail if the promise resolves', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), actual = Promise.resolve(); @@ -20,7 +20,7 @@ describe('#toBeRejectedWith', function() { }); it('should fail if the promise is rejected with a different value', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), @@ -38,7 +38,7 @@ describe('#toBeRejectedWith', function() { }); it('should build its error correctly when negated', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), @@ -55,7 +55,7 @@ describe('#toBeRejectedWith', function() { }); it('should support custom equality testers', function() { - var customEqualityTesters = [ + const customEqualityTesters = [ function() { return true; } @@ -72,7 +72,7 @@ describe('#toBeRejectedWith', function() { }); it('fails if actual is not a promise', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil), diff --git a/spec/core/matchers/async/toBeResolvedSpec.js b/spec/core/matchers/async/toBeResolvedSpec.js index 42ce930e..e70b4df2 100644 --- a/spec/core/matchers/async/toBeResolvedSpec.js +++ b/spec/core/matchers/async/toBeResolvedSpec.js @@ -1,6 +1,6 @@ describe('toBeResolved', function() { it('passes if the actual is resolved', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), actual = Promise.resolve(); @@ -10,7 +10,7 @@ describe('toBeResolved', function() { }); it('fails if the actual is rejected', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter([]) }), matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), @@ -27,7 +27,7 @@ describe('toBeResolved', function() { }); it('fails if actual is not a promise', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeResolved(matchersUtil), actual = 'not a promise'; diff --git a/spec/core/matchers/async/toBeResolvedToSpec.js b/spec/core/matchers/async/toBeResolvedToSpec.js index 20f465d2..5c81441d 100644 --- a/spec/core/matchers/async/toBeResolvedToSpec.js +++ b/spec/core/matchers/async/toBeResolvedToSpec.js @@ -1,6 +1,6 @@ describe('#toBeResolvedTo', function() { it('passes if the promise is resolved to the expected value', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), actual = Promise.resolve({ foo: 42 }); @@ -10,7 +10,7 @@ describe('#toBeResolvedTo', function() { }); it('fails if the promise is rejected', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), @@ -29,7 +29,7 @@ describe('#toBeResolvedTo', function() { }); it('fails if the promise is resolved to a different value', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), @@ -47,7 +47,7 @@ describe('#toBeResolvedTo', function() { }); it('builds its message correctly when negated', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), @@ -64,7 +64,7 @@ describe('#toBeResolvedTo', function() { }); it('supports custom equality testers', function() { - var customEqualityTesters = [ + const customEqualityTesters = [ function() { return true; } @@ -82,7 +82,7 @@ describe('#toBeResolvedTo', function() { }); it('fails if actual is not a promise', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil), diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index 558a6612..b730c9c5 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -1,6 +1,6 @@ describe('matchersUtil', function() { it('exposes the injected pretty-printer as .pp', function() { - var pp = function() {}, + const pp = function() {}, matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }); expect(matchersUtil.pp).toBe(pp); @@ -8,72 +8,72 @@ describe('matchersUtil', function() { describe('equals', function() { it('passes for literals that are triple-equal', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(null, null)).toBe(true); expect(matchersUtil.equals(void 0, void 0)).toBe(true); }); it('fails for things that are not equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals({ a: 'foo' }, 1)).toBe(false); }); it('passes for Strings that are equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals('foo', 'foo')).toBe(true); }); it('fails for Strings that are not equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals('foo', 'bar')).toBe(false); }); it('passes for Numbers that are equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(123, 123)).toBe(true); }); it('fails for Numbers that are not equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(123, 456)).toBe(false); }); it('fails for a Number and a String that have equivalent values', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(123, '123')).toBe(false); }); it('passes for Dates that are equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Jan 1, 1970')) ).toBe(true); }); it('fails for Dates that are not equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Feb 3, 1991')) ).toBe(false); }); it('passes for Booleans that are equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(true, true)).toBe(true); }); it('fails for Booleans that are not equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(true, false)).toBe(false); }); it('passes for RegExps that are equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(/foo/, /foo/)).toBe(true); }); it('fails for RegExps that are not equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(/foo/, /bar/)).toBe(false); expect( matchersUtil.equals(new RegExp('foo', 'i'), new RegExp('foo')) @@ -81,12 +81,12 @@ describe('matchersUtil', function() { }); it('passes for Arrays that are equivalent', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals([1, 2], [1, 2])).toBe(true); }); it('passes for Arrays that are equivalent, with elements added by changing length', function() { - var foo = [], + const foo = [], matchersUtil = new jasmineUnderTest.MatchersUtil(); foo.length = 1; @@ -99,12 +99,12 @@ describe('matchersUtil', function() { }); it('fails for Arrays that have different elements', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals([1, 2, 3], [1, 5, 3])).toBe(false); }); it('fails for Arrays whose contents are equivalent, but have differing properties', function() { - var one = [1, 2, 3], + const one = [1, 2, 3], two = [1, 2, 3], matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -115,7 +115,7 @@ describe('matchersUtil', function() { }); it('passes for Arrays with equivalent contents and properties', function() { - var one = [1, 2, 3], + const one = [1, 2, 3], two = [1, 2, 3], matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -126,21 +126,21 @@ describe('matchersUtil', function() { }); it('passes for Errors that are the same type and have the same message', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Error('foo'), new Error('foo'))).toBe( true ); }); it('fails for Errors that are the same type and have different messages', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Error('foo'), new Error('bar'))).toBe( false ); }); it('fails for objects with different constructors', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); function One() {} function Two() {} @@ -148,17 +148,17 @@ describe('matchersUtil', function() { }); it('passes for Objects that are equivalent (simple case)', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals({ a: 'foo' }, { a: 'foo' })).toBe(true); }); it('fails for Objects that are not equivalent (simple case)', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals({ a: 'foo' }, { a: 'bar' })).toBe(false); }); it('passes for Objects that are equivalent (deep case)', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( matchersUtil.equals( { a: 'foo', b: { c: 'bar' } }, @@ -168,7 +168,7 @@ describe('matchersUtil', function() { }); it('fails for Objects that are not equivalent (deep case)', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( matchersUtil.equals( { a: 'foo', b: { c: 'baz' } }, @@ -178,7 +178,7 @@ describe('matchersUtil', function() { }); it('passes for Objects that are equivalent (with cycles)', function() { - var actual = { a: 'foo' }, + const actual = { a: 'foo' }, expected = { a: 'foo' }, matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -189,7 +189,7 @@ describe('matchersUtil', function() { }); it('fails for Objects that are not equivalent (with cycles)', function() { - var actual = { a: 'foo' }, + const actual = { a: 'foo' }, expected = { a: 'bar' }, matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -200,7 +200,7 @@ describe('matchersUtil', function() { }); it('fails for Objects that have the same number of keys, but different keys/values', function() { - var expected = { a: undefined }, + const expected = { a: undefined }, actual = { b: 1 }, matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -208,7 +208,7 @@ describe('matchersUtil', function() { }); it('fails when comparing an empty object to an empty array (issue #114)', function() { - var emptyObject = {}, + const emptyObject = {}, emptyArray = [], matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -217,7 +217,7 @@ describe('matchersUtil', function() { }); it('passes for equivalent frozen objects (GitHub issue #266)', function() { - var a = { foo: 1 }, + const a = { foo: 1 }, b = { foo: 1 }, matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -232,7 +232,7 @@ describe('matchersUtil', function() { return; } - var p1 = new Promise(function() {}), + const p1 = new Promise(function() {}), p2 = new Promise(function() {}), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -249,13 +249,13 @@ describe('matchersUtil', function() { if (isNotRunningInBrowser()) { return; } - var a = document.createElement('div'); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a = document.createElement('div'); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); a.setAttribute('test-attr', 'attr-value'); a.appendChild(document.createTextNode('test')); - var b = document.createElement('div'); + const b = document.createElement('div'); b.setAttribute('test-attr', 'attr-value'); b.appendChild(document.createTextNode('test')); @@ -266,8 +266,8 @@ describe('matchersUtil', function() { if (isNotRunningInBrowser()) { return; } - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var iframe = document.createElement('iframe'); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const iframe = document.createElement('iframe'); document.body.appendChild(iframe); iframe.contentWindow.eval('window.testObject = {}'); expect(matchersUtil.equals({}, iframe.contentWindow.testObject)).toBe( @@ -280,12 +280,12 @@ describe('matchersUtil', function() { if (isNotRunningInBrowser()) { return; } - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a = document.createElement('div'); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a = document.createElement('div'); a.setAttribute('test-attr', 'attr-value'); a.appendChild(document.createTextNode('test')); - var b = document.createElement('div'); + const b = document.createElement('div'); b.setAttribute('test-attr', 'attr-value2'); b.appendChild(document.createTextNode('test')); @@ -311,9 +311,9 @@ describe('matchersUtil', function() { if (isNotRunningInNode()) { return; } - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var vm = require('vm'); - var sandbox = { + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const vm = require('vm'); + const sandbox = { obj: null }; vm.runInNewContext('obj = {a: 1, b: 2}', sandbox); @@ -325,9 +325,9 @@ describe('matchersUtil', function() { if (isNotRunningInNode()) { return; } - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var vm = require('vm'); - var sandbox = { + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const vm = require('vm'); + const sandbox = { arr: null }; vm.runInNewContext('arr = [1, 2]', sandbox); @@ -337,7 +337,7 @@ describe('matchersUtil', function() { }); it('passes when Any is used', function() { - var number = 3, + const number = 3, anyNumber = new jasmineUnderTest.Any(Number), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -346,7 +346,7 @@ describe('matchersUtil', function() { }); it('fails when Any is compared to something unexpected', function() { - var number = 3, + const number = 3, anyString = new jasmineUnderTest.Any(String), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -355,7 +355,7 @@ describe('matchersUtil', function() { }); it('passes when ObjectContaining is used', function() { - var obj = { + const obj = { foo: 3, bar: 7 }, @@ -367,11 +367,11 @@ describe('matchersUtil', function() { }); it('passes when MapContaining is used', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var obj = new Map(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const obj = new Map(); obj.set(1, 2); obj.set('foo', 'bar'); - var containing = new jasmineUnderTest.MapContaining(new Map()); + const containing = new jasmineUnderTest.MapContaining(new Map()); containing.sample.set('foo', 'bar'); expect(matchersUtil.equals(obj, containing)).toBe(true); @@ -379,11 +379,11 @@ describe('matchersUtil', function() { }); it('passes when SetContaining is used', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var obj = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const obj = new Set(); obj.add(1); obj.add('foo'); - var containing = new jasmineUnderTest.SetContaining(new Set()); + const containing = new jasmineUnderTest.SetContaining(new Set()); containing.sample.add(1); expect(matchersUtil.equals(obj, containing)).toBe(true); @@ -391,7 +391,7 @@ describe('matchersUtil', function() { }); it('passes when an asymmetric equality tester returns true', function() { - var tester = { + const tester = { asymmetricMatch: function() { return true; } @@ -403,7 +403,7 @@ describe('matchersUtil', function() { }); it('fails when an asymmetric equality tester returns false', function() { - var tester = { + const tester = { asymmetricMatch: function() { return false; } @@ -415,7 +415,7 @@ describe('matchersUtil', function() { }); it('passes when ArrayContaining is used', function() { - var arr = ['foo', 'bar'], + const arr = ['foo', 'bar'], matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( @@ -424,7 +424,7 @@ describe('matchersUtil', function() { }); it('passes when a custom equality matcher returns true', function() { - var tester = function() { + const tester = function() { return true; }, matchersUtil = new jasmineUnderTest.MatchersUtil({ @@ -436,17 +436,17 @@ describe('matchersUtil', function() { }); it('passes for two empty Objects', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals({}, {})).toBe(true); }); describe("when a custom equality matcher returns 'undefined'", function() { - var tester = function() { + const tester = function() { return jasmine.undefined; }; it('passes for two empty Objects', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester], pp: function() {} }); @@ -455,7 +455,7 @@ describe('matchersUtil', function() { }); it('fails for equivalents when a custom equality matcher returns false', function() { - var tester = function() { + const tester = function() { return false; }, matchersUtil = new jasmineUnderTest.MatchersUtil({ @@ -467,7 +467,7 @@ describe('matchersUtil', function() { }); it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() { - var asymmetricTester = { + const asymmetricTester = { asymmetricMatch: function() { return true; } @@ -485,7 +485,7 @@ describe('matchersUtil', function() { }); it('passes when an Any is compared to an Any that checks for the same type', function() { - var any1 = new jasmineUnderTest.Any(Function), + const any1 = new jasmineUnderTest.Any(Function), any2 = new jasmineUnderTest.Any(Function), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -493,7 +493,7 @@ describe('matchersUtil', function() { }); it('passes for null prototype objects with same properties', function() { - var objA = Object.create(null), + const objA = Object.create(null), objB = Object.create(null), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -504,7 +504,7 @@ describe('matchersUtil', function() { }); it('fails for null prototype objects with different properties', function() { - var objA = Object.create(null), + const objA = Object.create(null), objB = Object.create(null), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -515,16 +515,16 @@ describe('matchersUtil', function() { }); it('passes when comparing two empty sets', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Set(), new Set())).toBe(true); }); it('passes when comparing identical sets', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setA = new Set(); setA.add(6); setA.add(5); - var setB = new Set(); + const setB = new Set(); setB.add(6); setB.add(5); @@ -532,11 +532,11 @@ describe('matchersUtil', function() { }); it('passes when comparing identical sets with different insertion order and simple elements', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setA = new Set(); setA.add(3); setA.add(6); - var setB = new Set(); + const setB = new Set(); setB.add(6); setB.add(3); @@ -544,24 +544,24 @@ describe('matchersUtil', function() { }); it('passes when comparing identical sets with different insertion order and complex elements 1', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA1 = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setA1 = new Set(); setA1.add(['a', 3]); setA1.add([6, 1]); - var setA2 = new Set(); + const setA2 = new Set(); setA1.add(['y', 3]); setA1.add([6, 1]); - var setA = new Set(); + const setA = new Set(); setA.add(setA1); setA.add(setA2); - var setB1 = new Set(); + const setB1 = new Set(); setB1.add([6, 1]); setB1.add(['a', 3]); - var setB2 = new Set(); + const setB2 = new Set(); setB1.add([6, 1]); setB1.add(['y', 3]); - var setB = new Set(); + const setB = new Set(); setB.add(setB1); setB.add(setB2); @@ -569,11 +569,11 @@ describe('matchersUtil', function() { }); it('passes when comparing identical sets with different insertion order and complex elements 2', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setA = new Set(); setA.add([[1, 2], [3, 4]]); setA.add([[5, 6], [7, 8]]); - var setB = new Set(); + const setB = new Set(); setB.add([[5, 6], [7, 8]]); setB.add([[1, 2], [3, 4]]); @@ -581,12 +581,12 @@ describe('matchersUtil', function() { }); it('fails for sets with different elements', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setA = new Set(); setA.add(6); setA.add(3); setA.add(5); - var setB = new Set(); + const setB = new Set(); setB.add(6); setB.add(4); setB.add(5); @@ -595,11 +595,11 @@ describe('matchersUtil', function() { }); it('fails for sets of different size', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setA = new Set(); setA.add(6); setA.add(3); - var setB = new Set(); + const setB = new Set(); setB.add(6); setB.add(4); setB.add(5); @@ -608,36 +608,36 @@ describe('matchersUtil', function() { }); it('passes when comparing two empty maps', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(new Map(), new Map())).toBe(true); }); it('passes when comparing identical maps', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const mapA = new Map(); mapA.set(6, 5); - var mapB = new Map(); + const mapB = new Map(); mapB.set(6, 5); expect(matchersUtil.equals(mapA, mapB)).toBe(true); }); it('passes when comparing identical maps with different insertion order', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const mapA = new Map(); mapA.set('a', 3); mapA.set(6, 1); - var mapB = new Map(); + const mapB = new Map(); mapB.set(6, 1); mapB.set('a', 3); expect(matchersUtil.equals(mapA, mapB)).toBe(true); }); it('fails for maps with different elements', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const mapA = new Map(); mapA.set(6, 3); mapA.set(5, 1); - var mapB = new Map(); + const mapB = new Map(); mapB.set(6, 4); mapB.set(5, 1); @@ -645,17 +645,17 @@ describe('matchersUtil', function() { }); it('fails for maps of different size', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const mapA = new Map(); mapA.set(6, 3); - var mapB = new Map(); + const mapB = new Map(); mapB.set(6, 4); mapB.set(5, 1); expect(matchersUtil.equals(mapA, mapB)).toBe(false); }); it('passes when comparing two identical URLs', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect( matchersUtil.equals( @@ -666,7 +666,7 @@ describe('matchersUtil', function() { }); it('fails when comparing two different URLs', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), url1 = new URL('http://localhost/1'); expect(matchersUtil.equals(url1, new URL('http://localhost/2'))).toBe( @@ -690,26 +690,26 @@ describe('matchersUtil', function() { }); it('passes for ArrayBuffers with same length and content', function() { - var buffer1 = new ArrayBuffer(4); - var buffer2 = new ArrayBuffer(4); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const buffer1 = new ArrayBuffer(4); + const buffer2 = new ArrayBuffer(4); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(buffer1, buffer2)).toBe(true); }); it('fails for ArrayBuffers with same length but different content', function() { - var buffer1 = new ArrayBuffer(4); - var buffer2 = new ArrayBuffer(4); - var array1 = new Uint8Array(buffer1); + const buffer1 = new ArrayBuffer(4); + const buffer2 = new ArrayBuffer(4); + const array1 = new Uint8Array(buffer1); array1[0] = 1; - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(buffer1, buffer2)).toBe(false); }); describe('Typed arrays', function() { it('fails for typed arrays of same length and contents but different types', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new Int8Array(1); - var a2 = new Uint8Array(1); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new Int8Array(1); + const a2 = new Uint8Array(1); a1[0] = a2[0] = 0; expect(matchersUtil.equals(a1, a2)).toBe(false); }); @@ -725,14 +725,14 @@ describe('matchersUtil', function() { 'Float32Array', 'Float64Array' ].forEach(function(typeName) { - var TypedArrayCtor = jasmine.getGlobal()[typeName]; + const TypedArrayCtor = jasmine.getGlobal()[typeName]; it( 'passes for ' + typeName + 's with same length and content', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(2); - var a2 = new TypedArrayCtor(2); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(2); + const a2 = new TypedArrayCtor(2); a1[0] = a2[0] = 0; a1[1] = a2[1] = 1; expect(matchersUtil.equals(a1, a2)).toBe(true); @@ -740,9 +740,9 @@ describe('matchersUtil', function() { ); it('fails for ' + typeName + 's with different length', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(2); - var a2 = new TypedArrayCtor(1); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(2); + const a2 = new TypedArrayCtor(1); a1[0] = a1[1] = a2[0] = 0; expect(matchersUtil.equals(a1, a2)).toBe(false); }); @@ -750,9 +750,9 @@ describe('matchersUtil', function() { it( 'fails for ' + typeName + 's with same length but different content', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(1); - var a2 = new TypedArrayCtor(1); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(1); + const a2 = new TypedArrayCtor(1); a1[0] = 0; a2[0] = 1; expect(matchersUtil.equals(a1, a2)).toBe(false); @@ -760,18 +760,18 @@ describe('matchersUtil', function() { ); it('checks nonstandard properties of ' + typeName, function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(1); - var a2 = new TypedArrayCtor(1); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(1); + const a2 = new TypedArrayCtor(1); a1[0] = a2[0] = 0; a1.extra = 'yes'; expect(matchersUtil.equals(a1, a2)).toBe(false); }); it('works with custom equality testers with ' + typeName, function() { - var a1 = new TypedArrayCtor(1); - var a2 = new TypedArrayCtor(1); - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const a1 = new TypedArrayCtor(1); + const a2 = new TypedArrayCtor(1); + const matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [ function() { return true; @@ -786,7 +786,7 @@ describe('matchersUtil', function() { ['BigInt64Array', 'BigUint64Array'].forEach(function(typeName) { function requireType() { - var TypedArrayCtor = jasmine.getGlobal()[typeName]; + const TypedArrayCtor = jasmine.getGlobal()[typeName]; if (!TypedArrayCtor) { pending('Browser does not support ' + typeName); @@ -798,10 +798,10 @@ describe('matchersUtil', function() { it( 'passes for ' + typeName + 's with same length and content', function() { - var TypedArrayCtor = requireType(); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(2); - var a2 = new TypedArrayCtor(2); + const TypedArrayCtor = requireType(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(2); + const a2 = new TypedArrayCtor(2); // eslint-disable-next-line compat/compat a1[0] = a2[0] = BigInt(0); // eslint-disable-next-line compat/compat @@ -811,10 +811,10 @@ describe('matchersUtil', function() { ); it('fails for ' + typeName + 's with different length', function() { - var TypedArrayCtor = requireType(); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(2); - var a2 = new TypedArrayCtor(1); + const TypedArrayCtor = requireType(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(2); + const a2 = new TypedArrayCtor(1); // eslint-disable-next-line compat/compat a1[0] = a1[1] = a2[0] = BigInt(0); expect(matchersUtil.equals(a1, a2)).toBe(false); @@ -823,10 +823,10 @@ describe('matchersUtil', function() { it( 'fails for ' + typeName + 's with same length but different content', function() { - var TypedArrayCtor = requireType(); - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var a1 = new TypedArrayCtor(2); - var a2 = new TypedArrayCtor(2); + const TypedArrayCtor = requireType(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const a1 = new TypedArrayCtor(2); + const a2 = new TypedArrayCtor(2); // eslint-disable-next-line compat/compat a1[0] = a1[1] = a2[0] = BigInt(0); // eslint-disable-next-line compat/compat @@ -838,7 +838,7 @@ describe('matchersUtil', function() { }); describe('when running in an environment with array polyfills', function() { - var findIndexDescriptor = Object.getOwnPropertyDescriptor( + const findIndexDescriptor = Object.getOwnPropertyDescriptor( Array.prototype, 'findIndex' ); @@ -865,13 +865,12 @@ describe('matchersUtil', function() { throw new TypeError('predicate must be a function'); } - var list = Object(this); - var length = list.length >>> 0; - var thisArg = arguments[1]; - var value; + const list = Object(this); + const length = list.length >>> 0; + const thisArg = arguments[1]; - for (var i = 0; i < length; i++) { - value = list[i]; + for (let i = 0; i < length; i++) { + const value = list[i]; if (predicate.call(thisArg, value, i, list)) { return i; } @@ -897,7 +896,7 @@ describe('matchersUtil', function() { describe('Building diffs for asymmetric equality testers', function() { it('diffs the values returned by valuesForDiff_', function() { - var tester = { + const tester = { asymmetricMatch: function() { return false; }, @@ -931,7 +930,7 @@ describe('matchersUtil', function() { }); it('records both objects when the tester does not implement valuesForDiff', function() { - var tester = { + const tester = { asymmetricMatch: function() { return false; } @@ -960,7 +959,7 @@ describe('matchersUtil', function() { }); it('uses a diffBuilder if one is provided as the third argument', function() { - var diffBuilder = new jasmineUnderTest.DiffBuilder(), + const diffBuilder = new jasmineUnderTest.DiffBuilder(), matchersUtil = new jasmineUnderTest.MatchersUtil(); spyOn(diffBuilder, 'recordMismatch'); @@ -981,27 +980,27 @@ describe('matchersUtil', function() { describe('contains', function() { it('passes when expected is a substring of actual', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains('ABC', 'BC')).toBe(true); }); it('fails when expected is a not substring of actual', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains('ABC', 'X')).toBe(false); }); it('passes when expected is an element in an actual array', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true); }); it('fails when expected is not an element in an actual array', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false); }); it('passes with mixed-element arrays', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains(['foo', { some: 'bar' }], 'foo')).toBe(true); expect( matchersUtil.contains(['foo', { some: 'bar' }], { some: 'bar' }) @@ -1009,7 +1008,7 @@ describe('matchersUtil', function() { }); it('uses custom equality testers if actual is an Array', function() { - var customTester = function() { + const customTester = function() { return true; }, matchersUtil = new jasmineUnderTest.MatchersUtil({ @@ -1021,18 +1020,18 @@ describe('matchersUtil', function() { }); it('fails when actual is undefined', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains(undefined, 'A')).toBe(false); }); it('fails when actual is null', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.contains(null, 'A')).toBe(false); }); it('works with array-like objects that implement iterable', function() { - var capturedArgs = null, - matchersUtil = new jasmineUnderTest.MatchersUtil(); + let capturedArgs = null; + const matchersUtil = new jasmineUnderTest.MatchersUtil(); function testFunction() { capturedArgs = arguments; @@ -1056,17 +1055,17 @@ describe('matchersUtil', function() { }); it('passes for set members', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setItem = { foo: 'bar' }; - var set = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const setItem = { foo: 'bar' }; + const set = new Set(); set.add(setItem); expect(matchersUtil.contains(set, setItem)).toBe(true); }); it('passes for objects that equal to a set member', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var set = new Set(); + const matchersUtil = new jasmineUnderTest.MatchersUtil(); + const set = new Set(); set.add({ foo: 'bar' }); expect(matchersUtil.contains(set, { foo: 'bar' })).toBe(true); @@ -1075,7 +1074,7 @@ describe('matchersUtil', function() { describe('buildFailureMessage', function() { it('builds an English sentence for a failure case', function() { - var actual = 'foo', + const actual = 'foo', name = 'toBar', pp = jasmineUnderTest.makePrettyPrinter(), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), @@ -1085,22 +1084,18 @@ describe('matchersUtil', function() { }); it("builds an English sentence for a 'not' failure case", function() { - var actual = 'foo', + const actual = 'foo', name = 'toBar', isNot = true, pp = jasmineUnderTest.makePrettyPrinter(), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), - message = (message = matchersUtil.buildFailureMessage( - name, - isNot, - actual - )); + 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() { - var actual = 'foo', + const actual = 'foo', name = 'toBar', pp = jasmineUnderTest.makePrettyPrinter(), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), @@ -1116,7 +1111,7 @@ describe('matchersUtil', function() { }); it('uses the injected pretty-printer to format the expecteds and actual', function() { - var actual = 'foo', + const actual = 'foo', expected1 = 'qux', expected2 = 'grault', name = 'toBar', @@ -1125,13 +1120,13 @@ describe('matchersUtil', function() { return '<' + value + '>'; }, matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), - message = (message = matchersUtil.buildFailureMessage( + 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 8fefa119..40beb9fe 100644 --- a/spec/core/matchers/nothingSpec.js +++ b/spec/core/matchers/nothingSpec.js @@ -1,6 +1,6 @@ describe('nothing', function() { it('should pass', function() { - var matcher = jasmineUnderTest.matchers.nothing(), + const matcher = jasmineUnderTest.matchers.nothing(), result = matcher.compare(); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toBeCloseToSpec.js b/spec/core/matchers/toBeCloseToSpec.js index d2d18c23..ceaa47e4 100644 --- a/spec/core/matchers/toBeCloseToSpec.js +++ b/spec/core/matchers/toBeCloseToSpec.js @@ -1,7 +1,7 @@ describe('toBeCloseTo', function() { it('passes when within two decimal places by default', function() { - var matcher = jasmineUnderTest.matchers.toBeCloseTo(), - result; + const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + let result; result = matcher.compare(0, 0); expect(result.pass).toBe(true); @@ -14,8 +14,8 @@ describe('toBeCloseTo', function() { }); it('fails when not within two decimal places by default', function() { - var matcher = jasmineUnderTest.matchers.toBeCloseTo(), - result; + const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + let result; result = matcher.compare(0, 0.01); expect(result.pass).toBe(false); @@ -25,8 +25,8 @@ describe('toBeCloseTo', function() { }); it('accepts an optional precision argument', function() { - var matcher = jasmineUnderTest.matchers.toBeCloseTo(), - result; + const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + let result; result = matcher.compare(0, 0.1, 0); expect(result.pass).toBe(true); @@ -48,7 +48,7 @@ describe('toBeCloseTo', function() { }); it('fails when one of the arguments is null', function() { - var matcher = jasmineUnderTest.matchers.toBeCloseTo(); + const matcher = jasmineUnderTest.matchers.toBeCloseTo(); expect(function() { matcher.compare(null, null); @@ -70,8 +70,8 @@ describe('toBeCloseTo', function() { }); it('rounds expected values', function() { - var matcher = jasmineUnderTest.matchers.toBeCloseTo(), - result; + const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + let result; result = matcher.compare(1.23, 1.229); expect(result.pass).toBe(true); @@ -98,8 +98,8 @@ describe('toBeCloseTo', function() { }); it('handles edge cases with rounding', function() { - var matcher = jasmineUnderTest.matchers.toBeCloseTo(), - result; + const matcher = jasmineUnderTest.matchers.toBeCloseTo(); + let result; // these cases resulted in false negatives in version of V8 // included in Node.js 12 and Chrome 74 (and Edge Chromium) diff --git a/spec/core/matchers/toBeDefinedSpec.js b/spec/core/matchers/toBeDefinedSpec.js index 4b89c9ac..9aa20288 100644 --- a/spec/core/matchers/toBeDefinedSpec.js +++ b/spec/core/matchers/toBeDefinedSpec.js @@ -1,17 +1,13 @@ describe('toBeDefined', function() { it('matches for defined values', function() { - var matcher = jasmineUnderTest.matchers.toBeDefined(), - result; - - result = matcher.compare('foo'); + const matcher = jasmineUnderTest.matchers.toBeDefined(); + const result = matcher.compare('foo'); expect(result.pass).toBe(true); }); it('fails when matching undefined values', function() { - var matcher = jasmineUnderTest.matchers.toBeDefined(), - result; - - result = matcher.compare(void 0); + const matcher = jasmineUnderTest.matchers.toBeDefined(); + const result = matcher.compare(void 0); expect(result.pass).toBe(false); }); }); diff --git a/spec/core/matchers/toBeFalseSpec.js b/spec/core/matchers/toBeFalseSpec.js index 47e2b389..f4038e5c 100644 --- a/spec/core/matchers/toBeFalseSpec.js +++ b/spec/core/matchers/toBeFalseSpec.js @@ -1,25 +1,19 @@ describe('toBeFalse', function() { it('passes for false', function() { - var matcher = jasmineUnderTest.matchers.toBeFalse(), - result; - - result = matcher.compare(false); + const matcher = jasmineUnderTest.matchers.toBeFalse(); + const result = matcher.compare(false); expect(result.pass).toBe(true); }); it('fails for non-false', function() { - var matcher = jasmineUnderTest.matchers.toBeFalse(), - result; - - result = matcher.compare('foo'); + const matcher = jasmineUnderTest.matchers.toBeFalse(); + const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); it('fails for falsy', function() { - var matcher = jasmineUnderTest.matchers.toBeFalse(), - result; - - result = matcher.compare(undefined); + const matcher = jasmineUnderTest.matchers.toBeFalse(); + const result = matcher.compare(undefined); expect(result.pass).toBe(false); }); }); diff --git a/spec/core/matchers/toBeFalsySpec.js b/spec/core/matchers/toBeFalsySpec.js index feb1d058..4a516738 100644 --- a/spec/core/matchers/toBeFalsySpec.js +++ b/spec/core/matchers/toBeFalsySpec.js @@ -1,7 +1,7 @@ describe('toBeFalsy', function() { it("passes for 'falsy' values", function() { - var matcher = jasmineUnderTest.matchers.toBeFalsy(), - result; + const matcher = jasmineUnderTest.matchers.toBeFalsy(); + let result; result = matcher.compare(false); expect(result.pass).toBe(true); @@ -23,8 +23,8 @@ describe('toBeFalsy', function() { }); it("fails for 'truthy' values", function() { - var matcher = jasmineUnderTest.matchers.toBeFalsy(), - result; + const matcher = jasmineUnderTest.matchers.toBeFalsy(); + let result; result = matcher.compare(true); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeGreaterThanOrEqualSpec.js b/spec/core/matchers/toBeGreaterThanOrEqualSpec.js index 444cd317..7adda0e4 100644 --- a/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +++ b/spec/core/matchers/toBeGreaterThanOrEqualSpec.js @@ -1,7 +1,7 @@ describe('toBeGreaterThanOrEqual', function() { it('passes when actual >= expected', function() { - var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(), - result; + const matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(); + let result; result = matcher.compare(2, 1); expect(result.pass).toBe(true); @@ -17,8 +17,8 @@ describe('toBeGreaterThanOrEqual', function() { }); it('fails when actual < expected', function() { - var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(), - result; + const matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(); + let result; result = matcher.compare(1, 2); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeGreaterThanSpec.js b/spec/core/matchers/toBeGreaterThanSpec.js index f157e524..1a2fb378 100644 --- a/spec/core/matchers/toBeGreaterThanSpec.js +++ b/spec/core/matchers/toBeGreaterThanSpec.js @@ -1,15 +1,13 @@ describe('toBeGreaterThan', function() { it('passes when actual > expected', function() { - var matcher = jasmineUnderTest.matchers.toBeGreaterThan(), - result; - - result = matcher.compare(2, 1); + const matcher = jasmineUnderTest.matchers.toBeGreaterThan(); + const result = matcher.compare(2, 1); expect(result.pass).toBe(true); }); it('fails when actual <= expected', function() { - var matcher = jasmineUnderTest.matchers.toBeGreaterThan(), - result; + const matcher = jasmineUnderTest.matchers.toBeGreaterThan(); + let result; result = matcher.compare(1, 1); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeInstanceOfSpec.js b/spec/core/matchers/toBeInstanceOfSpec.js index 252122f1..cb6ea070 100644 --- a/spec/core/matchers/toBeInstanceOfSpec.js +++ b/spec/core/matchers/toBeInstanceOfSpec.js @@ -1,8 +1,8 @@ describe('toBeInstanceOf', function() { describe('when expecting Number', function() { it('passes for literal number', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(3, Number); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(3, Number); expect(result).toEqual({ pass: true, message: 'Expected instance of Number not to be an instance of Number' @@ -10,10 +10,10 @@ describe('toBeInstanceOf', function() { }); it('passes for NaN', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf({ + const matcher = jasmineUnderTest.matchers.toBeInstanceOf({ pp: jasmineUnderTest.makePrettyPrinter() }); - var result = matcher.compare(NaN, Number); + const result = matcher.compare(NaN, Number); expect(result).toEqual({ pass: true, message: 'Expected instance of NaN not to be an instance of Number' @@ -21,8 +21,8 @@ describe('toBeInstanceOf', function() { }); it('passes for Infinity', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(Infinity, Number); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(Infinity, Number); expect(result).toEqual({ pass: true, message: 'Expected instance of Number not to be an instance of Number' @@ -30,8 +30,8 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-number', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare('foo', Number); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare('foo', Number); expect(result).toEqual({ pass: false, message: 'Expected instance of String to be an instance of Number' @@ -41,8 +41,8 @@ describe('toBeInstanceOf', function() { describe('when expecting String', function() { it('passes for a string', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare('foo', String); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare('foo', String); expect(result).toEqual({ pass: true, message: 'Expected instance of String not to be an instance of String' @@ -50,8 +50,8 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-string', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare({}, String); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare({}, String); expect(result).toEqual({ pass: false, message: 'Expected instance of Object to be an instance of String' @@ -61,8 +61,8 @@ describe('toBeInstanceOf', function() { describe('when expecting Boolean', function() { it('passes for a boolean', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(true, Boolean); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(true, Boolean); expect(result).toEqual({ pass: true, message: 'Expected instance of Boolean not to be an instance of Boolean' @@ -70,8 +70,8 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-boolean', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare('false', Boolean); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare('false', Boolean); expect(result).toEqual({ pass: false, message: 'Expected instance of String to be an instance of Boolean' @@ -81,8 +81,8 @@ describe('toBeInstanceOf', function() { describe('when expecting RegExp', function() { it('passes for a literal regular expression', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(/foo/, RegExp); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(/foo/, RegExp); expect(result).toEqual({ pass: true, message: 'Expected instance of RegExp not to be an instance of RegExp' @@ -92,10 +92,10 @@ describe('toBeInstanceOf', function() { describe('when expecting Function', function() { it('passes for a function', function() { - var fn = function() {}; + const fn = function() {}; - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(fn, Function); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(fn, Function); expect(result).toEqual({ pass: true, message: @@ -104,10 +104,10 @@ describe('toBeInstanceOf', function() { }); it('passes for an async function', function() { - var fn = eval("(async function fn() { return 'foo'; })"); + const fn = eval("(async function fn() { return 'foo'; })"); - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(fn, Function); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(fn, Function); expect(result).toEqual({ pass: true, message: @@ -120,8 +120,8 @@ describe('toBeInstanceOf', function() { function Animal() {} it('passes for any object', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare({ foo: 'bar' }, Object); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare({ foo: 'bar' }, Object); expect(result).toEqual({ pass: true, message: 'Expected instance of Object not to be an instance of Object' @@ -129,8 +129,8 @@ describe('toBeInstanceOf', function() { }); it('passes for an Error object', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(new Error('example'), Object); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(new Error('example'), Object); expect(result).toEqual({ pass: true, message: 'Expected instance of Error not to be an instance of Object' @@ -138,8 +138,8 @@ describe('toBeInstanceOf', function() { }); it('passes for a user-defined class', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(new Animal(), Object); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(new Animal(), Object); expect(result).toEqual({ pass: true, message: 'Expected instance of Animal not to be an instance of Object' @@ -147,8 +147,8 @@ describe('toBeInstanceOf', function() { }); it('fails for a non-object', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare('foo', Object); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare('foo', Object); expect(result).toEqual({ pass: false, message: 'Expected instance of String to be an instance of Object' @@ -156,12 +156,12 @@ describe('toBeInstanceOf', function() { }); it('passes for objects with no constructor', function() { - var object = Object.create(null); + const object = Object.create(null); - var matcher = jasmineUnderTest.matchers.toBeInstanceOf({ + const matcher = jasmineUnderTest.matchers.toBeInstanceOf({ pp: jasmineUnderTest.makePrettyPrinter() }); - var result = matcher.compare(object, Object); + const result = matcher.compare(object, Object); expect(result).toEqual({ pass: true, message: @@ -188,8 +188,8 @@ describe('toBeInstanceOf', function() { Cat.prototype.constructor = Cat; it('passes for instances of that class', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(new Animal(), Animal); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(new Animal(), Animal); expect(result).toEqual({ pass: true, message: 'Expected instance of Animal not to be an instance of Animal' @@ -197,8 +197,8 @@ describe('toBeInstanceOf', function() { }); it('passes for instances of a subclass', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(new Cat(), Animal); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(new Cat(), Animal); expect(result).toEqual({ pass: true, message: 'Expected instance of Cat not to be an instance of Animal' @@ -206,8 +206,8 @@ describe('toBeInstanceOf', function() { }); it('does not pass for sibling classes', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); - var result = matcher.compare(new Dog(), Cat); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const result = matcher.compare(new Dog(), Cat); expect(result).toEqual({ pass: false, message: 'Expected instance of Dog to be an instance of Cat' @@ -216,7 +216,7 @@ describe('toBeInstanceOf', function() { }); it('raises an error if passed an invalid expected value', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf(); + const matcher = jasmineUnderTest.matchers.toBeInstanceOf(); expect(function() { matcher.compare({}, 'Error'); }).toThrowError( @@ -226,7 +226,7 @@ describe('toBeInstanceOf', function() { }); it('raises an error if missing an expected value', function() { - var matcher = jasmineUnderTest.matchers.toBeInstanceOf({ + const matcher = jasmineUnderTest.matchers.toBeInstanceOf({ pp: jasmineUnderTest.makePrettyPrinter() }); expect(function() { diff --git a/spec/core/matchers/toBeLessThanOrEqualSpec.js b/spec/core/matchers/toBeLessThanOrEqualSpec.js index 0aa7940b..46777791 100644 --- a/spec/core/matchers/toBeLessThanOrEqualSpec.js +++ b/spec/core/matchers/toBeLessThanOrEqualSpec.js @@ -1,7 +1,7 @@ describe('toBeLessThanOrEqual', function() { it('passes when actual <= expected', function() { - var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(), - result; + const matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(); + let result; result = matcher.compare(1, 2); expect(result.pass).toBe(true); @@ -17,8 +17,8 @@ describe('toBeLessThanOrEqual', function() { }); it('fails when actual < expected', function() { - var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(), - result; + const matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(); + let result; result = matcher.compare(2, 1); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeLessThanSpec.js b/spec/core/matchers/toBeLessThanSpec.js index 24a1d9af..9b786375 100644 --- a/spec/core/matchers/toBeLessThanSpec.js +++ b/spec/core/matchers/toBeLessThanSpec.js @@ -1,15 +1,13 @@ describe('toBeLessThan', function() { it('passes when actual < expected', function() { - var matcher = jasmineUnderTest.matchers.toBeLessThan(), - result; - - result = matcher.compare(1, 2); + const matcher = jasmineUnderTest.matchers.toBeLessThan(); + const result = matcher.compare(1, 2); expect(result.pass).toBe(true); }); it('fails when actual <= expected', function() { - var matcher = jasmineUnderTest.matchers.toBeLessThan(), - result; + const matcher = jasmineUnderTest.matchers.toBeLessThan(); + let result; result = matcher.compare(1, 1); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeNaNSpec.js b/spec/core/matchers/toBeNaNSpec.js index d38ffed7..b04c23f3 100644 --- a/spec/core/matchers/toBeNaNSpec.js +++ b/spec/core/matchers/toBeNaNSpec.js @@ -1,16 +1,14 @@ describe('toBeNaN', function() { it('passes for NaN with a custom .not fail', function() { - var matcher = jasmineUnderTest.matchers.toBeNaN(), - result; - - result = matcher.compare(Number.NaN); + const matcher = jasmineUnderTest.matchers.toBeNaN(); + const result = matcher.compare(Number.NaN); expect(result.pass).toBe(true); expect(result.message).toEqual('Expected actual not to be NaN.'); }); it('fails for anything not a NaN', function() { - var matcher = jasmineUnderTest.matchers.toBeNaN(), - result; + const matcher = jasmineUnderTest.matchers.toBeNaN(); + let result; result = matcher.compare(1); expect(result.pass).toBe(false); @@ -29,7 +27,7 @@ describe('toBeNaN', function() { }); it('has a custom message on failure', function() { - var matcher = jasmineUnderTest.matchers.toBeNaN({ + const matcher = jasmineUnderTest.matchers.toBeNaN({ pp: jasmineUnderTest.makePrettyPrinter() }), result = matcher.compare(0); diff --git a/spec/core/matchers/toBeNegativeInfinitySpec.js b/spec/core/matchers/toBeNegativeInfinitySpec.js index d771378f..77cf0193 100644 --- a/spec/core/matchers/toBeNegativeInfinitySpec.js +++ b/spec/core/matchers/toBeNegativeInfinitySpec.js @@ -1,7 +1,7 @@ describe('toBeNegativeInfinity', function() { it("fails for anything that isn't -Infinity", function() { - var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), - result; + const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(); + let result; result = matcher.compare(1); expect(result.pass).toBe(false); @@ -14,7 +14,7 @@ describe('toBeNegativeInfinity', function() { }); it('has a custom message on failure', function() { - var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity({ + const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity({ pp: jasmineUnderTest.makePrettyPrinter() }), result = matcher.compare(0); @@ -23,7 +23,7 @@ describe('toBeNegativeInfinity', function() { }); it('succeeds for -Infinity', function() { - var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), + const matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), result = matcher.compare(Number.NEGATIVE_INFINITY); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toBeNullSpec.js b/spec/core/matchers/toBeNullSpec.js index da5c2856..cae7c03b 100644 --- a/spec/core/matchers/toBeNullSpec.js +++ b/spec/core/matchers/toBeNullSpec.js @@ -1,17 +1,13 @@ describe('toBeNull', function() { it('passes for null', function() { - var matcher = jasmineUnderTest.matchers.toBeNull(), - result; - - result = matcher.compare(null); + const matcher = jasmineUnderTest.matchers.toBeNull(); + const result = matcher.compare(null); expect(result.pass).toBe(true); }); it('fails for non-null', function() { - var matcher = jasmineUnderTest.matchers.toBeNull(), - result; - - result = matcher.compare('foo'); + const matcher = jasmineUnderTest.matchers.toBeNull(); + const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); }); diff --git a/spec/core/matchers/toBePositiveInfinitySpec.js b/spec/core/matchers/toBePositiveInfinitySpec.js index 3673fb69..6e5835de 100644 --- a/spec/core/matchers/toBePositiveInfinitySpec.js +++ b/spec/core/matchers/toBePositiveInfinitySpec.js @@ -1,7 +1,7 @@ describe('toBePositiveInfinity', function() { it("fails for anything that isn't Infinity", function() { - var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), - result; + const matcher = jasmineUnderTest.matchers.toBePositiveInfinity(); + let result; result = matcher.compare(1); expect(result.pass).toBe(false); @@ -14,7 +14,7 @@ describe('toBePositiveInfinity', function() { }); it('has a custom message on failure', function() { - var matcher = jasmineUnderTest.matchers.toBePositiveInfinity({ + const matcher = jasmineUnderTest.matchers.toBePositiveInfinity({ pp: jasmineUnderTest.makePrettyPrinter() }), result = matcher.compare(0); @@ -23,7 +23,7 @@ describe('toBePositiveInfinity', function() { }); it('succeeds for Infinity', function() { - var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), + const matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), result = matcher.compare(Number.POSITIVE_INFINITY); expect(result.pass).toBe(true); diff --git a/spec/core/matchers/toBeSpec.js b/spec/core/matchers/toBeSpec.js index b577b0da..dfa1011f 100644 --- a/spec/core/matchers/toBeSpec.js +++ b/spec/core/matchers/toBeSpec.js @@ -1,22 +1,19 @@ describe('toBe', function() { it('passes with no message when actual === expected', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result; - - result = matcher.compare(1, 1); + result = matcher.compare(1, 1); expect(result.pass).toBe(true); }); it('passes with a custom message when expected is an array', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result, array = [1]; - result = matcher.compare(array, array); + const result = matcher.compare(array, array); expect(result.pass).toBe(true); expect(result.message).toBe( 'Expected [ 1 ] not to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().' @@ -24,14 +21,13 @@ describe('toBe', function() { }); it('passes with a custom message when expected is an object', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result, obj = { foo: 'bar' }; - result = matcher.compare(obj, obj); + const result = matcher.compare(obj, obj); expect(result.pass).toBe(true); expect(result.message).toBe( "Expected Object({ foo: 'bar' }) not to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe()." @@ -39,23 +35,20 @@ describe('toBe', function() { }); it('fails with no message when actual !== expected', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil(), + const matchersUtil = new jasmineUnderTest.MatchersUtil(), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result; - - result = matcher.compare(1, 2); + 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() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result; + result = matcher.compare([1], [1]); - result = matcher.compare([1], [1]); expect(result.pass).toBe(false); expect(result.message).toBe( 'Expected [ 1 ] to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().' @@ -63,13 +56,12 @@ describe('toBe', function() { }); it('fails with a custom message when expected is an object', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result; + result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); - result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); expect(result.pass).toBe(false); expect(result.message).toBe( "Expected Object({ foo: 'bar' }) to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe()." @@ -77,15 +69,14 @@ describe('toBe', function() { }); it('works with custom object formatters when expected is an object', function() { - var formatter = function(x) { + const formatter = function(x) { return '<' + x.foo + '>'; }, prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }), matcher = jasmineUnderTest.matchers.toBe(matchersUtil), - result; + result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); - result = matcher.compare({ foo: 'bar' }, { foo: 'bar' }); expect(result.pass).toBe(false); expect(result.message).toBe( 'Expected to be . Tip: To check for deep equality, use .toEqual() instead of .toBe().' diff --git a/spec/core/matchers/toBeTrueSpec.js b/spec/core/matchers/toBeTrueSpec.js index d444d206..b7a0cb48 100644 --- a/spec/core/matchers/toBeTrueSpec.js +++ b/spec/core/matchers/toBeTrueSpec.js @@ -1,17 +1,13 @@ describe('toBeTrue', function() { it('passes for true', function() { - var matcher = jasmineUnderTest.matchers.toBeTrue(), - result; - - result = matcher.compare(true); + const matcher = jasmineUnderTest.matchers.toBeTrue(); + const result = matcher.compare(true); expect(result.pass).toBe(true); }); it('fails for non-true', function() { - var matcher = jasmineUnderTest.matchers.toBeTrue(), - result; - - result = matcher.compare('foo'); + const matcher = jasmineUnderTest.matchers.toBeTrue(); + const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); }); diff --git a/spec/core/matchers/toBeTruthySpec.js b/spec/core/matchers/toBeTruthySpec.js index 134210be..a1e128f4 100644 --- a/spec/core/matchers/toBeTruthySpec.js +++ b/spec/core/matchers/toBeTruthySpec.js @@ -1,7 +1,7 @@ describe('toBeTruthy', function() { it("passes for 'truthy' values", function() { - var matcher = jasmineUnderTest.matchers.toBeTruthy(), - result; + const matcher = jasmineUnderTest.matchers.toBeTruthy(); + let result; result = matcher.compare(true); expect(result.pass).toBe(true); @@ -23,8 +23,8 @@ describe('toBeTruthy', function() { }); it("fails for 'falsy' values", function() { - var matcher = jasmineUnderTest.matchers.toBeTruthy(), - result; + const matcher = jasmineUnderTest.matchers.toBeTruthy(); + let result; result = matcher.compare(false); expect(result.pass).toBe(false); diff --git a/spec/core/matchers/toBeUndefinedSpec.js b/spec/core/matchers/toBeUndefinedSpec.js index f4c090fe..40adb4e2 100644 --- a/spec/core/matchers/toBeUndefinedSpec.js +++ b/spec/core/matchers/toBeUndefinedSpec.js @@ -1,17 +1,13 @@ describe('toBeUndefined', function() { it('passes for undefined values', function() { - var matcher = jasmineUnderTest.matchers.toBeUndefined(), - result; - - result = matcher.compare(void 0); + const matcher = jasmineUnderTest.matchers.toBeUndefined(); + const result = matcher.compare(void 0); expect(result.pass).toBe(true); }); it('fails when matching defined values', function() { - var matcher = jasmineUnderTest.matchers.toBeUndefined(), - result; - - result = matcher.compare('foo'); + const matcher = jasmineUnderTest.matchers.toBeUndefined(); + const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); }); diff --git a/spec/core/matchers/toContainSpec.js b/spec/core/matchers/toContainSpec.js index 1feab6b4..d35f557c 100644 --- a/spec/core/matchers/toContainSpec.js +++ b/spec/core/matchers/toContainSpec.js @@ -1,27 +1,25 @@ describe('toContain', function() { it('delegates to jasmineUnderTest.matchersUtil.contains', function() { - var matchersUtil = { + const matchersUtil = { contains: jasmine.createSpy('delegated-contains').and.returnValue(true) }, - matcher = jasmineUnderTest.matchers.toContain(matchersUtil), - result; + matcher = jasmineUnderTest.matchers.toContain(matchersUtil); - result = matcher.compare('ABC', 'B'); + const result = matcher.compare('ABC', 'B'); expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B'); expect(result.pass).toBe(true); }); it('works with custom equality testers', function() { - var tester = function(a, b) { + const tester = function(a, b) { return a.toString() === b.toString(); }, matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }), - matcher = jasmineUnderTest.matchers.toContain(matchersUtil), - result; + matcher = jasmineUnderTest.matchers.toContain(matchersUtil); - result = matcher.compare(['1', '2'], 2); + 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 36a3506c..a6ca1ae7 100644 --- a/spec/core/matchers/toEqualSpec.js +++ b/spec/core/matchers/toEqualSpec.js @@ -3,50 +3,48 @@ describe('toEqual', function() { 'use strict'; function compareEquals(actual, expected) { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); - var result = matcher.compare(actual, expected); + const result = matcher.compare(actual, expected); return result; } it('delegates to equals function', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equals').and.returnValue(true), buildFailureMessage: function() { return 'does not matter'; }, DiffBuilder: new jasmineUnderTest.DiffBuilder() }, - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil), - result; + matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); - result = matcher.compare(1, 1); + const result = matcher.compare(1, 1); expect(matchersUtil.equals).toHaveBeenCalledWith(1, 1, jasmine.anything()); expect(result.pass).toBe(true); }); it('works with custom equality testers', function() { - var tester = function(a, b) { + const tester = function(a, b) { return a.toString() === b.toString(); }, matchersUtil = new jasmineUnderTest.MatchersUtil({ customTesters: [tester] }), - matcher = jasmineUnderTest.matchers.toEqual(matchersUtil), - result; + matcher = jasmineUnderTest.matchers.toEqual(matchersUtil); - result = matcher.compare(1, '1'); + const result = matcher.compare(1, '1'); expect(result.pass).toBe(true); }); it('reports the difference between objects that are not equal', function() { - var actual = { x: 1, y: 3 }, + const actual = { x: 1, y: 3 }, expected = { x: 2, y: 3 }, message = 'Expected $.x = 1 to equal 2.'; @@ -54,7 +52,7 @@ describe('toEqual', function() { }); it('reports the difference between nested objects that are not equal', function() { - var actual = { x: { y: 1 } }, + const actual = { x: { y: 1 } }, expected = { x: { y: 2 } }, message = 'Expected $.x.y = 1 to equal 2.'; @@ -62,7 +60,7 @@ describe('toEqual', function() { }); it("formats property access so that it's valid JavaScript", function() { - var actual = { 'my prop': 1 }, + const actual = { 'my prop': 1 }, expected = { 'my prop': 2 }, message = "Expected $['my prop'] = 1 to equal 2."; @@ -70,7 +68,7 @@ describe('toEqual', function() { }); it('reports missing properties', function() { - var actual = { x: {} }, + const actual = { x: {} }, expected = { x: { y: 1 } }, message = 'Expected $.x to have properties\n' + ' y: 1'; @@ -78,7 +76,7 @@ describe('toEqual', function() { }); it('reports extra properties', function() { - var actual = { x: { y: 1, z: 2 } }, + const actual = { x: { y: 1, z: 2 } }, expected = { x: {} }, message = 'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2'; @@ -87,7 +85,7 @@ describe('toEqual', function() { }); it('pretty-prints properties', function() { - var actual = { x: { y: 'foo bar' } }, + const actual = { x: { y: 'foo bar' } }, expected = { x: {} }, message = 'Expected $.x not to have properties\n' + " y: 'foo bar'"; @@ -101,7 +99,7 @@ describe('toEqual', function() { } } - var actual = { x: { y: 1, z: 2, f: 4 } }, + const actual = { x: { y: 1, z: 2, f: 4 } }, expected = { x: { y: 1, z: 2, g: 3 } }, pp = jasmineUnderTest.makePrettyPrinter([formatter]), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), @@ -122,7 +120,7 @@ describe('toEqual', function() { } } - var actual = [{ foo: 4 }], + const actual = [{ foo: 4 }], expected = [{ foo: 5 }], prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }), @@ -139,7 +137,7 @@ describe('toEqual', function() { } } - var actual = [ + const actual = [ { foo: { a: 1, b: 2 }, bar: 'should not be pretty printed' @@ -162,7 +160,7 @@ describe('toEqual', function() { }); it('reports extra and missing properties of the root-level object', function() { - var actual = { x: 1 }, + const actual = { x: 1 }, expected = { a: 1 }, message = 'Expected object to have properties\n' + @@ -174,7 +172,7 @@ describe('toEqual', function() { }); it('reports multiple incorrect values', function() { - var actual = { x: 1, y: 2 }, + 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.'; @@ -183,7 +181,7 @@ describe('toEqual', function() { }); it('reports mismatch between actual child object and expected child number', function() { - var actual = { x: { y: 2 } }, + const actual = { x: { y: 2 } }, expected = { x: 1 }, message = 'Expected $.x = Object({ y: 2 }) to equal 1.'; @@ -191,7 +189,7 @@ describe('toEqual', function() { }); it('uses the default failure message if actual is not an object', function() { - var actual = 1, + const actual = 1, expected = { x: {} }, message = 'Expected 1 to equal Object({ x: Object({ }) }).'; @@ -199,7 +197,7 @@ describe('toEqual', function() { }); it('uses the default failure message if expected is not an object', function() { - var actual = { x: {} }, + const actual = { x: {} }, expected = 1, message = 'Expected Object({ x: Object({ }) }) to equal 1.'; @@ -207,7 +205,7 @@ describe('toEqual', function() { }); it('uses the default failure message given arrays with different lengths', function() { - var actual = [1, 2], + const actual = [1, 2], expected = [1, 2, 3], message = 'Expected $.length = 2 to equal 3.\n' + @@ -217,7 +215,7 @@ describe('toEqual', function() { }); it('reports a mismatch between elements of equal-length arrays', function() { - var actual = [1, 2, 5], + const actual = [1, 2, 5], expected = [1, 2, 3], message = 'Expected $[2] = 5 to equal 3.'; @@ -225,7 +223,7 @@ describe('toEqual', function() { }); it('reports a mismatch between multiple array elements', function() { - var actual = [2, 2, 5], + const actual = [2, 2, 5], expected = [1, 2, 3], message = 'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.'; @@ -234,7 +232,7 @@ describe('toEqual', function() { }); it('reports a mismatch between properties of objects in arrays', function() { - var actual = [{ x: 1 }], + const actual = [{ x: 1 }], expected = [{ x: 2 }], message = 'Expected $[0].x = 1 to equal 2.'; @@ -242,7 +240,7 @@ describe('toEqual', function() { }); it('reports a mismatch between arrays in objects', function() { - var actual = { x: [1] }, + const actual = { x: [1] }, expected = { x: [2] }, message = 'Expected $.x[0] = 1 to equal 2.'; @@ -250,7 +248,7 @@ describe('toEqual', function() { }); it('reports mismatches between nested arrays', function() { - var actual = [[1]], + const actual = [[1]], expected = [[2]], message = 'Expected $[0][0] = 1 to equal 2.'; @@ -258,7 +256,7 @@ describe('toEqual', function() { }); it('reports mismatches between arrays of different types', function() { - var actual = new Uint32Array([1, 2, 3]), + 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 ].'; @@ -267,7 +265,7 @@ describe('toEqual', function() { }); it('reports mismatches involving NaN', function() { - var actual = { x: 0 }, + const actual = { x: 0 }, expected = { x: 0 / 0 }, message = 'Expected $.x = 0 to equal NaN.'; @@ -275,7 +273,7 @@ describe('toEqual', function() { }); it('reports mismatches involving regular expressions', function() { - var actual = { x: '1' }, + const actual = { x: '1' }, expected = { x: /1/ }, message = "Expected $.x = '1' to equal /1/."; @@ -283,7 +281,7 @@ describe('toEqual', function() { }); it('reports mismatches involving infinities', function() { - var actual = { x: 0 }, + const actual = { x: 0 }, expected = { x: 1 / 0 }, message = 'Expected $.x = 0 to equal Infinity.'; @@ -291,7 +289,7 @@ describe('toEqual', function() { }); it('reports mismatches involving booleans', function() { - var actual = { x: false }, + const actual = { x: false }, expected = { x: true }, message = 'Expected $.x = false to equal true.'; @@ -299,7 +297,7 @@ describe('toEqual', function() { }); it('reports mismatches involving strings', function() { - var actual = { x: 'foo' }, + const actual = { x: 'foo' }, expected = { x: 'bar' }, message = "Expected $.x = 'foo' to equal 'bar'."; @@ -307,7 +305,7 @@ describe('toEqual', function() { }); it('reports mismatches involving undefined', function() { - var actual = { x: void 0 }, + const actual = { x: void 0 }, expected = { x: 0 }, message = 'Expected $.x = undefined to equal 0.'; @@ -315,7 +313,7 @@ describe('toEqual', function() { }); it('reports mismatches involving null', function() { - var actual = { x: null }, + const actual = { x: null }, expected = { x: 0 }, message = 'Expected $.x = null to equal 0.'; @@ -326,7 +324,7 @@ describe('toEqual', function() { function Foo() {} function Bar() {} - var actual = { x: new Foo() }, + const actual = { x: new Foo() }, expected = { x: new Bar() }, message = 'Expected $.x to be a kind of Bar, but was Foo({ }).'; @@ -342,7 +340,7 @@ describe('toEqual', function() { } } - var actual = { x: new Foo() }, + const actual = { x: new Foo() }, expected = { x: new Bar() }, message = 'Expected $.x to be a kind of Bar, but was |[object Object]|.', pp = jasmineUnderTest.makePrettyPrinter([formatter]), @@ -356,7 +354,7 @@ describe('toEqual', function() { function Foo() {} function Bar() {} - var actual = new Foo(), + const actual = new Foo(), expected = new Bar(), message = 'Expected object to be a kind of Bar, but was Foo({ }).'; @@ -368,7 +366,7 @@ describe('toEqual', function() { }); it('reports mismatches between objects with their own constructor property', function() { - var actual = { x: { constructor: 'blerf' } }, + const actual = { x: { constructor: 'blerf' } }, expected = { x: { constructor: 'ftarrh' } }, message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'."; @@ -376,7 +374,7 @@ describe('toEqual', function() { }); it('reports mismatches between an object with a real constructor and one with its own constructor property', function() { - var actual = { x: {} }, + const actual = { x: {} }, expected = { x: { constructor: 'ftarrh' } }, message = 'Expected $.x to have properties\n' + " constructor: 'ftarrh'"; @@ -388,7 +386,7 @@ describe('toEqual', function() { }); it('reports mismatches between 0 and -0', function() { - var actual = { x: 0 }, + const actual = { x: 0 }, expected = { x: -0 }, message = 'Expected $.x = 0 to equal -0.'; @@ -396,7 +394,7 @@ describe('toEqual', function() { }); it('reports mismatches between 0 and Number.MIN_VALUE', function() { - var actual = { x: 0 }, + const actual = { x: 0 }, expected = { x: Number.MIN_VALUE }, message = 'Expected $.x = 0 to equal 5e-324.'; @@ -404,7 +402,7 @@ describe('toEqual', function() { }); it('reports mismatches between Errors', function() { - var actual = { x: new Error('the error you got') }, + 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.'; @@ -413,7 +411,7 @@ describe('toEqual', function() { }); it('reports mismatches between Functions', function() { - var actual = { x: function() {} }, + const actual = { x: function() {} }, expected = { x: function() {} }, message = 'Expected $.x = Function to equal Function.'; @@ -421,8 +419,8 @@ describe('toEqual', function() { }); it('reports mismatches between an object and objectContaining', function() { - var actual = { a: 1, b: 4, c: 3, extra: 'ignored' }; - var expected = jasmineUnderTest.objectContaining({ + const actual = { a: 1, b: 4, c: 3, extra: 'ignored' }; + const expected = jasmineUnderTest.objectContaining({ a: 1, b: 2, c: 3, @@ -434,16 +432,16 @@ describe('toEqual', function() { }); it('reports mismatches between a non-object and objectContaining', function() { - var actual = 1; - var expected = jasmineUnderTest.objectContaining({ a: 1 }); + const actual = 1; + const expected = jasmineUnderTest.objectContaining({ a: 1 }); expect(compareEquals(actual, expected).message).toEqual( "Expected 1 to equal ''." ); }); it('reports mismatches involving a nested objectContaining', function() { - var actual = { x: { a: 1, b: 4, c: 3, extra: 'ignored' } }; - var expected = { + const actual = { x: { a: 1, b: 4, c: 3, extra: 'ignored' } }; + const expected = { x: jasmineUnderTest.objectContaining({ a: 1, b: 2, c: 3, d: 4 }) }; expect(compareEquals(actual, expected).message).toEqual( @@ -455,59 +453,59 @@ describe('toEqual', function() { // == Sets == it('reports mismatches between Sets', function() { - var actual = new Set(); + const actual = new Set(); actual.add(1); - var expected = new Set(); + const expected = new Set(); expected.add(2); - var message = 'Expected Set( 1 ) to equal Set( 2 ).'; + const message = 'Expected Set( 1 ) to equal Set( 2 ).'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports deep mismatches within Sets', function() { - var actual = new Set(); + const actual = new Set(); actual.add({ x: 1 }); - var expected = new Set(); + const expected = new Set(); expected.add({ x: 2 }); - var message = + const message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Sets nested in objects', function() { - var actualSet = new Set(); + const actualSet = new Set(); actualSet.add(1); - var expectedSet = new Set(); + const expectedSet = new Set(); expectedSet.add(2); - var actual = { sets: [actualSet] }; - var expected = { sets: [expectedSet] }; - var message = 'Expected $.sets[0] = Set( 1 ) to equal Set( 2 ).'; + const actual = { sets: [actualSet] }; + const expected = { sets: [expectedSet] }; + const message = 'Expected $.sets[0] = Set( 1 ) to equal Set( 2 ).'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Sets of different lengths', function() { - var actual = new Set(); + const actual = new Set(); actual.add(1); actual.add(2); - var expected = new Set(); + const expected = new Set(); expected.add(2); - var message = 'Expected Set( 1, 2 ) to equal Set( 2 ).'; + const message = 'Expected Set( 1, 2 ) to equal Set( 2 ).'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Sets where actual is missing a value from expected', function() { // Use 'duplicate' object in actual so sizes match - var actual = new Set(); + const actual = new Set(); actual.add({ x: 1 }); actual.add({ x: 1 }); - var expected = new Set(); + const expected = new Set(); expected.add({ x: 1 }); expected.add({ x: 2 }); - var message = + const message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).'; expect(compareEquals(actual, expected).message).toEqual(message); @@ -515,13 +513,13 @@ describe('toEqual', function() { it('reports mismatches between Sets where actual has a value missing from expected', function() { // Use 'duplicate' object in expected so sizes match - var actual = new Set(); + const actual = new Set(); actual.add({ x: 1 }); actual.add({ x: 2 }); - var expected = new Set(); + const expected = new Set(); expected.add({ x: 1 }); expected.add({ x: 1 }); - var message = + const message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).'; expect(compareEquals(actual, expected).message).toEqual(message); @@ -531,114 +529,114 @@ describe('toEqual', function() { it('does not report mismatches between deep equal Maps', function() { // values are the same but with different object identity - var actual = new Map(); + const actual = new Map(); actual.set('a', { x: 1 }); - var expected = new Map(); + const expected = new Map(); expected.set('a', { x: 1 }); expect(compareEquals(actual, expected).pass).toBe(true); }); it('reports deep mismatches within Maps', function() { - var actual = new Map(); + const actual = new Map(); actual.set('a', { x: 1 }); - var expected = new Map(); + const expected = new Map(); expected.set('a', { x: 2 }); - var message = + const message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] )."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Maps nested in objects', function() { - var actual = { Maps: [new Map()] }; + const actual = { Maps: [new Map()] }; actual.Maps[0].set('a', 1); - var expected = { Maps: [new Map()] }; + const expected = { Maps: [new Map()] }; expected.Maps[0].set('a', 2); - var message = + const message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] )."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Maps of different lengths', function() { - var actual = new Map(); + const actual = new Map(); actual.set('a', 1); - var expected = new Map(); + const expected = new Map(); expected.set('a', 2); expected.set('b', 1); - var message = + const message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] )."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('reports mismatches between Maps with equal values but differing keys', function() { - var actual = new Map(); + const actual = new Map(); actual.set('a', 1); - var expected = new Map(); + const expected = new Map(); expected.set('b', 1); - var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] )."; + const message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] )."; expect(compareEquals(actual, expected).message).toEqual(message); }); it('does not report mismatches between Maps with keys with same object identity', function() { - var key = { x: 1 }; - var actual = new Map(); + const key = { x: 1 }; + const actual = new Map(); actual.set(key, 2); - var expected = new Map(); + const expected = new Map(); expected.set(key, 2); expect(compareEquals(actual, expected).pass).toBe(true); }); it('reports mismatches between Maps with identical keys with different object identity', function() { - var actual = new Map(); + const actual = new Map(); actual.set({ x: 1 }, 2); - var expected = new Map(); + const expected = new Map(); expected.set({ x: 1 }, 2); - var message = + const message = 'Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).'; expect(compareEquals(actual, expected).message).toEqual(message); }); it('does not report mismatches when comparing Map key to jasmine.anything()', function() { - var actual = new Map(); + const actual = new Map(); actual.set('a', 1); - var expected = new Map(); + const expected = new Map(); expected.set(jasmineUnderTest.anything(), 1); expect(compareEquals(actual, expected).pass).toBe(true); }); it('does not report mismatches when comparing Maps with the same symbol keys', function() { - var key = Symbol(); - var actual = new Map(); + const key = Symbol(); + const actual = new Map(); actual.set(key, 1); - var expected = new Map(); + const expected = new Map(); expected.set(key, 1); expect(compareEquals(actual, expected).pass).toBe(true); }); it('reports mismatches between Maps with different symbol keys', function() { - var actual = new Map(); + const actual = new Map(); actual.set(Symbol(), 1); - var expected = new Map(); + const expected = new Map(); expected.set(Symbol(), 1); - var message = + const message = 'Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).'; expect(compareEquals(actual, expected).message).toBe(message); }); it('does not report mismatches when comparing Map symbol key to jasmine.anything()', function() { - var actual = new Map(); + const actual = new Map(); actual.set(Symbol(), 1); - var expected = new Map(); + const expected = new Map(); expected.set(jasmineUnderTest.anything(), 1); expect(compareEquals(actual, expected).pass).toBe(true); @@ -652,8 +650,8 @@ describe('toEqual', function() { beforeEach(function() { this.nonBrowser = isNotRunningInBrowser(); if (this.nonBrowser) { - var JSDOM = require('jsdom').JSDOM; - var dom = new JSDOM(); + const JSDOM = require('jsdom').JSDOM; + const dom = new JSDOM(); jasmineUnderTest.getGlobal().Node = dom.window.Node; this.doc = dom.window.document; } else { @@ -668,7 +666,7 @@ describe('toEqual', function() { }); it('reports mismatches between DOM nodes with different tags', function() { - var actual = { a: this.doc.createElement('div') }, + const actual = { a: this.doc.createElement('div') }, expected = { a: this.doc.createElement('p') }, message = 'Expected $.a =
to equal

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

to equal
.'; @@ -692,18 +690,24 @@ describe('toEqual', function() { }); it('reports mismatches between SVG nodes', function() { - var nodeA = this.doc.createElementNS('http://www.w3.org/2000/svg', 'svg'), + const nodeA = this.doc.createElementNS( + 'http://www.w3.org/2000/svg', + 'svg' + ), nodeB = this.doc.createElementNS('http://www.w3.org/2000/svg', 'svg'); nodeA.setAttribute('height', '50'); nodeB.setAttribute('height', '30'); - var rect = this.doc.createElementNS('http://www.w3.org/2000/svg', 'rect'); + const rect = this.doc.createElementNS( + 'http://www.w3.org/2000/svg', + 'rect' + ); rect.setAttribute('width', '50'); nodeA.appendChild(rect); expect(nodeA.isEqualNode(nodeB)).toBe(false); - var actual = { a: nodeA }, + const actual = { a: nodeA }, expected = { a: nodeB }, message = 'Expected $.a = ... to equal .'; @@ -712,14 +716,14 @@ describe('toEqual', function() { }); it('reports whole DOM node when attribute contains > character', function() { - var nodeA = this.doc.createElement('div'), + const nodeA = this.doc.createElement('div'), nodeB = this.doc.createElement('div'); nodeA.setAttribute('thing', '>>>'); nodeB.setAttribute('thing', 'bar'); expect(nodeA.isEqualNode(nodeB)).toBe(false); - var actual = { a: nodeA }, + const actual = { a: nodeA }, expected = { a: nodeB }, message = 'Expected $.a =
to equal
.'; @@ -728,7 +732,7 @@ describe('toEqual', function() { }); it('reports no content when DOM node has multiple empty text nodes', function() { - var nodeA = this.doc.createElement('div'), + const nodeA = this.doc.createElement('div'), nodeB = this.doc.createElement('div'); nodeA.appendChild(this.doc.createTextNode('')); @@ -737,7 +741,7 @@ describe('toEqual', function() { nodeA.appendChild(this.doc.createTextNode('')); expect(nodeA.isEqualNode(nodeB)).toBe(false); - var actual = { a: nodeA }, + const actual = { a: nodeA }, expected = { a: nodeB }, message = 'Expected $.a =
to equal
.'; @@ -745,13 +749,13 @@ describe('toEqual', function() { }); it('reports content when DOM node has non empty text node', function() { - var nodeA = this.doc.createElement('div'), + const nodeA = this.doc.createElement('div'), nodeB = this.doc.createElement('div'); nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!')); expect(nodeA.isEqualNode(nodeB)).toBe(false); - var actual = { a: nodeA }, + const actual = { a: nodeA }, expected = { a: nodeB }, message = 'Expected $.a =
...
to equal
.'; @@ -759,13 +763,13 @@ describe('toEqual', function() { }); it('reports empty DOM attributes', function() { - var nodeA = this.doc.createElement('div'), + const nodeA = this.doc.createElement('div'), nodeB = this.doc.createElement('div'); nodeA.setAttribute('contenteditable', ''); expect(nodeA.isEqualNode(nodeB)).toBe(false); - var actual = { a: nodeA }, + const actual = { a: nodeA }, expected = { a: nodeB }, message = 'Expected $.a =
to equal
.'; @@ -773,13 +777,13 @@ describe('toEqual', function() { }); it('reports 0 attr value as non empty DOM attribute', function() { - var nodeA = this.doc.createElement('div'), + const nodeA = this.doc.createElement('div'), nodeB = this.doc.createElement('div'); nodeA.setAttribute('contenteditable', 0); expect(nodeA.isEqualNode(nodeB)).toBe(false); - var actual = { a: nodeA }, + const actual = { a: nodeA }, expected = { a: nodeB }, message = 'Expected $.a =
to equal
.'; @@ -787,7 +791,7 @@ describe('toEqual', function() { }); it('reports mismatches between a DOM node and a bare Object', function() { - var actual = { a: this.doc.createElement('div') }, + const actual = { a: this.doc.createElement('div') }, expected = { a: {} }, message = 'Expected $.a =
to equal Object({ }).'; @@ -796,7 +800,7 @@ describe('toEqual', function() { }); it('reports asymmetric mismatches', function() { - var actual = { a: 1 }, + const actual = { a: 1 }, expected = { a: jasmineUnderTest.any(String) }, message = 'Expected $.a = 1 to equal .'; @@ -805,7 +809,7 @@ describe('toEqual', function() { }); it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() { - var actual = { a: jasmineUnderTest.any(String) }, + const actual = { a: jasmineUnderTest.any(String) }, expected = { a: 1 }, message = 'Expected $.a = to equal 1.'; @@ -814,7 +818,7 @@ describe('toEqual', function() { }); it('does not report a mismatch when asymmetric matchers are satisfied', function() { - var actual = { a: 'a' }, + const actual = { a: 'a' }, expected = { a: jasmineUnderTest.any(String) }; expect(compareEquals(actual, expected).message).toEqual(''); @@ -822,7 +826,7 @@ describe('toEqual', function() { }); it('works on big complex stuff', function() { - var actual = { + const actual = { foo: [{ bar: 1, things: ['a', 'b'] }, { bar: 2, things: ['a', 'b'] }], baz: [{ a: { b: 1 } }], quux: 1, @@ -834,7 +838,7 @@ describe('toEqual', function() { aNull: void 0 }; - var expected = { + const expected = { foo: [ { bar: 2, things: ['a', 'b', 'c'] }, { bar: 2, things: ['a', 'd'] } @@ -849,7 +853,7 @@ describe('toEqual', function() { aNull: null }; - var message = + const message = 'Expected $.foo[0].bar = 1 to equal 2.\n' + 'Expected $.foo[0].things.length = 2 to equal 3.\n' + "Expected $.foo[0].things[2] = undefined to equal 'c'.\n" + @@ -869,7 +873,7 @@ describe('toEqual', function() { describe('different length arrays', function() { it('actual array is longer', function() { - var actual = [1, 1, 2, 3, 5], + const actual = [1, 1, 2, 3, 5], expected = [1, 1, 2, 3], message = 'Expected $.length = 5 to equal 4.\n' + @@ -886,7 +890,7 @@ describe('toEqual', function() { } } - var actual = [1, 1, 2, 3, 5], + const actual = [1, 1, 2, 3, 5], expected = [1, 1, 2, 3], pp = jasmineUnderTest.makePrettyPrinter([formatter]), matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }), @@ -899,7 +903,7 @@ describe('toEqual', function() { }); it('expected array is longer', function() { - var actual = [1, 1, 2, 3], + const actual = [1, 1, 2, 3], expected = [1, 1, 2, 3, 5], message = 'Expected $.length = 4 to equal 5.\n' + @@ -910,7 +914,7 @@ describe('toEqual', function() { }); it('undefined in middle of actual array', function() { - var actual = [1, void 0, 3], + const actual = [1, void 0, 3], expected = [1, 2, 3], message = 'Expected $[1] = undefined to equal 2.'; @@ -919,7 +923,7 @@ describe('toEqual', function() { }); it('undefined in middle of expected array', function() { - var actual = [1, 2, 3], + const actual = [1, 2, 3], expected = [1, void 0, 3], message = 'Expected $[1] = 2 to equal undefined.'; @@ -928,7 +932,7 @@ describe('toEqual', function() { }); it('actual array is longer by 4 elements', function() { - var actual = [1, 1, 2, 3, 5, 8, 13], + const actual = [1, 1, 2, 3, 5, 8, 13], expected = [1, 1, 2], message = 'Expected $.length = 7 to equal 3.\n' + @@ -942,7 +946,7 @@ describe('toEqual', function() { }); it('expected array is longer by 4 elements', function() { - var actual = [1, 1, 2], + const actual = [1, 1, 2], expected = [1, 1, 2, 3, 5, 8, 13], message = 'Expected $.length = 3 to equal 7.\n' + @@ -956,7 +960,7 @@ describe('toEqual', function() { }); it('different length and different elements', function() { - var actual = [1], + const actual = [1], expected = [2, 3], message = 'Expected $.length = 1 to equal 2.\n' + @@ -968,7 +972,7 @@ describe('toEqual', function() { }); it('object with nested array (actual longer than expected)', function() { - var actual = { values: [1, 1, 2, 3] }, + const actual = { values: [1, 1, 2, 3] }, expected = { values: [1, 1, 2] }, message = 'Expected $.values.length = 4 to equal 3.\n' + @@ -979,7 +983,7 @@ describe('toEqual', function() { }); it('object with nested array (expected longer than actual)', function() { - var actual = { values: [1, 1, 2] }, + const actual = { values: [1, 1, 2] }, expected = { values: [1, 1, 2, 3] }, message = 'Expected $.values.length = 3 to equal 4.\n' + @@ -990,7 +994,7 @@ describe('toEqual', function() { }); it('array with unexpected nested object', function() { - var actual = [1, 1, 2, { value: 3 }], + const actual = [1, 1, 2, { value: 3 }], expected = [1, 1, 2], message = 'Expected $.length = 4 to equal 3.\n' + @@ -1001,7 +1005,7 @@ describe('toEqual', function() { }); it('array with missing nested object', function() { - var actual = [1, 1, 2], + const actual = [1, 1, 2], expected = [1, 1, 2, { value: 3 }], message = 'Expected $.length = 3 to equal 4.\n' + @@ -1012,7 +1016,7 @@ describe('toEqual', function() { }); it('array with nested different length array', function() { - var actual = [[1], [1, 2]], + const actual = [[1], [1, 2]], expected = [[1, 1], [2]], message = 'Expected $[0].length = 1 to equal 2.\n' + @@ -1026,7 +1030,7 @@ describe('toEqual', function() { }); it('last element of longer array is undefined', function() { - var actual = [1, 2], + const actual = [1, 2], expected = [1, 2, void 0], message = 'Expected $.length = 2 to equal 3.'; @@ -1039,87 +1043,87 @@ describe('toEqual', function() { describe('Symbols', function() { it('Fails if Symbol compared to Object', function() { - var sym = Symbol('foo'); - var obj = {}; + const sym = Symbol('foo'); + const obj = {}; expect(sym).not.toEqual(obj); }); it('Passes Symbol with itself', function() { - var sym = Symbol('foo'); + const sym = Symbol('foo'); expect(sym).toEqual(sym); }); it('Fails if two Symbols with same value are compared', function() { - var symA = Symbol('foo'); - var symB = Symbol('foo'); + const symA = Symbol('foo'); + const symB = Symbol('foo'); expect(symA).not.toEqual(symB); }); it('Fails if two Symbols with different value are compared', function() { - var symA = Symbol('foo'); - var symB = Symbol('bar'); + const symA = Symbol('foo'); + const symB = Symbol('bar'); expect(symA).not.toEqual(symB); }); it('Fails if Symbol compared to NaN', function() { - var sym = Symbol('foo'); + const sym = Symbol('foo'); expect(sym).not.toEqual(NaN); }); it('Fails if Symbol compared to Infinity', function() { - var sym = Symbol('foo'); + const sym = Symbol('foo'); expect(sym).not.toEqual(Infinity); }); it('Fails if Symbol compared to String', function() { - var sym = Symbol('foo'); - var str = 'foo'; + const sym = Symbol('foo'); + const str = 'foo'; expect(sym).not.toEqual(str); }); it('Fails if Symbol compared to Number', function() { - var sym = Symbol('foo'); - var num = Math.random(); + const sym = Symbol('foo'); + const num = Math.random(); expect(sym).not.toEqual(num); }); it('Fails if Symbol compared to Boolean', function() { - var sym = Symbol('foo'); + const sym = Symbol('foo'); expect(sym).not.toEqual(true); expect(sym).not.toEqual(false); }); it('Fails if Symbol compared to Undefined', function() { - var sym = Symbol('foo'); + const sym = Symbol('foo'); expect(sym).not.toEqual(undefined); }); it('Fails if Symbol compared to null', function() { - var sym = Symbol('foo'); + const sym = Symbol('foo'); expect(sym).not.toEqual(null); }); it('Fails if Symbol compared to []', function() { - var sym = Symbol('foo'); - var arr = ['foo']; + const sym = Symbol('foo'); + const arr = ['foo']; expect(sym).not.toEqual(arr); }); it('Fails if Symbol compared to Function', function() { - var sym = Symbol('foo'); - var f = function func() {}; + const sym = Symbol('foo'); + const f = function func() {}; expect(sym).not.toEqual(f); }); diff --git a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js index b8ad4951..251a2c9e 100644 --- a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +++ b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js @@ -1,6 +1,6 @@ describe('toHaveBeenCalledBefore', function() { it('throws an exception when the actual is not a spy', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({ + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() {}, @@ -12,7 +12,7 @@ describe('toHaveBeenCalledBefore', function() { }); it('throws an exception when the expected is not a spy', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({ + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({ pp: jasmineUnderTest.makePrettyPrinter() }), spy = new jasmineUnderTest.Env().createSpy('a spy'), @@ -24,7 +24,7 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual was not called', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), firstSpy = new jasmineUnderTest.Spy('first spy'), secondSpy = new jasmineUnderTest.Spy('second spy'); @@ -38,7 +38,7 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the expected was not called', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), firstSpy = new jasmineUnderTest.Spy('first spy'), secondSpy = new jasmineUnderTest.Spy('second spy'); @@ -52,15 +52,14 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual is called after the expected', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'), - result; + secondSpy = new jasmineUnderTest.Spy('second spy'); secondSpy(); firstSpy(); - result = matcher.compare(firstSpy, secondSpy); + const result = matcher.compare(firstSpy, secondSpy); expect(result.pass).toBe(false); expect(result.message).toEqual( 'Expected spy first spy to have been called before spy second spy' @@ -68,16 +67,15 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the actual is called before and after the expected', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'), - result; + secondSpy = new jasmineUnderTest.Spy('second spy'); firstSpy(); secondSpy(); firstSpy(); - result = matcher.compare(firstSpy, secondSpy); + const result = matcher.compare(firstSpy, secondSpy); expect(result.pass).toBe(false); expect(result.message).toEqual( 'Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)' @@ -85,16 +83,15 @@ describe('toHaveBeenCalledBefore', function() { }); it('fails when the expected is called before and after the actual', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'), - result; + secondSpy = new jasmineUnderTest.Spy('second spy'); secondSpy(); firstSpy(); secondSpy(); - result = matcher.compare(firstSpy, secondSpy); + const result = matcher.compare(firstSpy, secondSpy); expect(result.pass).toBe(false); expect(result.message).toEqual( 'Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)' @@ -102,15 +99,14 @@ describe('toHaveBeenCalledBefore', function() { }); it('passes when the actual is called before the expected', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(), firstSpy = new jasmineUnderTest.Spy('first spy'), - secondSpy = new jasmineUnderTest.Spy('second spy'), - result; + secondSpy = new jasmineUnderTest.Spy('second spy'); firstSpy(); secondSpy(); - result = matcher.compare(firstSpy, secondSpy); + const result = matcher.compare(firstSpy, secondSpy); expect(result.pass).toBe(true); expect(result.message).toEqual( 'Expected spy first spy to not have been called before spy second spy, but it was' diff --git a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js index ff2975c9..997f6f5d 100644 --- a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js @@ -1,13 +1,12 @@ describe('toHaveBeenCalledOnceWith', function() { it('passes when the actual was called only once and with matching parameters', function() { - var pp = jasmineUnderTest.makePrettyPrinter(), + const pp = jasmineUnderTest.makePrettyPrinter(), util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'b'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(true); expect(result.message).toEqual( @@ -16,7 +15,7 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('supports custom equality testers', function() { - var customEqualityTesters = [ + const customEqualityTesters = [ function() { return true; } @@ -27,23 +26,21 @@ describe('toHaveBeenCalledOnceWith', function() { matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith( matchersUtil ), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'b'); - result = matcher.compare(calledSpy, 'a', 'a'); + const result = matcher.compare(calledSpy, 'a', 'a'); expect(result.pass).toBe(true); }); it('fails when the actual was never called', function() { - var pp = jasmineUnderTest.makePrettyPrinter(), + const pp = jasmineUnderTest.makePrettyPrinter(), util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(false); expect(result.message).toEqual( @@ -52,14 +49,13 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called once with different parameters', function() { - var pp = jasmineUnderTest.makePrettyPrinter(), + const pp = jasmineUnderTest.makePrettyPrinter(), util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'c'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(false); expect(result.message).toEqual( @@ -68,15 +64,14 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called multiple times with expected parameters', function() { - var pp = jasmineUnderTest.makePrettyPrinter(), + const pp = jasmineUnderTest.makePrettyPrinter(), util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'b'); calledSpy('a', 'b'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(false); expect(result.message).toEqual( @@ -85,15 +80,14 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('fails when the actual was called multiple times (one of them - with expected parameters)', function() { - var pp = jasmineUnderTest.makePrettyPrinter(), + const pp = jasmineUnderTest.makePrettyPrinter(), util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'b'); calledSpy('a', 'c'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(false); expect(result.message).toEqual( @@ -102,7 +96,7 @@ describe('toHaveBeenCalledOnceWith', function() { }); it('throws an exception when the actual is not a spy', function() { - var pp = jasmineUnderTest.makePrettyPrinter(), + const pp = jasmineUnderTest.makePrettyPrinter(), util = new jasmineUnderTest.MatchersUtil({ pp: pp }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util), fn = function() {}; diff --git a/spec/core/matchers/toHaveBeenCalledSpec.js b/spec/core/matchers/toHaveBeenCalledSpec.js index ebc9a9cb..f8fa0ffe 100644 --- a/spec/core/matchers/toHaveBeenCalledSpec.js +++ b/spec/core/matchers/toHaveBeenCalledSpec.js @@ -1,12 +1,11 @@ describe('toHaveBeenCalled', function() { it('passes when the actual was called, with a custom .not fail message', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy(); - result = matcher.compare(calledSpy); + const result = matcher.compare(calledSpy); expect(result.pass).toBe(true); expect(result.message).toEqual( 'Expected spy called-spy not to have been called.' @@ -14,16 +13,15 @@ describe('toHaveBeenCalled', function() { }); it('fails when the actual was not called', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), + uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); - result = matcher.compare(uncalledSpy); + const result = matcher.compare(uncalledSpy); expect(result.pass).toBe(false); }); it('throws an exception when the actual is not a spy', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalled({ + const matcher = jasmineUnderTest.matchers.toHaveBeenCalled({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() {}; @@ -34,7 +32,7 @@ describe('toHaveBeenCalled', function() { }); it('throws an exception when invoked with any arguments', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), spy = new jasmineUnderTest.Spy('sample spy'); expect(function() { @@ -43,11 +41,10 @@ describe('toHaveBeenCalled', function() { }); it('has a custom message on failure', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), - spy = new jasmineUnderTest.Spy('sample-spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalled(), + spy = new jasmineUnderTest.Spy('sample-spy'); - result = matcher.compare(spy); + const result = matcher.compare(spy); expect(result.message).toEqual( 'Expected spy sample-spy to have been called.' diff --git a/spec/core/matchers/toHaveBeenCalledTimesSpec.js b/spec/core/matchers/toHaveBeenCalledTimesSpec.js index 2af579a8..141abeb9 100644 --- a/spec/core/matchers/toHaveBeenCalledTimesSpec.js +++ b/spec/core/matchers/toHaveBeenCalledTimesSpec.js @@ -1,23 +1,21 @@ describe('toHaveBeenCalledTimes', function() { it('passes when the actual 0 matches the expected 0 ', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; - result = matcher.compare(calledSpy, 0); + result = matcher.compare(calledSpy, 0); expect(result.pass).toBeTruthy(); }); it('passes when the actual matches the expected', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy(); - result = matcher.compare(calledSpy, 1); + const result = matcher.compare(calledSpy, 1); expect(result.pass).toBe(true); }); it('fails when expected numbers is not supplied', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), spy = new jasmineUnderTest.Spy('spy'); spy(); @@ -29,28 +27,26 @@ describe('toHaveBeenCalledTimes', function() { }); it('fails when the actual was called less than the expected', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); - result = matcher.compare(uncalledSpy, 2); + const result = matcher.compare(uncalledSpy, 2); expect(result.pass).toBe(false); }); it('fails when the actual was called more than expected', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); uncalledSpy(); uncalledSpy(); - result = matcher.compare(uncalledSpy, 1); + const result = matcher.compare(uncalledSpy, 1); expect(result.pass).toBe(false); }); it('throws an exception when the actual is not a spy', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({ + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() {}; @@ -61,15 +57,14 @@ describe('toHaveBeenCalledTimes', function() { }); it('has a custom message on failure that tells it was called only once', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new jasmineUnderTest.Spy('sample-spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + spy = new jasmineUnderTest.Spy('sample-spy'); spy(); spy(); spy(); spy(); - result = matcher.compare(spy, 1); + const result = matcher.compare(spy, 1); expect(result.message).toEqual( 'Expected spy sample-spy to have been called once. It was called ' + 4 + @@ -78,15 +73,14 @@ describe('toHaveBeenCalledTimes', function() { }); it('has a custom message on failure that tells how many times it was called', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), - spy = new jasmineUnderTest.Spy('sample-spy'), - result; + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(), + spy = new jasmineUnderTest.Spy('sample-spy'); spy(); spy(); spy(); spy(); - result = matcher.compare(spy, 2); + const result = matcher.compare(spy, 2); expect(result.message).toEqual( 'Expected spy sample-spy to have been called 2 times. It was called ' + 4 + diff --git a/spec/core/matchers/toHaveBeenCalledWithSpec.js b/spec/core/matchers/toHaveBeenCalledWithSpec.js index a0f869a4..d77800ed 100644 --- a/spec/core/matchers/toHaveBeenCalledWithSpec.js +++ b/spec/core/matchers/toHaveBeenCalledWithSpec.js @@ -1,15 +1,14 @@ describe('toHaveBeenCalledWith', function() { it('passes when the actual was called with matching parameters', function() { - var matchersUtil = { + const matchersUtil = { contains: jasmine.createSpy('delegated-contains').and.returnValue(true), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'b'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -18,7 +17,7 @@ describe('toHaveBeenCalledWith', function() { }); it('supports custom equality testers', function() { - var customEqualityTesters = [ + const customEqualityTesters = [ function() { return true; } @@ -27,26 +26,24 @@ describe('toHaveBeenCalledWith', function() { customTesters: customEqualityTesters }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called-spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called-spy'); calledSpy('a', 'b'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(true); }); it('fails when the actual was not called', function() { - var matchersUtil = { + const matchersUtil = { contains: jasmine .createSpy('delegated-contains') .and.returnValue(false), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'), - result; + uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'); - result = matcher.compare(uncalledSpy); + const result = matcher.compare(uncalledSpy); expect(result.pass).toBe(false); expect(result.message()).toEqual( 'Expected spy uncalled spy to have been called with:\n [ ]\nbut it was never called.' @@ -54,17 +51,16 @@ describe('toHaveBeenCalledWith', function() { }); it('fails when the actual was called with different parameters', function() { - var matchersUtil = new jasmineUnderTest.MatchersUtil({ + const matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: jasmineUnderTest.makePrettyPrinter() }), matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil), - calledSpy = new jasmineUnderTest.Spy('called spy'), - result; + calledSpy = new jasmineUnderTest.Spy('called spy'); calledSpy('a'); calledSpy('c', 'd'); calledSpy('a', 'b', 'c'); - result = matcher.compare(calledSpy, 'a', 'b'); + const result = matcher.compare(calledSpy, 'a', 'b'); expect(result.pass).toBe(false); expect(result.message()).toEqual( @@ -87,7 +83,7 @@ describe('toHaveBeenCalledWith', function() { }); it('throws an exception when the actual is not a spy', function() { - var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({ + const matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() {}; diff --git a/spec/core/matchers/toHaveClassSpec.js b/spec/core/matchers/toHaveClassSpec.js index d56a0a16..3ad1034a 100644 --- a/spec/core/matchers/toHaveClassSpec.js +++ b/spec/core/matchers/toHaveClassSpec.js @@ -4,7 +4,7 @@ describe('toHaveClass', function() { }); it('fails for a DOM element that lacks the expected class', function() { - var matcher = jasmineUnderTest.matchers.toHaveClass(), + const matcher = jasmineUnderTest.matchers.toHaveClass(), result = matcher.compare( this.domHelpers.createElementWithClassName(''), 'foo' @@ -14,7 +14,7 @@ describe('toHaveClass', function() { }); it('passes for a DOM element that has the expected class', function() { - var matcher = jasmineUnderTest.matchers.toHaveClass(), + const matcher = jasmineUnderTest.matchers.toHaveClass(), el = this.domHelpers.createElementWithClassName('foo bar baz'); expect(matcher.compare(el, 'foo').pass).toBe(true); @@ -23,14 +23,14 @@ describe('toHaveClass', function() { }); it('fails for a DOM element that only has other classes', function() { - var matcher = jasmineUnderTest.matchers.toHaveClass(), + const matcher = jasmineUnderTest.matchers.toHaveClass(), el = this.domHelpers.createElementWithClassName('foo bar'); expect(matcher.compare(el, 'fo').pass).toBe(false); }); it('throws an exception when actual is not a DOM element', function() { - var matcher = jasmineUnderTest.matchers.toHaveClass({ + const matcher = jasmineUnderTest.matchers.toHaveClass({ pp: jasmineUnderTest.makePrettyPrinter() }); @@ -42,7 +42,7 @@ describe('toHaveClass', function() { matcher.compare(undefined, 'foo'); }).toThrowError('undefined is not a DOM element'); - var textNode = this.domHelpers.document.createTextNode(''); + const textNode = this.domHelpers.document.createTextNode(''); expect(function() { matcher.compare(textNode, 'foo'); }).toThrowError('HTMLNode is not a DOM element'); diff --git a/spec/core/matchers/toHaveSizeSpec.js b/spec/core/matchers/toHaveSizeSpec.js index afcf8e81..c708a5b7 100644 --- a/spec/core/matchers/toHaveSizeSpec.js +++ b/spec/core/matchers/toHaveSizeSpec.js @@ -2,107 +2,107 @@ describe('toHaveSize', function() { 'use strict'; it('passes for an array whose length matches', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare([1, 2], 2); expect(result.pass).toBe(true); }); it('fails for an array whose length does not match', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare([1, 2, 3], 2); expect(result.pass).toBe(false); }); it('passes for an object with the proper number of keys', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2 }, 2); expect(result.pass).toBe(true); }); it('fails for an object with a different number of keys', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2 }, 1); expect(result.pass).toBe(false); }); it('passes for an object with an explicit `length` property that matches', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2, length: 5 }, 5); expect(result.pass).toBe(true); }); it('fails for an object with an explicit `length` property that does not match', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare({ a: 1, b: 2, length: 5 }, 1); expect(result.pass).toBe(false); }); it('passes for a string whose length matches', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare('ab', 2); expect(result.pass).toBe(true); }); it('fails for a string whose length does not match', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare('abc', 2); expect(result.pass).toBe(false); }); it('passes for a Map whose length matches', function() { - var map = new Map(); + const map = new Map(); map.set('a', 1); map.set('b', 2); - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare(map, 2); expect(result.pass).toBe(true); }); it('fails for a Map whose length does not match', function() { - var map = new Map(); + const map = new Map(); map.set('a', 1); map.set('b', 2); - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare(map, 1); expect(result.pass).toBe(false); }); it('passes for a Set whose length matches', function() { - var set = new Set(); + const set = new Set(); set.add('a'); set.add('b'); - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare(set, 2); expect(result.pass).toBe(true); }); it('fails for a Set whose length does not match', function() { - var set = new Set(); + const set = new Set(); set.add('a'); set.add('b'); - var matcher = jasmineUnderTest.matchers.toHaveSize(), + const matcher = jasmineUnderTest.matchers.toHaveSize(), result = matcher.compare(set, 1); expect(result.pass).toBe(false); }); it('throws an error for WeakSet', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(); + const matcher = jasmineUnderTest.matchers.toHaveSize(); expect(function() { matcher.compare(new WeakSet(), 2); @@ -110,7 +110,7 @@ describe('toHaveSize', function() { }); it('throws an error for WeakMap', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(); + const matcher = jasmineUnderTest.matchers.toHaveSize(); expect(function() { matcher.compare(new WeakMap(), 2); @@ -118,7 +118,7 @@ describe('toHaveSize', function() { }); it('throws an error for DataView', function() { - var matcher = jasmineUnderTest.matchers.toHaveSize(); + const matcher = jasmineUnderTest.matchers.toHaveSize(); expect(function() { matcher.compare(new DataView(new ArrayBuffer(128)), 2); diff --git a/spec/core/matchers/toMatchSpec.js b/spec/core/matchers/toMatchSpec.js index aa4d6c54..0dd4840b 100644 --- a/spec/core/matchers/toMatchSpec.js +++ b/spec/core/matchers/toMatchSpec.js @@ -1,38 +1,34 @@ describe('toMatch', function() { it('passes when RegExps are equivalent', function() { - var matcher = jasmineUnderTest.matchers.toMatch(), - result; + const matcher = jasmineUnderTest.matchers.toMatch(); - result = matcher.compare(/foo/, /foo/); + const result = matcher.compare(/foo/, /foo/); expect(result.pass).toBe(true); }); it('fails when RegExps are not equivalent', function() { - var matcher = jasmineUnderTest.matchers.toMatch(), - result; + const matcher = jasmineUnderTest.matchers.toMatch(); - result = matcher.compare(/bar/, /foo/); + const result = matcher.compare(/bar/, /foo/); expect(result.pass).toBe(false); }); it('passes when the actual matches the expected string as a pattern', function() { - var matcher = jasmineUnderTest.matchers.toMatch(), - result; + const matcher = jasmineUnderTest.matchers.toMatch(); - result = matcher.compare('foosball', 'foo'); + const result = matcher.compare('foosball', 'foo'); expect(result.pass).toBe(true); }); it('fails when the actual matches the expected string as a pattern', function() { - var matcher = jasmineUnderTest.matchers.toMatch(), - result; + const matcher = jasmineUnderTest.matchers.toMatch(); - result = matcher.compare('bar', 'foo'); + const result = matcher.compare('bar', 'foo'); expect(result.pass).toBe(false); }); it('throws an Error when the expected is not a String or RegExp', function() { - var matcher = jasmineUnderTest.matchers.toMatch(); + const matcher = jasmineUnderTest.matchers.toMatch(); expect(function() { matcher.compare('foo', { bar: 'baz' }); diff --git a/spec/core/matchers/toThrowErrorSpec.js b/spec/core/matchers/toThrowErrorSpec.js index 6d76a1d1..a3c967c5 100644 --- a/spec/core/matchers/toThrowErrorSpec.js +++ b/spec/core/matchers/toThrowErrorSpec.js @@ -1,6 +1,6 @@ describe('toThrowError', function() { it('throws an error when the actual is not a function', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(); + const matcher = jasmineUnderTest.matchers.toThrowError(); expect(function() { matcher.compare({}); @@ -8,7 +8,7 @@ describe('toThrowError', function() { }); it('throws an error when the expected is not an Error, string, or RegExp', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { throw new Error('foo'); }; @@ -19,7 +19,7 @@ describe('toThrowError', function() { }); it('throws an error when the expected error type is not an Error', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { throw new Error('foo'); }; @@ -30,7 +30,7 @@ describe('toThrowError', function() { }); it('throws an error when the expected error message is not a string or RegExp', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { throw new Error('foo'); }; @@ -41,28 +41,26 @@ describe('toThrowError', function() { }); it('fails if actual does not throw at all', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { return true; - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(false); expect(result.message).toEqual('Expected function to throw an Error.'); }); it('fails if thrown is not an instanceof Error', function() { - var matcher = jasmineUnderTest.matchers.toThrowError({ + const matcher = jasmineUnderTest.matchers.toThrowError({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw 4; - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(false); expect(result.message()).toEqual( 'Expected function to throw an Error, but it threw 4.' @@ -74,7 +72,7 @@ describe('toThrowError', function() { return typeof document === 'undefined'; } - var iframe = null; + let iframe = null; afterEach(function() { if (iframe !== null) { @@ -87,16 +85,16 @@ describe('toThrowError', function() { return; } - var matcher = jasmineUnderTest.matchers.toThrowError(); + const matcher = jasmineUnderTest.matchers.toThrowError(); iframe = document.body.appendChild(document.createElement('iframe')); iframe.src = 'about:blank'; - var iframeDocument = iframe.contentWindow.document; + const iframeDocument = iframe.contentWindow.document; iframeDocument.body.appendChild( iframeDocument.createElement('script') ).textContent = "function method() { throw new Error('foo'); }"; - var result = matcher.compare(iframe.contentWindow.method); + const result = matcher.compare(iframe.contentWindow.method); expect(result.pass).toBe(true); expect(result.message).toEqual( 'Expected function not to throw an Error, but it threw Error.' @@ -105,15 +103,14 @@ describe('toThrowError', function() { }); it('fails with the correct message if thrown is a falsy value', function() { - var matcher = jasmineUnderTest.matchers.toThrowError({ + const matcher = jasmineUnderTest.matchers.toThrowError({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw undefined; - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(false); expect(result.message()).toEqual( 'Expected function to throw an Error, but it threw undefined.' @@ -121,13 +118,12 @@ describe('toThrowError', function() { }); it('passes if thrown is a type of Error, but there is no expected error', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { throw new TypeError(); - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(true); expect(result.message).toEqual( @@ -136,15 +132,14 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected is the same message', function() { - var matcher = jasmineUnderTest.matchers.toThrowError({ + const matcher = jasmineUnderTest.matchers.toThrowError({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('foo'); - }, - result; + }; - result = matcher.compare(fn, 'foo'); + const result = matcher.compare(fn, 'foo'); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -153,15 +148,14 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is not the same message', function() { - var matcher = jasmineUnderTest.matchers.toThrowError({ + const matcher = jasmineUnderTest.matchers.toThrowError({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('foo'); - }, - result; + }; - result = matcher.compare(fn, 'bar'); + const result = matcher.compare(fn, 'bar'); expect(result.pass).toBe(false); expect(result.message()).toEqual( @@ -170,15 +164,14 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() { - var matcher = jasmineUnderTest.matchers.toThrowError({ + const matcher = jasmineUnderTest.matchers.toThrowError({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('a long message'); - }, - result; + }; - result = matcher.compare(fn, /long/); + const result = matcher.compare(fn, /long/); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -187,15 +180,14 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() { - var matcher = jasmineUnderTest.matchers.toThrowError({ + const matcher = jasmineUnderTest.matchers.toThrowError({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw new Error('a long message'); - }, - result; + }; - result = matcher.compare(fn, /foo/); + const result = matcher.compare(fn, /foo/); expect(result.pass).toBe(false); expect(result.message()).toEqual( @@ -204,31 +196,29 @@ describe('toThrowError', function() { }); it('passes if thrown is an Error and the expected the same Error', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { throw new Error(); - }, - result; + }; - result = matcher.compare(fn, Error); + const result = matcher.compare(fn, Error); expect(result.pass).toBe(true); expect(result.message()).toEqual('Expected function not to throw Error.'); }); it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), CustomError = function CustomError(arg) { arg.x; }, fn = function() { throw new CustomError({ x: 1 }); - }, - result; + }; CustomError.prototype = new Error(); - result = matcher.compare(fn, CustomError); + const result = matcher.compare(fn, CustomError); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -237,13 +227,12 @@ describe('toThrowError', function() { }); it('fails if thrown is an Error and the expected is a different Error', function() { - var matcher = jasmineUnderTest.matchers.toThrowError(), + const matcher = jasmineUnderTest.matchers.toThrowError(), fn = function() { throw new Error(); - }, - result; + }; - result = matcher.compare(fn, TypeError); + const result = matcher.compare(fn, TypeError); expect(result.pass).toBe(false); expect(result.message()).toEqual( @@ -252,17 +241,16 @@ describe('toThrowError', function() { }); it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); - }, - result; + }; - result = matcher.compare(fn, TypeError, 'foo'); + const result = matcher.compare(fn, TypeError, 'foo'); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -271,7 +259,7 @@ describe('toThrowError', function() { }); it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), pp: jasmineUnderTest.makePrettyPrinter() }, @@ -281,12 +269,11 @@ describe('toThrowError', function() { }, fn = function() { throw new CustomError({ message: 'foo' }); - }, - result; + }; CustomError.prototype = new Error(); - result = matcher.compare(fn, CustomError, 'foo'); + const result = matcher.compare(fn, CustomError, 'foo'); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -295,17 +282,16 @@ describe('toThrowError', function() { }); it('fails if thrown is a type of Error and the expected is a different Error', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); - }, - result; + }; - result = matcher.compare(fn, TypeError, 'bar'); + const result = matcher.compare(fn, TypeError, 'bar'); expect(result.pass).toBe(false); expect(result.message()).toEqual( @@ -314,17 +300,16 @@ describe('toThrowError', function() { }); it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); - }, - result; + }; - result = matcher.compare(fn, TypeError, /foo/); + const result = matcher.compare(fn, TypeError, /foo/); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -333,17 +318,16 @@ describe('toThrowError', function() { }); it('fails if thrown is a type of Error and the expected is a different Error', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil), fn = function() { throw new TypeError('foo'); - }, - result; + }; - result = matcher.compare(fn, TypeError, /bar/); + const result = matcher.compare(fn, TypeError, /bar/); expect(result.pass).toBe(false); expect(result.message()).toEqual( diff --git a/spec/core/matchers/toThrowMatchingSpec.js b/spec/core/matchers/toThrowMatchingSpec.js index a5ed2c5c..1b5ed44c 100644 --- a/spec/core/matchers/toThrowMatchingSpec.js +++ b/spec/core/matchers/toThrowMatchingSpec.js @@ -1,6 +1,6 @@ describe('toThrowMatching', function() { it('throws an error when the actual is not a function', function() { - var matcher = jasmineUnderTest.matchers.toThrowMatching(); + const matcher = jasmineUnderTest.matchers.toThrowMatching(); expect(function() { matcher.compare({}, function() { @@ -10,7 +10,7 @@ describe('toThrowMatching', function() { }); it('throws an error when the expected is not a function', function() { - var matcher = jasmineUnderTest.matchers.toThrowMatching(), + const matcher = jasmineUnderTest.matchers.toThrowMatching(), fn = function() { throw new Error('foo'); }; @@ -21,13 +21,12 @@ describe('toThrowMatching', function() { }); it('fails if actual does not throw at all', function() { - var matcher = jasmineUnderTest.matchers.toThrowMatching(), + const matcher = jasmineUnderTest.matchers.toThrowMatching(), fn = function() { return true; - }, - result; + }; - result = matcher.compare(fn, function() { + const result = matcher.compare(fn, function() { return true; }); @@ -36,15 +35,14 @@ describe('toThrowMatching', function() { }); it('fails with the correct message if thrown is a falsy value', function() { - var matcher = jasmineUnderTest.matchers.toThrowMatching({ + const matcher = jasmineUnderTest.matchers.toThrowMatching({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw undefined; - }, - result; + }; - result = matcher.compare(fn, function() { + const result = matcher.compare(fn, function() { return false; }); expect(result.pass).toBe(false); @@ -54,16 +52,15 @@ describe('toThrowMatching', function() { }); it('passes if the argument is a function that returns true when called with the error', function() { - var matcher = jasmineUnderTest.matchers.toThrowMatching(), + const matcher = jasmineUnderTest.matchers.toThrowMatching(), predicate = function(e) { return e.message === 'nope'; }, fn = function() { throw new TypeError('nope'); - }, - result; + }; - result = matcher.compare(fn, predicate); + const result = matcher.compare(fn, predicate); expect(result.pass).toBe(true); expect(result.message).toEqual( @@ -72,7 +69,7 @@ describe('toThrowMatching', function() { }); it('fails if the argument is a function that returns false when called with the error', function() { - var matcher = jasmineUnderTest.matchers.toThrowMatching({ + const matcher = jasmineUnderTest.matchers.toThrowMatching({ pp: jasmineUnderTest.makePrettyPrinter() }), predicate = function(e) { @@ -80,10 +77,9 @@ describe('toThrowMatching', function() { }, fn = function() { throw new TypeError('nope'); - }, - result; + }; - result = matcher.compare(fn, predicate); + const result = matcher.compare(fn, predicate); expect(result.pass).toBe(false); expect(result.message()).toEqual( diff --git a/spec/core/matchers/toThrowSpec.js b/spec/core/matchers/toThrowSpec.js index 0ed049d3..3f96010e 100644 --- a/spec/core/matchers/toThrowSpec.js +++ b/spec/core/matchers/toThrowSpec.js @@ -1,6 +1,6 @@ describe('toThrow', function() { it('throws an error when the actual is not a function', function() { - var matcher = jasmineUnderTest.matchers.toThrow(); + const matcher = jasmineUnderTest.matchers.toThrow(); expect(function() { matcher.compare({}); @@ -9,30 +9,28 @@ describe('toThrow', function() { }); it('fails if actual does not throw', function() { - var matcher = jasmineUnderTest.matchers.toThrow(), + const matcher = jasmineUnderTest.matchers.toThrow(), fn = function() { return true; - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(false); expect(result.message).toEqual('Expected function to throw an exception.'); }); it('passes if it throws but there is no expected', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(true); expect(result.message()).toEqual( @@ -41,15 +39,14 @@ describe('toThrow', function() { }); it('passes even if what is thrown is falsy', function() { - var matcher = jasmineUnderTest.matchers.toThrow({ + const matcher = jasmineUnderTest.matchers.toThrow({ pp: jasmineUnderTest.makePrettyPrinter() }), fn = function() { throw undefined; - }, - result; + }; - result = matcher.compare(fn); + const result = matcher.compare(fn); expect(result.pass).toBe(true); expect(result.message()).toEqual( 'Expected function not to throw, but it threw undefined.' @@ -57,34 +54,32 @@ describe('toThrow', function() { }); it('passes if what is thrown is equivalent to what is expected', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(true), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; - }, - result; + }; - result = matcher.compare(fn, 5); + const result = matcher.compare(fn, 5); expect(result.pass).toBe(true); expect(result.message()).toEqual('Expected function not to throw 5.'); }); it('fails if what is thrown is not equivalent to what is expected', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; - }, - result; + }; - result = matcher.compare(fn, 'foo'); + const result = matcher.compare(fn, 'foo'); expect(result.pass).toBe(false); expect(result.message()).toEqual( @@ -93,17 +88,16 @@ describe('toThrow', function() { }); it('fails if what is thrown is not equivalent to undefined', function() { - var matchersUtil = { + const matchersUtil = { equals: jasmine.createSpy('delegated-equal').and.returnValue(false), pp: jasmineUnderTest.makePrettyPrinter() }, matcher = jasmineUnderTest.matchers.toThrow(matchersUtil), fn = function() { throw 5; - }, - result; + }; - result = matcher.compare(fn, void 0); + const result = matcher.compare(fn, void 0); expect(result.pass).toBe(false); expect(result.message()).toEqual( diff --git a/spec/helpers/BrowserFlags.js b/spec/helpers/BrowserFlags.js index 248fc274..be5a7387 100644 --- a/spec/helpers/BrowserFlags.js +++ b/spec/helpers/BrowserFlags.js @@ -1,11 +1,11 @@ (function(env) { function browserVersion(matchFn) { - var userAgent = jasmine.getGlobal().navigator.userAgent; + const userAgent = jasmine.getGlobal().navigator.userAgent; if (!userAgent) { return void 0; } - var match = matchFn(userAgent); + const match = matchFn(userAgent); return match ? parseFloat(match[1]) : void 0; } diff --git a/spec/helpers/domHelpers.js b/spec/helpers/domHelpers.js index 79175df3..9cdb349a 100644 --- a/spec/helpers/domHelpers.js +++ b/spec/helpers/domHelpers.js @@ -1,19 +1,19 @@ (function(env) { function domHelpers() { - var doc; + let doc; if (typeof document !== 'undefined') { doc = document; } else { - var JSDOM = require('jsdom').JSDOM; - var dom = new JSDOM(); + const JSDOM = require('jsdom').JSDOM; + const dom = new JSDOM(); doc = dom.window.document; } return { document: doc, createElementWithClassName: function(className) { - var el = this.document.createElement('div'); + const el = this.document.createElement('div'); el.className = className; return el; } diff --git a/spec/helpers/integrationMatchers.js b/spec/helpers/integrationMatchers.js index da63cc74..fd80b83c 100644 --- a/spec/helpers/integrationMatchers.js +++ b/spec/helpers/integrationMatchers.js @@ -4,22 +4,22 @@ toHaveFailedExpectationsForRunnable: function() { return { compare: function(actual, fullName, expectedFailures) { - var foundRunnable = false, + let foundRunnable = false, expectations = true, foundFailures = []; - for (var i = 0; i < actual.calls.count(); i++) { - var args = actual.calls.argsFor(i)[0]; + for (let i = 0; i < actual.calls.count(); i++) { + const args = actual.calls.argsFor(i)[0]; if (args.fullName === fullName) { foundRunnable = true; - for (var j = 0; j < args.failedExpectations.length; j++) { + for (let j = 0; j < args.failedExpectations.length; j++) { foundFailures.push(args.failedExpectations[j].message); } - for (var j = 0; j < expectedFailures.length; j++) { - var failure = foundFailures[j]; - var expectedFailure = expectedFailures[j]; + for (let j = 0; j < expectedFailures.length; j++) { + const failure = foundFailures[j]; + const expectedFailure = expectedFailures[j]; if ( Object.prototype.toString.call(expectedFailure) === diff --git a/spec/helpers/nodeDefineJasmineUnderTest.js b/spec/helpers/nodeDefineJasmineUnderTest.js index c91bdc5f..7e4021a9 100644 --- a/spec/helpers/nodeDefineJasmineUnderTest.js +++ b/spec/helpers/nodeDefineJasmineUnderTest.js @@ -1,8 +1,8 @@ (function() { - var path = require('path'), + const path = require('path'), glob = require('glob'); - var jasmineUnderTestRequire = require(path.join( + const jasmineUnderTestRequire = require(path.join( __dirname, '../../src/core/requireCore.js' )); @@ -12,7 +12,7 @@ }; function getSourceFiles() { - var src_files = ['core/**/*.js', 'version.js'].map(function(file) { + const src_files = ['core/**/*.js', 'version.js'].map(function(file) { return path.join(__dirname, '../../', 'src/', file); }); diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js index 8a8ae4f2..cee8b949 100644 --- a/spec/html/HtmlReporterSpec.js +++ b/spec/html/HtmlReporterSpec.js @@ -1,5 +1,5 @@ describe('HtmlReporter', function() { - var env; + let env; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -10,7 +10,7 @@ describe('HtmlReporter', function() { }); it('builds the initial DOM elements, including the title banner', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -35,18 +35,18 @@ describe('HtmlReporter', function() { expect(container.querySelector('ul.jasmine-symbol-summary')).toBeTruthy(); // title banner - var banner = container.querySelector('.jasmine-banner'); + const banner = container.querySelector('.jasmine-banner'); - var title = banner.querySelector('a.jasmine-title'); + const title = banner.querySelector('a.jasmine-title'); expect(title.getAttribute('href')).toEqual('http://jasmine.github.io/'); expect(title.getAttribute('target')).toEqual('_blank'); - var version = banner.querySelector('.jasmine-version'); + const version = banner.querySelector('.jasmine-version'); expect(version.textContent).toEqual(jasmineUnderTest.version); }); it('builds a single reporter even if initialized multiple times', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -71,7 +71,8 @@ describe('HtmlReporter', function() { describe('when a spec is done', function() { describe('and no expectations ran', function() { - var container, reporter; + let container, reporter; + beforeEach(function() { container = document.createElement('div'); reporter = new jasmineUnderTest.HtmlReporter({ @@ -104,7 +105,7 @@ describe('HtmlReporter', function() { expect(console.warn).toHaveBeenCalledWith( "Spec 'Some Name' has no expectations." ); - var specEl = container.querySelector('.jasmine-symbol-summary li'); + const specEl = container.querySelector('.jasmine-symbol-summary li'); expect(specEl.getAttribute('class')).toEqual('jasmine-empty'); }); @@ -119,13 +120,13 @@ describe('HtmlReporter', function() { expect(console.error).toHaveBeenCalledWith( "Spec 'Some Name' has no expectations." ); - var specEl = container.querySelector('.jasmine-symbol-summary li'); + const specEl = container.querySelector('.jasmine-symbol-summary li'); expect(specEl.getAttribute('class')).toEqual('jasmine-failed'); }); }); it('reports the status symbol of a excluded spec', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -148,7 +149,7 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var specEl = container.querySelector('.jasmine-symbol-summary li'); + const specEl = container.querySelector('.jasmine-symbol-summary li'); expect(specEl.getAttribute('class')).toEqual('jasmine-excluded'); expect(specEl.getAttribute('id')).toEqual('spec_789'); expect(specEl.getAttribute('title')).toEqual( @@ -157,7 +158,7 @@ describe('HtmlReporter', function() { }); it('reports the status symbol of a pending spec', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -180,13 +181,13 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var specEl = container.querySelector('.jasmine-symbol-summary li'); + const specEl = container.querySelector('.jasmine-symbol-summary li'); expect(specEl.getAttribute('class')).toEqual('jasmine-pending'); expect(specEl.getAttribute('id')).toEqual('spec_789'); }); it('reports the status symbol of a passing spec', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -209,14 +210,14 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var statuses = container.querySelector('.jasmine-symbol-summary'); - var specEl = statuses.querySelector('li'); + const statuses = container.querySelector('.jasmine-symbol-summary'); + const specEl = statuses.querySelector('li'); expect(specEl.getAttribute('class')).toEqual('jasmine-passed'); expect(specEl.getAttribute('id')).toEqual('spec_123'); }); it('reports the status symbol of a failing spec', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -240,7 +241,7 @@ describe('HtmlReporter', function() { passedExpectations: [] }); - var specEl = container.querySelector('.jasmine-symbol-summary li'); + const specEl = container.querySelector('.jasmine-symbol-summary li'); expect(specEl.getAttribute('class')).toEqual('jasmine-failed'); expect(specEl.getAttribute('id')).toEqual('spec_345'); }); @@ -248,7 +249,7 @@ describe('HtmlReporter', function() { describe('when there are deprecation warnings', function() { it('displays the messages in their own alert bars', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -284,7 +285,9 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var alertBars = container.querySelectorAll('.jasmine-alert .jasmine-bar'); + const alertBars = container.querySelectorAll( + '.jasmine-alert .jasmine-bar' + ); expect(alertBars.length).toEqual(4); expect(alertBars[1].innerHTML).toMatch( @@ -301,7 +304,7 @@ describe('HtmlReporter', function() { }); it('displays expandable stack traces', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -314,10 +317,7 @@ describe('HtmlReporter', function() { createTextNode: function() { return document.createTextNode.apply(document, arguments); } - }), - expander, - expanderLink, - expanderContents; + }); reporter.initialize(); @@ -332,13 +332,15 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - expander = container.querySelector( + const expander = container.querySelector( '.jasmine-alert .jasmine-bar .jasmine-expander' ); - expanderContents = expander.querySelector('.jasmine-expander-contents'); + const expanderContents = expander.querySelector( + '.jasmine-expander-contents' + ); expect(expanderContents.textContent).toMatch(/a stack trace/); - expanderLink = expander.querySelector('a'); + const expanderLink = expander.querySelector('a'); expect(expander).not.toHaveClass('jasmine-expanded'); expect(expanderLink.textContent).toMatch(/Show stack trace/); @@ -352,7 +354,7 @@ describe('HtmlReporter', function() { }); it('omits the expander when there is no stack trace', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -365,8 +367,7 @@ describe('HtmlReporter', function() { createTextNode: function() { return document.createTextNode.apply(document, arguments); } - }), - warningBar; + }); reporter.initialize(); @@ -381,12 +382,12 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - warningBar = container.querySelector('.jasmine-warning'); + const warningBar = container.querySelector('.jasmine-warning'); expect(warningBar.querySelector('.jasmine-expander')).toBeFalsy(); }); it('nicely formats the verboseDeprecations note', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -399,8 +400,7 @@ describe('HtmlReporter', function() { createTextNode: function() { return document.createTextNode.apply(document, arguments); } - }), - alertBar; + }); reporter.initialize(); @@ -415,7 +415,7 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - alertBar = container.querySelector('.jasmine-warning'); + const alertBar = container.querySelector('.jasmine-warning'); expect(alertBar.innerHTML).toMatch( /a deprecation
Note: This message will be shown only once/ @@ -428,7 +428,7 @@ describe('HtmlReporter', function() { if (!window.console) { window.console = { error: function() {} }; } - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -463,16 +463,16 @@ describe('HtmlReporter', function() { reporter.suiteDone({ id: 1 }); reporter.jasmineDone({}); - var summary = container.querySelector('.jasmine-summary'); - var suite = summary.childNodes[0]; - var specs = suite.childNodes[1]; - var spec = specs.childNodes[0]; - var specLink = spec.childNodes[0]; + const summary = container.querySelector('.jasmine-summary'); + const suite = summary.childNodes[0]; + const specs = suite.childNodes[1]; + const spec = specs.childNodes[0]; + const specLink = spec.childNodes[0]; expect(specLink.innerHTML).toMatch(/SPEC HAS NO EXPECTATIONS/); }); it('reports the run time', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -493,14 +493,14 @@ describe('HtmlReporter', function() { reporter.jasmineDone({ totalTime: 100 }); - var duration = container.querySelector( + const duration = container.querySelector( '.jasmine-alert .jasmine-duration' ); expect(duration.innerHTML).toMatch(/finished in 0.1s/); }); it('reports the suite and spec names with status', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -526,7 +526,7 @@ describe('HtmlReporter', function() { fullName: 'A Suite' }); - var specResult = { + let specResult = { id: 123, description: 'with a spec', fullName: 'A Suite with a spec', @@ -543,7 +543,7 @@ describe('HtmlReporter', function() { fullName: 'A Suite inner suite' }); - var specResult = { + specResult = { id: 124, description: 'with another spec', fullName: 'A Suite inner suite with another spec', @@ -580,16 +580,16 @@ describe('HtmlReporter', function() { }); reporter.jasmineDone({}); - var summary = container.querySelector('.jasmine-summary'); + const summary = container.querySelector('.jasmine-summary'); expect(summary.childNodes.length).toEqual(1); - var outerSuite = summary.childNodes[0]; + const outerSuite = summary.childNodes[0]; expect(outerSuite.childNodes.length).toEqual(4); - var classes = []; - for (var i = 0; i < outerSuite.childNodes.length; i++) { - var node = outerSuite.childNodes[i]; + const classes = []; + for (let i = 0; i < outerSuite.childNodes.length; i++) { + const node = outerSuite.childNodes[i]; classes.push(node.getAttribute('class')); } expect(classes).toEqual([ @@ -599,17 +599,17 @@ describe('HtmlReporter', function() { 'jasmine-specs' ]); - var suiteDetail = outerSuite.childNodes[0]; - var suiteLink = suiteDetail.childNodes[0]; + const suiteDetail = outerSuite.childNodes[0]; + const suiteLink = suiteDetail.childNodes[0]; expect(suiteLink.innerHTML).toEqual('A Suite'); expect(suiteLink.getAttribute('href')).toEqual('/?foo=bar&spec=A Suite'); - var specs = outerSuite.childNodes[1]; - var spec = specs.childNodes[0]; + const specs = outerSuite.childNodes[1]; + const spec = specs.childNodes[0]; expect(spec.getAttribute('class')).toEqual('jasmine-passed'); expect(spec.getAttribute('id')).toEqual('spec-123'); - var specLink = spec.childNodes[0]; + const specLink = spec.childNodes[0]; expect(specLink.innerHTML).toEqual('with a spec'); expect(specLink.getAttribute('href')).toEqual( '/?foo=bar&spec=A Suite with a spec' @@ -617,7 +617,7 @@ describe('HtmlReporter', function() { }); it('has an options menu', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -635,7 +635,7 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var trigger = container.querySelector( + const trigger = container.querySelector( '.jasmine-run-options .jasmine-trigger' ), payload = container.querySelector( @@ -655,7 +655,7 @@ describe('HtmlReporter', function() { describe('when there are global errors', function() { it('displays the exceptions in their own alert bars', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -683,7 +683,7 @@ describe('HtmlReporter', function() { ] }); - var alertBars = container.querySelectorAll( + const alertBars = container.querySelectorAll( '.jasmine-alert .jasmine-bar' ); @@ -745,7 +745,7 @@ describe('HtmlReporter', function() { }); it('displays file and line information if available', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -774,7 +774,7 @@ describe('HtmlReporter', function() { ] }); - var alertBars = container.querySelectorAll( + const alertBars = container.querySelectorAll( '.jasmine-alert .jasmine-bar' ); @@ -787,7 +787,7 @@ describe('HtmlReporter', function() { describe('UI for stop on spec failure', function() { it('should be unchecked for full execution', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -805,12 +805,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); + const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); expect(stopOnFailureUI.checked).toBe(false); }); it('should be checked if stopping short', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -830,12 +830,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); + const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); expect(stopOnFailureUI.checked).toBe(true); }); it('should navigate and turn the setting on', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), navigationHandler = jasmine.createSpy('navigate'), getContainer = function() { return container; @@ -855,7 +855,7 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); + const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); stopOnFailureUI.click(); expect(navigationHandler).toHaveBeenCalledWith( @@ -865,7 +865,7 @@ describe('HtmlReporter', function() { }); it('should navigate and turn the setting off', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), navigationHandler = jasmine.createSpy('navigate'), getContainer = function() { return container; @@ -887,7 +887,7 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); + const stopOnFailureUI = container.querySelector('.jasmine-fail-fast'); stopOnFailureUI.click(); expect(navigationHandler).toHaveBeenCalledWith( @@ -899,7 +899,7 @@ describe('HtmlReporter', function() { describe('UI for throwing errors on expectation failures', function() { it('should be unchecked if not throwing', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -917,12 +917,14 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var throwingExpectationsUI = container.querySelector('.jasmine-throw'); + const throwingExpectationsUI = container.querySelector( + '.jasmine-throw' + ); expect(throwingExpectationsUI.checked).toBe(false); }); it('should be checked if throwing', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -942,12 +944,14 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var throwingExpectationsUI = container.querySelector('.jasmine-throw'); + const throwingExpectationsUI = container.querySelector( + '.jasmine-throw' + ); expect(throwingExpectationsUI.checked).toBe(true); }); it('should navigate and change the setting to on', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), navigateHandler = jasmine.createSpy('navigate'), getContainer = function() { return container; @@ -967,7 +971,9 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var throwingExpectationsUI = container.querySelector('.jasmine-throw'); + const throwingExpectationsUI = container.querySelector( + '.jasmine-throw' + ); throwingExpectationsUI.click(); expect(navigateHandler).toHaveBeenCalledWith( @@ -977,7 +983,7 @@ describe('HtmlReporter', function() { }); it('should navigate and change the setting to off', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), navigateHandler = jasmine.createSpy('navigate'), getContainer = function() { return container; @@ -999,7 +1005,9 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var throwingExpectationsUI = container.querySelector('.jasmine-throw'); + const throwingExpectationsUI = container.querySelector( + '.jasmine-throw' + ); throwingExpectationsUI.click(); expect(navigateHandler).toHaveBeenCalledWith( @@ -1010,7 +1018,7 @@ describe('HtmlReporter', function() { }); describe('UI for hiding disabled specs', function() { it('should be unchecked if not hiding disabled specs', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1029,12 +1037,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var disabledUI = container.querySelector('.jasmine-disabled'); + const disabledUI = container.querySelector('.jasmine-disabled'); expect(disabledUI.checked).toBe(false); }); it('should be checked if hiding disabled', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1053,12 +1061,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var disabledUI = container.querySelector('.jasmine-disabled'); + const disabledUI = container.querySelector('.jasmine-disabled'); expect(disabledUI.checked).toBe(true); }); it('should not display specs that have been disabled', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1083,7 +1091,7 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var specEl = container.querySelector('.jasmine-symbol-summary li'); + const specEl = container.querySelector('.jasmine-symbol-summary li'); expect(specEl.getAttribute('class')).toEqual( 'jasmine-excluded-no-display' ); @@ -1091,7 +1099,7 @@ describe('HtmlReporter', function() { }); describe('UI for running tests in random order', function() { it('should be unchecked if not randomizing', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1110,12 +1118,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var randomUI = container.querySelector('.jasmine-random'); + const randomUI = container.querySelector('.jasmine-random'); expect(randomUI.checked).toBe(false); }); it('should be checked if randomizing', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1134,12 +1142,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var randomUI = container.querySelector('.jasmine-random'); + const randomUI = container.querySelector('.jasmine-random'); expect(randomUI.checked).toBe(true); }); it('should navigate and change the setting to on', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), navigateHandler = jasmine.createSpy('navigate'), getContainer = function() { return container; @@ -1160,14 +1168,14 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var randomUI = container.querySelector('.jasmine-random'); + const randomUI = container.querySelector('.jasmine-random'); randomUI.click(); expect(navigateHandler).toHaveBeenCalledWith('random', true); }); it('should navigate and change the setting to off', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), navigateHandler = jasmine.createSpy('navigate'), getContainer = function() { return container; @@ -1188,14 +1196,14 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var randomUI = container.querySelector('.jasmine-random'); + const randomUI = container.querySelector('.jasmine-random'); randomUI.click(); expect(navigateHandler).toHaveBeenCalledWith('random', false); }); it('should show the seed bar if randomizing', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1218,14 +1226,14 @@ describe('HtmlReporter', function() { } }); - var seedBar = container.querySelector('.jasmine-seed-bar'); + const seedBar = container.querySelector('.jasmine-seed-bar'); expect(seedBar.textContent).toBe(', randomized with seed 424242'); - var seedLink = container.querySelector('.jasmine-seed-bar a'); + const seedLink = container.querySelector('.jasmine-seed-bar a'); expect(seedLink.getAttribute('href')).toBe('/?seed=424242'); }); it('should not show the current seed bar if not randomizing', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1243,12 +1251,12 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineDone({}); - var seedBar = container.querySelector('.jasmine-seed-bar'); + const seedBar = container.querySelector('.jasmine-seed-bar'); expect(seedBar).toBeNull(); }); it('should include non-spec query params in the jasmine-skipped link when present', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), reporter = new jasmineUnderTest.HtmlReporter({ env: env, getContainer: function() { @@ -1269,16 +1277,17 @@ describe('HtmlReporter', function() { reporter.jasmineStarted({ totalSpecsDefined: 1 }); reporter.jasmineDone({ order: { random: true } }); - var skippedLink = container.querySelector('.jasmine-skipped a'); + const skippedLink = container.querySelector('.jasmine-skipped a'); expect(skippedLink.getAttribute('href')).toEqual('/?foo=bar&spec='); }); }); describe('and all specs pass', function() { - var container; + let container; + beforeEach(function() { container = document.createElement('div'); - var getContainer = function() { + const getContainer = function() { return container; }, reporter = new jasmineUnderTest.HtmlReporter({ @@ -1314,7 +1323,7 @@ describe('HtmlReporter', function() { }); it('reports the specs counts', function() { - var alertBars = container.querySelectorAll( + const alertBars = container.querySelectorAll( '.jasmine-alert .jasmine-bar' ); @@ -1323,20 +1332,21 @@ describe('HtmlReporter', function() { }); it('reports no failure details', function() { - var specFailure = container.querySelector('.jasmine-failures'); + const specFailure = container.querySelector('.jasmine-failures'); expect(specFailure.childNodes.length).toEqual(0); }); it('reports no pending specs', function() { - var alertBar = container.querySelector('.jasmine-alert .jasmine-bar'); + const alertBar = container.querySelector('.jasmine-alert .jasmine-bar'); expect(alertBar.innerHTML).not.toMatch(/pending spec[s]/); }); }); describe('and there are excluded specs', function() { - var container, reporter, reporterConfig, specStatus; + let container, reporter, reporterConfig, specStatus; + beforeEach(function() { container = document.createElement('div'); reporterConfig = { @@ -1373,7 +1383,7 @@ describe('HtmlReporter', function() { }); it('shows the excluded spec in the spec list', function() { - var specList = container.querySelector('.jasmine-summary'); + const specList = container.querySelector('.jasmine-summary'); expect(specList.innerHTML).toContain('with a excluded spec'); }); @@ -1391,7 +1401,7 @@ describe('HtmlReporter', function() { }); it("doesn't show the excluded spec in the spec list", function() { - var specList = container.querySelector('.jasmine-summary'); + const specList = container.querySelector('.jasmine-summary'); expect(specList.innerHTML).toEqual(''); }); @@ -1399,10 +1409,11 @@ describe('HtmlReporter', function() { }); describe('and there are pending specs', function() { - var container, reporter; + let container, reporter; + beforeEach(function() { container = document.createElement('div'); - var getContainer = function() { + const getContainer = function() { return container; }; reporter = new jasmineUnderTest.HtmlReporter({ @@ -1418,7 +1429,7 @@ describe('HtmlReporter', function() { reporter.initialize(); reporter.jasmineStarted({ totalSpecsDefined: 1 }); - var specStatus = { + const specStatus = { id: 123, description: 'with a spec', fullName: 'A Suite with a spec', @@ -1433,7 +1444,7 @@ describe('HtmlReporter', function() { }); it('reports the pending specs count', function() { - var alertBar = container.querySelector('.jasmine-alert .jasmine-bar'); + const alertBar = container.querySelector('.jasmine-alert .jasmine-bar'); expect(alertBar.innerHTML).toMatch( /1 spec, 0 failures, 1 pending spec/ @@ -1441,13 +1452,13 @@ describe('HtmlReporter', function() { }); it('reports no failure details', function() { - var specFailure = container.querySelector('.jasmine-failures'); + const specFailure = container.querySelector('.jasmine-failures'); expect(specFailure.childNodes.length).toEqual(0); }); it('displays the custom pending reason', function() { - var pendingDetails = container.querySelector( + const pendingDetails = container.querySelector( '.jasmine-summary .jasmine-pending' ); @@ -1456,11 +1467,11 @@ describe('HtmlReporter', function() { }); describe('and some tests fail', function() { - var container, reporter; + let container, reporter; beforeEach(function() { container = document.createElement('div'); - var getContainer = function() { + const getContainer = function() { return container; }; reporter = new jasmineUnderTest.HtmlReporter({ @@ -1488,7 +1499,7 @@ describe('HtmlReporter', function() { description: 'inner suite' }); - var passingSpecResult = { + const passingSpecResult = { id: 123, status: 'passed', passedExpectations: [{ passed: true }], @@ -1497,7 +1508,7 @@ describe('HtmlReporter', function() { reporter.specStarted(passingSpecResult); reporter.specDone(passingSpecResult); - var failingSpecResult = { + const failingSpecResult = { id: 124, status: 'failed', description: 'a failing spec', @@ -1510,7 +1521,7 @@ describe('HtmlReporter', function() { } ] }; - var failingSpecResultWithDebugLogs = { + const failingSpecResultWithDebugLogs = { id: 567, status: 'failed', description: 'a failing spec', @@ -1528,11 +1539,11 @@ describe('HtmlReporter', function() { ] }; - var passingSuiteResult = { + const passingSuiteResult = { id: 1, description: 'A suite' }; - var failingSuiteResult = { + const failingSuiteResult = { id: 2, description: 'a suite', fullName: 'a suite', @@ -1550,48 +1561,48 @@ describe('HtmlReporter', function() { }); it('reports the specs counts', function() { - var alertBar = container.querySelector('.jasmine-alert .jasmine-bar'); + const alertBar = container.querySelector('.jasmine-alert .jasmine-bar'); expect(alertBar.innerHTML).toMatch(/3 specs, 3 failures/); }); it('reports failure messages and stack traces', function() { - var specFailures = container.querySelector('.jasmine-failures'); + const specFailures = container.querySelector('.jasmine-failures'); expect(specFailures.childNodes.length).toEqual(3); - var specFailure = specFailures.childNodes[0]; + const specFailure = specFailures.childNodes[0]; expect(specFailure.getAttribute('class')).toMatch(/jasmine-failed/); expect(specFailure.getAttribute('class')).toMatch( /jasmine-spec-detail/ ); - var specDiv = specFailure.childNodes[0]; + const specDiv = specFailure.childNodes[0]; expect(specDiv.getAttribute('class')).toEqual('jasmine-description'); - var message = specFailure.childNodes[1].childNodes[0]; + const message = specFailure.childNodes[1].childNodes[0]; expect(message.getAttribute('class')).toEqual('jasmine-result-message'); expect(message.innerHTML).toEqual('a failure message'); - var stackTrace = specFailure.childNodes[1].childNodes[1]; + const stackTrace = specFailure.childNodes[1].childNodes[1]; expect(stackTrace.getAttribute('class')).toEqual('jasmine-stack-trace'); expect(stackTrace.innerHTML).toEqual('a stack trace'); - var suiteFailure = specFailures.childNodes[0]; + const suiteFailure = specFailures.childNodes[0]; expect(suiteFailure.getAttribute('class')).toMatch(/jasmine-failed/); expect(suiteFailure.getAttribute('class')).toMatch( /jasmine-spec-detail/ ); - var suiteDiv = suiteFailure.childNodes[0]; + const suiteDiv = suiteFailure.childNodes[0]; expect(suiteDiv.getAttribute('class')).toEqual('jasmine-description'); - var suiteMessage = suiteFailure.childNodes[1].childNodes[0]; + const suiteMessage = suiteFailure.childNodes[1].childNodes[0]; expect(suiteMessage.getAttribute('class')).toEqual( 'jasmine-result-message' ); expect(suiteMessage.innerHTML).toEqual('a failure message'); - var suiteStackTrace = suiteFailure.childNodes[1].childNodes[1]; + const suiteStackTrace = suiteFailure.childNodes[1].childNodes[1]; expect(suiteStackTrace.getAttribute('class')).toEqual( 'jasmine-stack-trace' ); @@ -1599,22 +1610,21 @@ describe('HtmlReporter', function() { }); it('reports traces when present', function() { - var specFailure = container.querySelectorAll( + const specFailure = container.querySelectorAll( '.jasmine-spec-detail.jasmine-failed' )[2], - debugLogs = specFailure.querySelector('.jasmine-debug-log table'), - rows; + debugLogs = specFailure.querySelector('.jasmine-debug-log table'); expect(debugLogs).toBeTruthy(); - rows = debugLogs.querySelectorAll('tbody tr'); + const rows = debugLogs.querySelectorAll('tbody tr'); expect(rows.length).toEqual(2); }); it('provides links to focus on a failure and each containing suite', function() { - var description = container.querySelector( + const description = container.querySelector( '.jasmine-failures .jasmine-description' ); - var links = description.querySelectorAll('a'); + const links = description.querySelectorAll('a'); expect(description.textContent).toEqual( 'A suite > inner suite > a failing spec' @@ -1637,17 +1647,17 @@ describe('HtmlReporter', function() { }); it('allows switching between failure details and the spec summary', function() { - var menuBar = container.querySelectorAll('.jasmine-bar')[1]; + const menuBar = container.querySelectorAll('.jasmine-bar')[1]; expect(menuBar.getAttribute('class')).not.toMatch(/hidden/); - var link = menuBar.querySelector('a'); + const link = menuBar.querySelector('a'); expect(link.innerHTML).toEqual('Failures'); expect(link.getAttribute('href')).toEqual('#'); }); it("sets the reporter to 'Failures List' mode", function() { - var reporterNode = container.querySelector('.jasmine_html-reporter'); + const reporterNode = container.querySelector('.jasmine_html-reporter'); expect(reporterNode.getAttribute('class')).toMatch( 'jasmine-failure-list' ); @@ -1713,7 +1723,7 @@ 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() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1736,14 +1746,14 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var alertBar = container.querySelector('.jasmine-overall-result'); + const alertBar = container.querySelector('.jasmine-overall-result'); expect(alertBar).toHaveClass('jasmine-passed'); }); }); describe("When the jasmineDone event's overallStatus is 'failed'", function() { it('has class jasmine-failed', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1766,14 +1776,14 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var alertBar = container.querySelector('.jasmine-overall-result'); + const alertBar = container.querySelector('.jasmine-overall-result'); expect(alertBar).toHaveClass('jasmine-failed'); }); }); describe("When the jasmineDone event's overallStatus is 'incomplete'", function() { it('has class jasmine-incomplete', function() { - var container = document.createElement('div'), + const container = document.createElement('div'), getContainer = function() { return container; }, @@ -1797,7 +1807,7 @@ describe('HtmlReporter', function() { failedExpectations: [] }); - var alertBar = container.querySelector('.jasmine-overall-result'); + const alertBar = container.querySelector('.jasmine-overall-result'); expect(alertBar).toHaveClass('jasmine-incomplete'); expect(alertBar.textContent).toContain('Incomplete: because nope'); }); diff --git a/spec/html/HtmlSpecFilterSpec.js b/spec/html/HtmlSpecFilterSpec.js index 887ee07c..8fa9a05d 100644 --- a/spec/html/HtmlSpecFilterSpec.js +++ b/spec/html/HtmlSpecFilterSpec.js @@ -1,13 +1,13 @@ describe('jasmineUnderTest.HtmlSpecFilter', function() { it('should match when no string is provided', function() { - var specFilter = new jasmineUnderTest.HtmlSpecFilter(); + const specFilter = new jasmineUnderTest.HtmlSpecFilter(); expect(specFilter.matches('foo')).toBe(true); expect(specFilter.matches('*bar')).toBe(true); }); it('should only match the provided string', function() { - var specFilter = new jasmineUnderTest.HtmlSpecFilter({ + const specFilter = new jasmineUnderTest.HtmlSpecFilter({ filterString: function() { return 'foo'; } diff --git a/spec/html/MatchersHtmlSpec.js b/spec/html/MatchersHtmlSpec.js index a1cb8d24..1067a8fb 100644 --- a/spec/html/MatchersHtmlSpec.js +++ b/spec/html/MatchersHtmlSpec.js @@ -1,5 +1,5 @@ describe('MatchersSpec - HTML Dependent', function() { - var env, spec; + let env, spec; beforeEach(function() { env = new jasmineUnderTest.Env(); @@ -32,8 +32,8 @@ describe('MatchersSpec - HTML Dependent', function() { } xit('toEqual with DOM nodes', function() { - var nodeA = document.createElement('div'); - var nodeB = document.createElement('div'); + const nodeA = document.createElement('div'); + const nodeB = document.createElement('div'); expect(match(nodeA).toEqual(nodeA)).toPass(); expect(match(nodeA).toEqual(nodeB)).toFail(); }); diff --git a/spec/html/PrettyPrintHtmlSpec.js b/spec/html/PrettyPrintHtmlSpec.js index 738753ba..a5e67b28 100644 --- a/spec/html/PrettyPrintHtmlSpec.js +++ b/spec/html/PrettyPrintHtmlSpec.js @@ -1,21 +1,21 @@ describe('PrettyPrinter (HTML Dependent)', function() { it('should stringify non-element HTML nodes properly', function() { - var sampleNode = document.createTextNode(''); - var pp = jasmineUnderTest.makePrettyPrinter(); + const sampleNode = document.createTextNode(''); + const pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(sampleNode)).toEqual('HTMLNode'); expect(pp({ foo: sampleNode })).toEqual('Object({ foo: HTMLNode })'); }); it('should stringify empty HTML elements as their opening tags', function() { - var simple = document.createElement('div'); - var pp = jasmineUnderTest.makePrettyPrinter(); + const simple = document.createElement('div'); + const pp = jasmineUnderTest.makePrettyPrinter(); simple.className = 'foo'; expect(pp(simple)).toEqual('
'); }); it('should stringify non-empty HTML elements as tags with placeholders', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var nonEmpty = document.createElement('div'); + const pp = jasmineUnderTest.makePrettyPrinter(); + const nonEmpty = document.createElement('div'); nonEmpty.className = 'foo'; nonEmpty.innerHTML = '

Irrelevant

'; expect(pp(nonEmpty)).toEqual('
...
'); @@ -23,11 +23,12 @@ describe('PrettyPrinter (HTML Dependent)', function() { it("should print Firefox's wrapped native objects correctly", function() { if (jasmine.getEnv().firefoxVersion) { - var pp = jasmineUnderTest.makePrettyPrinter(); + const pp = jasmineUnderTest.makePrettyPrinter(); + let err; try { new CustomEvent(); } catch (e) { - var err = e; + err = e; } // Different versions of FF produce different error messages. expect(pp(err)).toMatch( @@ -37,8 +38,8 @@ describe('PrettyPrinter (HTML Dependent)', function() { }); it('should stringify HTML element with text and attributes', function() { - var pp = jasmineUnderTest.makePrettyPrinter(); - var el = document.createElement('div'); + const pp = jasmineUnderTest.makePrettyPrinter(); + const el = document.createElement('div'); el.setAttribute('things', 'foo'); el.innerHTML = 'foo'; expect(pp(el)).toEqual('
...
'); diff --git a/spec/html/QueryStringSpec.js b/spec/html/QueryStringSpec.js index de2f5721..bc8d1770 100644 --- a/spec/html/QueryStringSpec.js +++ b/spec/html/QueryStringSpec.js @@ -1,7 +1,7 @@ describe('QueryString', function() { describe('#navigateWithNewParam', function() { it('sets the query string to include the given key/value pair', function() { - var windowLocation = { + const windowLocation = { search: '' }, queryString = new jasmineUnderTest.QueryString({ @@ -16,7 +16,7 @@ describe('QueryString', function() { }); it('leaves existing params alone', function() { - var windowLocation = { + const windowLocation = { search: '?foo=bar' }, queryString = new jasmineUnderTest.QueryString({ @@ -34,7 +34,7 @@ describe('QueryString', function() { describe('#fullStringWithNewParam', function() { it('gets the query string including the given key/value pair', function() { - var windowLocation = { + const windowLocation = { search: '?foo=bar' }, queryString = new jasmineUnderTest.QueryString({ @@ -43,7 +43,7 @@ describe('QueryString', function() { } }); - var result = queryString.fullStringWithNewParam('baz', 'quux'); + const result = queryString.fullStringWithNewParam('baz', 'quux'); expect(result).toMatch(/foo=bar/); expect(result).toMatch(/baz=quux/); @@ -52,7 +52,7 @@ describe('QueryString', function() { describe('#getParam', function() { it('returns the value of the requested key', function() { - var windowLocation = { + const windowLocation = { search: '?baz=quux%20corge' }, queryString = new jasmineUnderTest.QueryString({ @@ -65,7 +65,7 @@ describe('QueryString', function() { }); it('returns null if the key is not present', function() { - var windowLocation = { + const windowLocation = { search: '' }, queryString = new jasmineUnderTest.QueryString({ diff --git a/spec/html/ResultsNodeSpec.js b/spec/html/ResultsNodeSpec.js index 0a57a8fc..1869c4a4 100644 --- a/spec/html/ResultsNodeSpec.js +++ b/spec/html/ResultsNodeSpec.js @@ -1,6 +1,6 @@ describe('ResultsNode', function() { it('wraps a result', function() { - var fakeResult = { + const fakeResult = { id: 123, message: 'foo' }, @@ -11,7 +11,7 @@ describe('ResultsNode', function() { }); it('can add children with a type', function() { - var fakeResult = { + const fakeResult = { id: 123, message: 'foo' }, @@ -29,7 +29,7 @@ describe('ResultsNode', function() { }); it('has a pointer back to its parent ResultNode', function() { - var fakeResult = { + const fakeResult = { id: 123, message: 'foo' }, @@ -45,7 +45,7 @@ describe('ResultsNode', function() { }); it('can provide the most recent child', function() { - var fakeResult = { + const fakeResult = { id: 123, message: 'foo' }, diff --git a/spec/html/SpyRegistryHtmlSpec.js b/spec/html/SpyRegistryHtmlSpec.js index bad2d2bd..3298fedc 100644 --- a/spec/html/SpyRegistryHtmlSpec.js +++ b/spec/html/SpyRegistryHtmlSpec.js @@ -4,7 +4,7 @@ describe('Spy Registry browser-specific behavior', function() { } it('can spy on and unspy window.onerror', function() { - var spies = [], + const spies = [], spyRegistry = new jasmineUnderTest.SpyRegistry({ currentSpies: function() { return spies; diff --git a/spec/npmPackage/npmPackageSpec.js b/spec/npmPackage/npmPackageSpec.js index f5995c92..a47067a0 100644 --- a/spec/npmPackage/npmPackageSpec.js +++ b/spec/npmPackage/npmPackageSpec.js @@ -1,18 +1,21 @@ describe('npm package', function() { - var path = require('path'), + const path = require('path'), temp = require('temp').track(), fs = require('fs'); beforeAll(function() { - var shell = require('shelljs'), + const shell = require('shelljs'), pack = shell.exec('npm pack', { silent: true }); this.tarball = pack.stdout.split('\n')[0]; this.tmpDir = temp.mkdirSync(); // automatically deleted on exit - var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { - silent: true - }); + const untar = shell.exec( + 'tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, + { + silent: true + } + ); expect(untar.code).toBe(0); this.packagedCore = require(path.join( @@ -26,7 +29,7 @@ describe('npm package', function() { toExistInPath: function() { return { compare: function(actual, expected) { - var fullPath = path.resolve(expected, actual); + const fullPath = path.resolve(expected, actual); return { pass: fs.existsSync(fullPath) }; @@ -58,7 +61,7 @@ describe('npm package', function() { 'jasmine-html.js' ]); - var packagedCore = this.packagedCore; + const packagedCore = this.packagedCore; this.packagedCore.files.jsFiles.forEach(function(fileName) { expect(fileName).toExistInPath(packagedCore.files.path); }); @@ -67,7 +70,7 @@ describe('npm package', function() { it('has cssFiles', function() { expect(this.packagedCore.files.cssFiles).toEqual(['jasmine.css']); - var packagedCore = this.packagedCore; + const packagedCore = this.packagedCore; this.packagedCore.files.cssFiles.forEach(function(fileName) { expect(fileName).toExistInPath(packagedCore.files.path); }); @@ -77,22 +80,20 @@ describe('npm package', function() { expect(this.packagedCore.files.bootFiles).toEqual(['boot0.js', 'boot1.js']); expect(this.packagedCore.files.nodeBootFiles).toEqual(['node_boot.js']); - var packagedCore = this.packagedCore; - this.packagedCore.files.bootFiles.forEach(function(fileName) { - expect(fileName).toExistInPath(packagedCore.files.bootDir); - }); + for (const fileName of this.packagedCore.files.bootFiles) { + expect(fileName).toExistInPath(this.packagedCore.files.bootDir); + } - var packagedCore = this.packagedCore; - this.packagedCore.files.nodeBootFiles.forEach(function(fileName) { - expect(fileName).toExistInPath(packagedCore.files.bootDir); - }); + for (const fileName of this.packagedCore.files.nodeBootFiles) { + expect(fileName).toExistInPath(this.packagedCore.files.bootDir); + } }); it('has an imagesDir', function() { expect(this.packagedCore.files.imagesDir).toEqual( fs.realpathSync(path.resolve(this.tmpDir, 'package/images')) ); - var images = fs.readdirSync(path.resolve(this.tmpDir, 'package/images')); + const images = fs.readdirSync(path.resolve(this.tmpDir, 'package/images')); expect(images).toContain('jasmine-horizontal.png'); expect(images).toContain('jasmine-horizontal.svg'); @@ -109,12 +110,12 @@ describe('npm package', function() { }); it('does not have any unexpected files in the root directory', function() { - var files = fs.readdirSync(this.tmpDir); + const files = fs.readdirSync(this.tmpDir); expect(files).toEqual(['package']); }); it('does not have any unexpected files in the package directory', function() { - var files = fs.readdirSync(path.resolve(this.tmpDir, 'package')); + const files = fs.readdirSync(path.resolve(this.tmpDir, 'package')); files.sort(); expect(files).toEqual([ 'MIT.LICENSE', @@ -126,23 +127,20 @@ describe('npm package', function() { }); it('only has images in the images dir', function() { - var files = fs.readdirSync(path.resolve(this.tmpDir, 'package/images')), - i; + const files = fs.readdirSync(path.resolve(this.tmpDir, 'package/images')); - for (i = 0; i < files.length; i++) { + for (let i = 0; i < files.length; i++) { expect(files[i]).toMatch(/\.(svg|png)$/); } }); it('only has JS and CSS files in the lib dir', function() { - var files = [], - i; + const files = []; function getFiles(dir) { - var dirents = fs.readdirSync(dir, { withFileTypes: true }), - j; + const dirents = fs.readdirSync(dir, { withFileTypes: true }); - for (j = 0; j < dirents.length; j++) { + for (let j = 0; j < dirents.length; j++) { const dirent = dirents[j]; if (dirent.isDirectory()) { @@ -155,7 +153,7 @@ describe('npm package', function() { getFiles(path.resolve(this.tmpDir, 'package/lib')); - for (i = 0; i < files.length; i++) { + for (let i = 0; i < files.length; i++) { expect(files[i]).toMatch(/\.(js|css)$/); } }); diff --git a/spec/performance/large_object_test.js b/spec/performance/large_object_test.js index 65b28863..dfc5b097 100644 --- a/spec/performance/large_object_test.js +++ b/spec/performance/large_object_test.js @@ -1,14 +1,13 @@ describe('Printing a big object', function() { - var bigObject; function rand(upper) { return Math.round(upper * Math.random()); } function generateObject(level) { - var object = {}; + const object = {}; - for (var i = 0; i < 50; i++) { - var decide = rand(2); + for (let i = 0; i < 50; i++) { + const decide = rand(2); switch (decide) { case 0: object['cycle' + i] = object; @@ -28,7 +27,7 @@ describe('Printing a big object', function() { } it('takes a reasonable amount of time', function() { - bigObject = generateObject(0); + const bigObject = generateObject(0); expect(jasmineUnderTest.pp(bigObject)).toMatch(/cycle/); }); }); diff --git a/spec/performance/performance_test.js b/spec/performance/performance_test.js index a9139bdd..ad6b5ddc 100644 --- a/spec/performance/performance_test.js +++ b/spec/performance/performance_test.js @@ -1,5 +1,5 @@ describe('performance', function() { - for (var i = 0; i < 10000; i++) { + for (let i = 0; i < 10000; i++) { it('should pass', function() { expect(true).toBe(true); }); diff --git a/spec/support/localJasmineBrowser.js b/spec/support/localJasmineBrowser.js index d08261ee..ab451de7 100644 --- a/spec/support/localJasmineBrowser.js +++ b/spec/support/localJasmineBrowser.js @@ -1,10 +1,10 @@ -var path = require('path'), +const path = require('path'), jasmineBrowser = require('jasmine-browser-runner'), jasmineCore = require('../../lib/jasmine-core.js'); -var configFile = process.argv[2] || 'jasmine-browser.js'; +const configFile = process.argv[2] || 'jasmine-browser.js'; -var config = require(path.resolve('spec/support', configFile)); +const config = require(path.resolve('spec/support', configFile)); config.jasmineCore = jasmineCore; config.batchReporter = true;