From 4e2f703615eacecf5054dd2b1f20a9da69f14f38 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Wed, 1 Jul 2020 17:28:45 -0700 Subject: [PATCH] Check for syntax and standard library objects that don't work in IE --- package.json | 17 +++- spec/.eslintrc.js | 4 + spec/core/AsyncExpectationSpec.js | 1 + spec/core/PrettyPrintSpec.js | 8 +- spec/core/UtilSpec.js | 2 +- spec/core/asymmetric_equality/AnySpec.js | 12 +-- spec/core/asymmetric_equality/AnythingSpec.js | 8 +- spec/core/asymmetric_equality/EmptySpec.js | 12 +-- .../asymmetric_equality/MapContainingSpec.js | 1 + spec/core/asymmetric_equality/NotEmptySpec.js | 12 +-- .../asymmetric_equality/SetContainingSpec.js | 1 + spec/core/baseSpec.js | 2 +- .../integration/CustomAsyncMatchersSpec.js | 1 + spec/core/integration/EnvSpec.js | 10 +-- spec/core/integration/MatchersSpec.js | 26 +++--- spec/core/matchers/async/toBePendingSpec.js | 1 + spec/core/matchers/async/toBeRejectedSpec.js | 1 + .../async/toBeRejectedWithErrorSpec.js | 1 + .../matchers/async/toBeRejectedWithSpec.js | 1 + spec/core/matchers/async/toBeResolvedSpec.js | 1 + .../core/matchers/async/toBeResolvedToSpec.js | 1 + spec/core/matchers/matchersUtilSpec.js | 69 ++++++++-------- spec/core/matchers/toEqualSpec.js | 80 +++++++++---------- spec/core/matchers/toHaveSizeSpec.js | 1 + spec/helpers/checkForMap.js | 1 + spec/helpers/checkForSet.js | 1 + spec/helpers/checkForSymbol.js | 1 + spec/helpers/checkForTypedArrays.js | 1 + .../asymmetricEqualityTesterArgCompatShim.js | 2 +- src/core/matchers/async/toBePending.js | 3 +- src/core/matchers/toHaveSize.js | 2 +- 31 files changed, 159 insertions(+), 125 deletions(-) diff --git a/package.json b/package.json index fb1d215d..a7d89f70 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "acorn": "^6.0.0", "ejs": "^2.5.5", "eslint": "7.3.1", + "eslint-plugin-compat": "^3.8.0", "express": "^4.16.4", "fast-check": "^1.21.0", "fast-glob": "^2.2.6", @@ -52,6 +53,12 @@ "singleQuote": true }, "eslintConfig": { + "extends": [ + "plugin:compat/recommended" + ], + "parserOptions": { + "ecmaVersion": 5 + }, "rules": { "quotes": [ "error", @@ -81,5 +88,13 @@ ], "space-before-blocks": "error" } - } + }, + "browserslist": [ + "Safari >= 8", + "last 2 Chrome versions", + "last 2 Firefox versions", + "Firefox 68", + "last 2 Edge versions", + "IE >= 10" + ] } diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js index 969a4efd..bfbec213 100644 --- a/spec/.eslintrc.js +++ b/spec/.eslintrc.js @@ -1,4 +1,8 @@ module.exports = { + "ignorePatterns": [ + "support/ci.js", + "support/jasmine-browser.js" + ], rules: { // Relax rules for now to allow for the quirks of the test suite // TODO: We should probably remove these & fix the resulting errors diff --git a/spec/core/AsyncExpectationSpec.js b/spec/core/AsyncExpectationSpec.js index 40f63731..94e2438c 100644 --- a/spec/core/AsyncExpectationSpec.js +++ b/spec/core/AsyncExpectationSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('AsyncExpectation', function() { beforeEach(function() { jasmineUnderTest.Expectation.addAsyncCoreMatchers( diff --git a/spec/core/PrettyPrintSpec.js b/spec/core/PrettyPrintSpec.js index 6c43cbd4..de6a11d6 100644 --- a/spec/core/PrettyPrintSpec.js +++ b/spec/core/PrettyPrintSpec.js @@ -19,7 +19,7 @@ describe('PrettyPrinter', function() { describe('stringify sets', function() { it('should stringify sets properly', function() { jasmine.getEnv().requireFunctioningSets(); - var set = new Set(); + var set = new Set(); // eslint-disable-line compat/compat set.add(1); set.add(2); var pp = jasmineUnderTest.makePrettyPrinter(); @@ -32,7 +32,7 @@ describe('PrettyPrinter', function() { try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; - var set = new Set(); + var set = new Set(); // eslint-disable-line compat/compat set.add('a'); set.add('b'); set.add('c'); @@ -47,7 +47,7 @@ describe('PrettyPrinter', function() { describe('stringify maps', function() { it('should stringify maps properly', function() { jasmine.getEnv().requireFunctioningMaps(); - var map = new Map(); + var map = new Map(); // eslint-disable-line compat/compat map.set(1, 2); var pp = jasmineUnderTest.makePrettyPrinter(); expect(pp(map)).toEqual('Map( [ 1, 2 ] )'); @@ -59,7 +59,7 @@ describe('PrettyPrinter', function() { try { jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2; - var map = new Map(); + var map = new Map(); // eslint-disable-line compat/compat map.set('a', 1); map.set('b', 2); map.set('c', 3); diff --git a/spec/core/UtilSpec.js b/spec/core/UtilSpec.js index 759ef8ce..8e05c6ab 100644 --- a/spec/core/UtilSpec.js +++ b/spec/core/UtilSpec.js @@ -40,7 +40,7 @@ describe('jasmineUnderTest.util', function() { beforeEach(function() { jasmine.getEnv().requirePromises(); - mockNativePromise = new Promise(function(res, rej) {}); + mockNativePromise = new Promise(function(res, rej) {}); // eslint-disable-line compat/compat mockPromiseLikeObject = new mockPromiseLike(); }); diff --git a/spec/core/asymmetric_equality/AnySpec.js b/spec/core/asymmetric_equality/AnySpec.js index 1739ae6f..8e28c306 100644 --- a/spec/core/asymmetric_equality/AnySpec.js +++ b/spec/core/asymmetric_equality/AnySpec.js @@ -34,7 +34,7 @@ describe("Any", function() { var any = new jasmineUnderTest.Any(Map); - expect(any.asymmetricMatch(new Map())).toBe(true); + expect(any.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat }); it("matches a Set", function() { @@ -42,23 +42,23 @@ describe("Any", function() { var any = new jasmineUnderTest.Any(Set); - expect(any.asymmetricMatch(new Set())).toBe(true); + expect(any.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat }); it("matches a TypedArray", function() { jasmine.getEnv().requireFunctioningTypedArrays(); - var any = new jasmineUnderTest.Any(Uint32Array); + var any = new jasmineUnderTest.Any(Uint32Array); // eslint-disable-line compat/compat - expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); + expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat }); it("matches a Symbol", function() { jasmine.getEnv().requireFunctioningSymbols(); - var any = new jasmineUnderTest.Any(Symbol); + var any = new jasmineUnderTest.Any(Symbol); // eslint-disable-line compat/compat - expect(any.asymmetricMatch(Symbol())).toBe(true); + expect(any.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat }); it("matches another constructed object", function() { diff --git a/spec/core/asymmetric_equality/AnythingSpec.js b/spec/core/asymmetric_equality/AnythingSpec.js index 216757eb..4e251b91 100644 --- a/spec/core/asymmetric_equality/AnythingSpec.js +++ b/spec/core/asymmetric_equality/AnythingSpec.js @@ -28,7 +28,7 @@ describe("Anything", function() { var anything = new jasmineUnderTest.Anything(); - expect(anything.asymmetricMatch(new Map())).toBe(true); + expect(anything.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat }); it("matches a Set", function() { @@ -36,7 +36,7 @@ describe("Anything", function() { var anything = new jasmineUnderTest.Anything(); - expect(anything.asymmetricMatch(new Set())).toBe(true); + expect(anything.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat }); it("matches a TypedArray", function() { @@ -44,7 +44,7 @@ describe("Anything", function() { var anything = new jasmineUnderTest.Anything(); - expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true); + expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat }); it("matches a Symbol", function() { @@ -52,7 +52,7 @@ describe("Anything", function() { var anything = new jasmineUnderTest.Anything(); - expect(anything.asymmetricMatch(Symbol())).toBe(true); + expect(anything.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat }); it("doesn't match undefined", function() { diff --git a/spec/core/asymmetric_equality/EmptySpec.js b/spec/core/asymmetric_equality/EmptySpec.js index 902b5001..48271ce5 100644 --- a/spec/core/asymmetric_equality/EmptySpec.js +++ b/spec/core/asymmetric_equality/EmptySpec.js @@ -24,20 +24,20 @@ describe("Empty", function () { it("matches an empty map", function () { jasmine.getEnv().requireFunctioningMaps(); var empty = new jasmineUnderTest.Empty(); - var fullMap = new Map(); + var fullMap = new Map(); // eslint-disable-line compat/compat fullMap.set('thing', 2); - expect(empty.asymmetricMatch(new Map())).toBe(true); + expect(empty.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat expect(empty.asymmetricMatch(fullMap)).toBe(false); }); it("matches an empty set", function () { jasmine.getEnv().requireFunctioningSets(); var empty = new jasmineUnderTest.Empty(); - var fullSet = new Set(); + var fullSet = new Set(); // eslint-disable-line compat/compat fullSet.add(3); - expect(empty.asymmetricMatch(new Set())).toBe(true); + expect(empty.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat expect(empty.asymmetricMatch(fullSet)).toBe(false); }); @@ -45,7 +45,7 @@ describe("Empty", function () { jasmine.getEnv().requireFunctioningTypedArrays(); var empty = new jasmineUnderTest.Empty(); - expect(empty.asymmetricMatch(new Int16Array())).toBe(true); - expect(empty.asymmetricMatch(new Int16Array([1,2]))).toBe(false); + expect(empty.asymmetricMatch(new Int16Array())).toBe(true); // eslint-disable-line compat/compat + expect(empty.asymmetricMatch(new Int16Array([1,2]))).toBe(false); // eslint-disable-line compat/compat }); }); diff --git a/spec/core/asymmetric_equality/MapContainingSpec.js b/spec/core/asymmetric_equality/MapContainingSpec.js index c9ea83a6..dc89218d 100644 --- a/spec/core/asymmetric_equality/MapContainingSpec.js +++ b/spec/core/asymmetric_equality/MapContainingSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('MapContaining', function() { function MapI(iterable) { // for IE11 var map = new Map(); diff --git a/spec/core/asymmetric_equality/NotEmptySpec.js b/spec/core/asymmetric_equality/NotEmptySpec.js index 04c05966..d00ee013 100644 --- a/spec/core/asymmetric_equality/NotEmptySpec.js +++ b/spec/core/asymmetric_equality/NotEmptySpec.js @@ -24,9 +24,9 @@ describe("NotEmpty", function () { it("matches a non empty map", function () { jasmine.getEnv().requireFunctioningMaps(); var notEmpty = new jasmineUnderTest.NotEmpty(); - var fullMap = new Map(); + var fullMap = new Map(); // eslint-disable-line compat/compat fullMap.set('one', 1); - var emptyMap = new Map(); + var emptyMap = new Map(); // eslint-disable-line compat/compat expect(notEmpty.asymmetricMatch(fullMap)).toBe(true); expect(notEmpty.asymmetricMatch(emptyMap)).toBe(false); @@ -35,9 +35,9 @@ describe("NotEmpty", function () { it("matches a non empty set", function () { jasmine.getEnv().requireFunctioningSets(); var notEmpty = new jasmineUnderTest.NotEmpty(); - var filledSet = new Set(); + var filledSet = new Set(); // eslint-disable-line compat/compat filledSet.add(1); - var emptySet = new Set(); + var emptySet = new Set(); // eslint-disable-line compat/compat expect(notEmpty.asymmetricMatch(filledSet)).toBe(true); expect(notEmpty.asymmetricMatch(emptySet)).toBe(false); @@ -47,7 +47,7 @@ describe("NotEmpty", function () { jasmine.getEnv().requireFunctioningTypedArrays(); var notEmpty = new jasmineUnderTest.NotEmpty(); - expect(notEmpty.asymmetricMatch(new Int16Array([1,2,3]))).toBe(true); - expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false); + expect(notEmpty.asymmetricMatch(new Int16Array([1,2,3]))).toBe(true); // eslint-disable-line compat/compat + expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false); // eslint-disable-line compat/compat }); }); diff --git a/spec/core/asymmetric_equality/SetContainingSpec.js b/spec/core/asymmetric_equality/SetContainingSpec.js index 50ee9d5b..3f7b1b16 100644 --- a/spec/core/asymmetric_equality/SetContainingSpec.js +++ b/spec/core/asymmetric_equality/SetContainingSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('SetContaining', function() { function SetI(iterable) { // for IE11 var set = new Set(); diff --git a/spec/core/baseSpec.js b/spec/core/baseSpec.js index b85721b9..fbdf9d9d 100644 --- a/spec/core/baseSpec.js +++ b/spec/core/baseSpec.js @@ -55,7 +55,7 @@ describe('base helpers', function() { describe('isSet', function() { it('returns true when the object is a Set', function() { jasmine.getEnv().requireFunctioningSets(); - expect(jasmineUnderTest.isSet(new Set())).toBe(true); + expect(jasmineUnderTest.isSet(new Set())).toBe(true); // eslint-disable-line compat/compat }); it('returns false when the object is not a Set', function() { diff --git a/spec/core/integration/CustomAsyncMatchersSpec.js b/spec/core/integration/CustomAsyncMatchersSpec.js index e1a8286c..1b60bb45 100644 --- a/spec/core/integration/CustomAsyncMatchersSpec.js +++ b/spec/core/integration/CustomAsyncMatchersSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('Custom Async Matchers (Integration)', function() { var env; diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index c811c9bf..090bb54c 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -2581,7 +2581,7 @@ describe("Env integration", function() { function fail(innerDone) { var resolve; - var p = new Promise(function(res, rej) { resolve = res }); + var p = new Promise(function(res, rej) { resolve = res }); // eslint-disable-line compat/compat env.expectAsync(p).toBeRejected().then(innerDone); resolve(); } @@ -2613,7 +2613,7 @@ describe("Env integration", function() { env.it('has an async failure', function() { env.addCustomEqualityTester(function() { return true; }); - var p = Promise.resolve('something'); + var p = Promise.resolve('something'); // eslint-disable-line compat/compat return env.expectAsync(p).toBeResolvedTo('something else'); }); @@ -2639,7 +2639,7 @@ describe("Env integration", function() { env.it('has an async failure', function() { env.addCustomEqualityTester(function() { return true; }); - var p = Promise.resolve(); + var p = Promise.resolve(); // eslint-disable-line compat/compat return env.expectAsync(p).toBeRejected(); }); @@ -2650,7 +2650,7 @@ describe("Env integration", function() { jasmine.getEnv().requirePromises(); var resolve, - promise = new Promise(function(res) { resolve = res; }); + promise = new Promise(function(res) { resolve = res; }); // eslint-disable-line compat/compat env.describe('a suite', function() { env.it('does not wait', function() { @@ -2698,7 +2698,7 @@ describe("Env integration", function() { jasmine.getEnv().requirePromises(); var resolve, - promise = new Promise(function(res) { resolve = res; }); + promise = new Promise(function(res) { resolve = res; }); // eslint-disable-line compat/compat env.describe('a suite', function() { env.afterAll(function() { diff --git a/spec/core/integration/MatchersSpec.js b/spec/core/integration/MatchersSpec.js index 5e253e08..92b7307f 100644 --- a/spec/core/integration/MatchersSpec.js +++ b/spec/core/integration/MatchersSpec.js @@ -335,11 +335,11 @@ describe('Matchers (Integration)', function() { describe('toBeResolved', function() { verifyPassesAsync(function(env) { - return env.expectAsync(Promise.resolve()).toBeResolved(); + return env.expectAsync(Promise.resolve()).toBeResolved(); // eslint-disable-line compat/compat }); verifyFailsAsync(function(env) { - return env.expectAsync(Promise.reject()).toBeResolved(); + return env.expectAsync(Promise.reject()).toBeResolved(); // eslint-disable-line compat/compat }); }); @@ -348,11 +348,11 @@ describe('Matchers (Integration)', function() { env.addCustomEqualityTester(function(a, b) { return a.toString() === b.toString(); }); - return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5); + return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5); // eslint-disable-line compat/compat }); verifyFailsAsync(function(env) { - return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar'); + return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar'); // eslint-disable-line compat/compat }); verifyFailsWithCustomObjectFormattersAsync({ @@ -360,7 +360,7 @@ describe('Matchers (Integration)', function() { return '|' + val + '|'; }, expectations: function(env) { - return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y'); + return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y'); // eslint-disable-line compat/compat }, expectedMessage: 'Expected a promise to be resolved to |y| ' + 'but it was resolved to |x|.' @@ -369,11 +369,11 @@ describe('Matchers (Integration)', function() { describe('toBeRejected', function() { verifyPassesAsync(function(env) { - return env.expectAsync(Promise.reject('nope')).toBeRejected(); + return env.expectAsync(Promise.reject('nope')).toBeRejected(); // eslint-disable-line compat/compat }); verifyFailsAsync(function(env) { - return env.expectAsync(Promise.resolve()).toBeRejected(); + return env.expectAsync(Promise.resolve()).toBeRejected(); // eslint-disable-line compat/compat }); }); @@ -382,11 +382,11 @@ describe('Matchers (Integration)', function() { env.addCustomEqualityTester(function(a, b) { return a.toString() === b.toString(); }); - return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5); + return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5); // eslint-disable-line compat/compat }); verifyFailsAsync(function(env) { - return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope'); + return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope'); // eslint-disable-line compat/compat }); verifyFailsWithCustomObjectFormattersAsync({ @@ -394,7 +394,7 @@ describe('Matchers (Integration)', function() { return '|' + val + '|'; }, expectations: function(env) { - return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y'); + return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y'); // eslint-disable-line compat/compat }, expectedMessage: 'Expected a promise to be rejected with |y| ' + 'but it was rejected with |x|.' @@ -403,11 +403,11 @@ describe('Matchers (Integration)', function() { describe('toBeRejectedWithError', function() { verifyPassesAsync(function(env) { - return env.expectAsync(Promise.reject(new Error())).toBeRejectedWithError(Error); + return env.expectAsync(Promise.reject(new Error())).toBeRejectedWithError(Error); // eslint-disable-line compat/compat }); verifyFailsAsync(function(env) { - return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error); + return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error); // eslint-disable-line compat/compat }); verifyFailsWithCustomObjectFormattersAsync({ @@ -415,7 +415,7 @@ describe('Matchers (Integration)', function() { return '|' + val + '|'; }, expectations: function(env) { - return env.expectAsync(Promise.reject('foo')).toBeRejectedWithError('foo'); + return env.expectAsync(Promise.reject('foo')).toBeRejectedWithError('foo'); // eslint-disable-line compat/compat }, expectedMessage: 'Expected a promise to be rejected with Error: |foo| ' + 'but it was rejected with |foo|.' diff --git a/spec/core/matchers/async/toBePendingSpec.js b/spec/core/matchers/async/toBePendingSpec.js index 318e22b7..285414f1 100644 --- a/spec/core/matchers/async/toBePendingSpec.js +++ b/spec/core/matchers/async/toBePendingSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('toBePending', function() { it('passes if the actual promise is pending', function() { jasmine.getEnv().requirePromises(); diff --git a/spec/core/matchers/async/toBeRejectedSpec.js b/spec/core/matchers/async/toBeRejectedSpec.js index 61bd2a5a..6ecf9ebc 100644 --- a/spec/core/matchers/async/toBeRejectedSpec.js +++ b/spec/core/matchers/async/toBeRejectedSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('toBeRejected', function() { it('passes if the actual is rejected', function() { jasmine.getEnv().requirePromises(); diff --git a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js index 71c53d55..d09a05fd 100644 --- a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('#toBeRejectedWithError', function () { it('passes when Error type matches', function () { jasmine.getEnv().requirePromises(); diff --git a/spec/core/matchers/async/toBeRejectedWithSpec.js b/spec/core/matchers/async/toBeRejectedWithSpec.js index 2c02a03a..69003c59 100644 --- a/spec/core/matchers/async/toBeRejectedWithSpec.js +++ b/spec/core/matchers/async/toBeRejectedWithSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('#toBeRejectedWith', function () { it('should return true if the promise is rejected with the expected value', function () { jasmine.getEnv().requirePromises(); diff --git a/spec/core/matchers/async/toBeResolvedSpec.js b/spec/core/matchers/async/toBeResolvedSpec.js index a6ab25ba..8dbff1c9 100644 --- a/spec/core/matchers/async/toBeResolvedSpec.js +++ b/spec/core/matchers/async/toBeResolvedSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('toBeResolved', function() { it('passes if the actual is resolved', function() { jasmine.getEnv().requirePromises(); diff --git a/spec/core/matchers/async/toBeResolvedToSpec.js b/spec/core/matchers/async/toBeResolvedToSpec.js index b721c89e..ee57abe1 100644 --- a/spec/core/matchers/async/toBeResolvedToSpec.js +++ b/spec/core/matchers/async/toBeResolvedToSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('#toBeResolvedTo', function() { it('passes if the promise is resolved to the expected value', function() { jasmine.getEnv().requirePromises(); diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index 10bd0ec0..e3ee9e8c 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -282,8 +282,8 @@ describe("matchersUtil", function() { it("passes for equivalent Promises (GitHub issue #1314)", function() { if (typeof Promise === 'undefined') { return; } - var p1 = new Promise(function () {}), - p2 = new Promise(function () {}), + var p1 = new Promise(function () {}), // eslint-disable-line compat/compat + p2 = new Promise(function () {}), // eslint-disable-line compat/compat matchersUtil = new jasmineUnderTest.MatchersUtil(); expect(matchersUtil.equals(p1, p1)).toBe(true); @@ -418,10 +418,10 @@ describe("matchersUtil", function() { jasmine.getEnv().requireFunctioningMaps(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var obj = new Map(); + var obj = new Map(); // eslint-disable-line compat/compat obj.set(1, 2); obj.set('foo', 'bar'); - var containing = new jasmineUnderTest.MapContaining(new Map()); + var containing = new jasmineUnderTest.MapContaining(new Map()); // eslint-disable-line compat/compat containing.sample.set('foo', 'bar'); expect(matchersUtil.equals(obj, containing)).toBe(true); @@ -432,10 +432,10 @@ describe("matchersUtil", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var obj = new Set(); + var obj = new Set(); // eslint-disable-line compat/compat obj.add(1); obj.add('foo'); - var containing = new jasmineUnderTest.SetContaining(new Set()); + var containing = new jasmineUnderTest.SetContaining(new Set()); // eslint-disable-line compat/compat containing.sample.add(1); expect(matchersUtil.equals(obj, containing)).toBe(true); @@ -603,17 +603,17 @@ describe("matchersUtil", function() { it("passes when comparing two empty sets", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - expect(matchersUtil.equals(new Set(), new Set())).toBe(true); + expect(matchersUtil.equals(new Set(), new Set())).toBe(true); // eslint-disable-line compat/compat }); it("passes when comparing identical sets", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + var setA = new Set(); // eslint-disable-line compat/compat setA.add(6); setA.add(5); - var setB = new Set(); + var setB = new Set(); // eslint-disable-line compat/compat setB.add(6); setB.add(5); @@ -624,10 +624,10 @@ describe("matchersUtil", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + var setA = new Set(); // eslint-disable-line compat/compat setA.add(3); setA.add(6); - var setB = new Set(); + var setB = new Set(); // eslint-disable-line compat/compat setB.add(6); setB.add(3); @@ -638,24 +638,23 @@ describe("matchersUtil", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA1 = new Set(); + var setA1 = new Set(); // eslint-disable-line compat/compat setA1.add(['a',3]); setA1.add([6,1]); - var setA2 = new Set(); + var setA2 = new Set(); // eslint-disable-line compat/compat setA1.add(['y',3]); setA1.add([6,1]); - var setA = new Set(); + var setA = new Set(); // eslint-disable-line compat/compat setA.add(setA1); setA.add(setA2); - - var setB1 = new Set(); + var setB1 = new Set(); // eslint-disable-line compat/compat setB1.add([6,1]); setB1.add(['a',3]); - var setB2 = new Set(); + var setB2 = new Set(); // eslint-disable-line compat/compat setB1.add([6,1]); setB1.add(['y',3]); - var setB = new Set(); + var setB = new Set(); // eslint-disable-line compat/compat setB.add(setB1); setB.add(setB2); @@ -666,10 +665,10 @@ describe("matchersUtil", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + var setA = new Set(); // eslint-disable-line compat/compat setA.add([[1,2], [3,4]]); setA.add([[5,6], [7,8]]); - var setB = new Set(); + var setB = new Set(); // eslint-disable-line compat/compat setB.add([[5,6], [7,8]]); setB.add([[1,2], [3,4]]); @@ -679,11 +678,11 @@ describe("matchersUtil", function() { it("fails for sets with different elements", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + var setA = new Set(); // eslint-disable-line compat/compat setA.add(6); setA.add(3); setA.add(5); - var setB = new Set(); + var setB = new Set(); // eslint-disable-line compat/compat setB.add(6); setB.add(4); setB.add(5); @@ -694,10 +693,10 @@ describe("matchersUtil", function() { it("fails for sets of different size", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var setA = new Set(); + var setA = new Set(); // eslint-disable-line compat/compat setA.add(6); setA.add(3); - var setB = new Set(); + var setB = new Set(); // eslint-disable-line compat/compat setB.add(6); setB.add(4); setB.add(5); @@ -708,15 +707,15 @@ describe("matchersUtil", function() { it("passes when comparing two empty maps", function() { jasmine.getEnv().requireFunctioningMaps(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - expect(matchersUtil.equals(new Map(), new Map())).toBe(true); + expect(matchersUtil.equals(new Map(), new Map())).toBe(true); // eslint-disable-line compat/compat }); it("passes when comparing identical maps", function() { jasmine.getEnv().requireFunctioningMaps(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + var mapA = new Map(); // eslint-disable-line compat/compat mapA.set(6, 5); - var mapB = new Map(); + var mapB = new Map(); // eslint-disable-line compat/compat mapB.set(6, 5); expect(matchersUtil.equals(mapA, mapB)).toBe(true); }); @@ -724,10 +723,10 @@ describe("matchersUtil", function() { it("passes when comparing identical maps with different insertion order", function() { jasmine.getEnv().requireFunctioningMaps(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + var mapA = new Map(); // eslint-disable-line compat/compat mapA.set("a", 3); mapA.set(6, 1); - var mapB = new Map(); + var mapB = new Map(); // eslint-disable-line compat/compat mapB.set(6, 1); mapB.set("a", 3); expect(matchersUtil.equals(mapA, mapB)).toBe(true); @@ -736,10 +735,10 @@ describe("matchersUtil", function() { it("fails for maps with different elements", function() { jasmine.getEnv().requireFunctioningMaps(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + var mapA = new Map(); // eslint-disable-line compat/compat mapA.set(6, 3); mapA.set(5, 1); - var mapB = new Map(); + var mapB = new Map(); // eslint-disable-line compat/compat mapB.set(6, 4); mapB.set(5, 1); @@ -749,9 +748,9 @@ describe("matchersUtil", function() { it("fails for maps of different size", function() { jasmine.getEnv().requireFunctioningMaps(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var mapA = new Map(); + var mapA = new Map(); // eslint-disable-line compat/compat mapA.set(6, 3); - var mapB = new Map(); + var mapB = new Map(); // eslint-disable-line compat/compat mapB.set(6, 4); mapB.set(5, 1); expect(matchersUtil.equals(mapA, mapB)).toBe(false); @@ -937,7 +936,7 @@ describe("matchersUtil", function() { var matchersUtil = new jasmineUnderTest.MatchersUtil(); var setItem = {'foo': 'bar'}; - var set = new Set(); + var set = new Set(); // eslint-disable-line compat/compat set.add(setItem); expect(matchersUtil.contains(set, setItem)).toBe(true); @@ -948,7 +947,7 @@ describe("matchersUtil", function() { jasmine.getEnv().requireFunctioningSets(); var matchersUtil = new jasmineUnderTest.MatchersUtil(); - var set = new Set(); + var set = new Set(); // eslint-disable-line compat/compat set.add({'foo': 'bar'}); expect(matchersUtil.contains(set, {'foo': 'bar'})).toBe(false); diff --git a/spec/core/matchers/toEqualSpec.js b/spec/core/matchers/toEqualSpec.js index 3a249364..081329d9 100644 --- a/spec/core/matchers/toEqualSpec.js +++ b/spec/core/matchers/toEqualSpec.js @@ -261,8 +261,8 @@ describe("toEqual", function() { it("reports mismatches between arrays of different types", function() { jasmine.getEnv().requireFunctioningTypedArrays(); - var actual = new Uint32Array([1, 2, 3]), - expected = new Uint16Array([1, 2, 3]), + var actual = new Uint32Array([1, 2, 3]), // eslint-disable-line compat/compat + expected = new Uint16Array([1, 2, 3]), // eslint-disable-line compat/compat message = "Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ]."; expect(compareEquals(actual, expected).message).toEqual(message); @@ -448,9 +448,9 @@ describe("toEqual", function() { it("reports mismatches between Sets", function() { jasmine.getEnv().requireFunctioningSets(); - var actual = new Set(); + var actual = new Set(); // eslint-disable-line compat/compat actual.add(1); - var expected = new Set(); + var expected = new Set(); // eslint-disable-line compat/compat expected.add(2); var message = 'Expected Set( 1 ) to equal Set( 2 ).'; @@ -460,9 +460,9 @@ describe("toEqual", function() { it("reports deep mismatches within Sets", function() { jasmine.getEnv().requireFunctioningSets(); - var actual = new Set(); + var actual = new Set(); // eslint-disable-line compat/compat actual.add({x: 1}); - var expected = new Set(); + var expected = new Set(); // eslint-disable-line compat/compat expected.add({x: 2}); var message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).'; @@ -472,9 +472,9 @@ describe("toEqual", function() { it("reports mismatches between Sets nested in objects", function() { jasmine.getEnv().requireFunctioningSets(); - var actualSet = new Set(); + var actualSet = new Set(); // eslint-disable-line compat/compat actualSet.add(1); - var expectedSet = new Set(); + var expectedSet = new Set(); // eslint-disable-line compat/compat expectedSet.add(2); var actual = { sets: [actualSet] }; @@ -487,10 +487,10 @@ describe("toEqual", function() { it("reports mismatches between Sets of different lengths", function() { jasmine.getEnv().requireFunctioningSets(); - var actual = new Set(); + var actual = new Set(); // eslint-disable-line compat/compat actual.add(1); actual.add(2); - var expected = new Set(); + var expected = new Set(); // eslint-disable-line compat/compat expected.add(2); var message = 'Expected Set( 1, 2 ) to equal Set( 2 ).'; @@ -501,10 +501,10 @@ describe("toEqual", function() { jasmine.getEnv().requireFunctioningSets(); // Use 'duplicate' object in actual so sizes match - var actual = new Set(); + var actual = new Set(); // eslint-disable-line compat/compat actual.add({x: 1}); actual.add({x: 1}); - var expected = new Set(); + var expected = new Set(); // eslint-disable-line compat/compat expected.add({x: 1}); expected.add({x: 2}); var message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).'; @@ -516,10 +516,10 @@ describe("toEqual", function() { jasmine.getEnv().requireFunctioningSets(); // Use 'duplicate' object in expected so sizes match - var actual = new Set(); + var actual = new Set(); // eslint-disable-line compat/compat actual.add({x: 1}); actual.add({x: 2}); - var expected = new Set(); + var expected = new Set(); // eslint-disable-line compat/compat expected.add({x: 1}); expected.add({x: 1}); var message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).'; @@ -533,9 +533,9 @@ describe("toEqual", function() { jasmine.getEnv().requireFunctioningMaps(); // values are the same but with different object identity - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set('a',{x:1}); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set('a',{x:1}); expect(compareEquals(actual, expected).pass).toBe(true); @@ -544,9 +544,9 @@ describe("toEqual", function() { it("reports deep mismatches within Maps", function() { jasmine.getEnv().requireFunctioningMaps(); - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set('a',{x:1}); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set('a',{x:2}); var message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] )."; @@ -556,9 +556,9 @@ describe("toEqual", function() { it("reports mismatches between Maps nested in objects", function() { jasmine.getEnv().requireFunctioningMaps(); - var actual = {Maps:[new Map()]}; + var actual = {Maps:[new Map()]}; // eslint-disable-line compat/compat actual.Maps[0].set('a',1); - var expected = {Maps:[new Map()]}; + var expected = {Maps:[new Map()]}; // eslint-disable-line compat/compat expected.Maps[0].set('a',2); var message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] )."; @@ -569,9 +569,9 @@ describe("toEqual", function() { it("reports mismatches between Maps of different lengths", function() { jasmine.getEnv().requireFunctioningMaps(); - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set('a',1); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set('a',2); expected.set('b',1); var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] )."; @@ -582,9 +582,9 @@ describe("toEqual", function() { it("reports mismatches between Maps with equal values but differing keys", function() { jasmine.getEnv().requireFunctioningMaps(); - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set('a',1); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set('b',1); var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] )."; @@ -594,9 +594,9 @@ describe("toEqual", function() { it("does not report mismatches between Maps with keys with same object identity", function() { jasmine.getEnv().requireFunctioningMaps(); var key = {x: 1}; - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set(key,2); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set(key,2); expect(compareEquals(actual, expected).pass).toBe(true); @@ -605,9 +605,9 @@ describe("toEqual", function() { it("reports mismatches between Maps with identical keys with different object identity", function() { jasmine.getEnv().requireFunctioningMaps(); - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set({x:1},2); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set({x:1},2); var message = "Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] )."; @@ -617,9 +617,9 @@ describe("toEqual", function() { it("does not report mismatches when comparing Map key to jasmine.anything()", function() { jasmine.getEnv().requireFunctioningMaps(); - var actual = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat actual.set('a',1); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set(jasmineUnderTest.anything(),1); expect(compareEquals(actual, expected).pass).toBe(true); @@ -629,10 +629,10 @@ describe("toEqual", function() { jasmine.getEnv().requireFunctioningMaps(); jasmine.getEnv().requireFunctioningSymbols(); - var key = Symbol(); - var actual = new Map(); + var key = Symbol(); // eslint-disable-line compat/compat + var actual = new Map(); // eslint-disable-line compat/compat actual.set(key,1); - var expected = new Map(); + var expected = new Map(); // eslint-disable-line compat/compat expected.set(key,1); expect(compareEquals(actual, expected).pass).toBe(true); @@ -642,10 +642,10 @@ describe("toEqual", function() { jasmine.getEnv().requireFunctioningMaps(); jasmine.getEnv().requireFunctioningSymbols(); - var actual = new Map(); - actual.set(Symbol(),1); - var expected = new Map(); - expected.set(Symbol(),1); + var actual = new Map(); // eslint-disable-line compat/compat + actual.set(Symbol(),1); // eslint-disable-line compat/compat + var expected = new Map(); // eslint-disable-line compat/compat + expected.set(Symbol(),1); // eslint-disable-line compat/compat var message = "Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] )."; expect(compareEquals(actual, expected).message).toBe(message); @@ -655,9 +655,9 @@ describe("toEqual", function() { jasmine.getEnv().requireFunctioningMaps(); jasmine.getEnv().requireFunctioningSymbols(); - var actual = new Map(); - actual.set(Symbol(),1); - var expected = new Map(); + var actual = new Map(); // eslint-disable-line compat/compat + actual.set(Symbol(),1); // eslint-disable-line compat/compat + var expected = new Map(); // eslint-disable-line compat/compat expected.set(jasmineUnderTest.anything(),1); expect(compareEquals(actual, expected).pass).toBe(true); diff --git a/spec/core/matchers/toHaveSizeSpec.js b/spec/core/matchers/toHaveSizeSpec.js index a14a24e5..d25e39e7 100644 --- a/spec/core/matchers/toHaveSizeSpec.js +++ b/spec/core/matchers/toHaveSizeSpec.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ describe('toHaveSize', function() { 'use strict'; diff --git a/spec/helpers/checkForMap.js b/spec/helpers/checkForMap.js index 77fa1233..b8bdacd3 100644 --- a/spec/helpers/checkForMap.js +++ b/spec/helpers/checkForMap.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ (function(env) { env.hasFunctioningMaps = function() { if (typeof Map === 'undefined') { diff --git a/spec/helpers/checkForSet.js b/spec/helpers/checkForSet.js index 8656342d..cae95db7 100644 --- a/spec/helpers/checkForSet.js +++ b/spec/helpers/checkForSet.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ (function(env) { env.hasFunctioningSets = function() { if (typeof Set === 'undefined') { diff --git a/spec/helpers/checkForSymbol.js b/spec/helpers/checkForSymbol.js index c1ed5415..8b5e4b1e 100644 --- a/spec/helpers/checkForSymbol.js +++ b/spec/helpers/checkForSymbol.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ (function(env) { function hasFunctioningSymbols() { if (typeof Symbol === 'undefined') { diff --git a/spec/helpers/checkForTypedArrays.js b/spec/helpers/checkForTypedArrays.js index 3b5d6b35..6902120b 100644 --- a/spec/helpers/checkForTypedArrays.js +++ b/spec/helpers/checkForTypedArrays.js @@ -1,3 +1,4 @@ +/* eslint-disable compat/compat */ (function(env) { function hasFunctioningTypedArrays() { if (typeof Uint32Array === 'undefined') { diff --git a/src/core/asymmetricEqualityTesterArgCompatShim.js b/src/core/asymmetricEqualityTesterArgCompatShim.js index faa4bf79..162d9651 100644 --- a/src/core/asymmetricEqualityTesterArgCompatShim.js +++ b/src/core/asymmetricEqualityTesterArgCompatShim.js @@ -91,7 +91,7 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) { }); } - props = Object.getOwnPropertyDescriptors(Array.prototype); + props = Object.getOwnPropertyDescriptors(Array.prototype); // eslint-disable-line compat/compat a = []; for (k in props) { diff --git a/src/core/matchers/async/toBePending.js b/src/core/matchers/async/toBePending.js index 7ea12df9..758eb99e 100644 --- a/src/core/matchers/async/toBePending.js +++ b/src/core/matchers/async/toBePending.js @@ -1,10 +1,11 @@ +/* eslint-disable compat/compat */ getJasmineRequireObj().toBePending = function(j$) { /** * Expect a promise to be pending, ie. the promise is neither resolved nor rejected. * @function * @async * @name async-matchers#toBePending - * @since 3.5.1 (should this be the next version or the version when it was added?) + * @since 3.6 * @example * await expectAsync(aPromise).toBePending(); */ diff --git a/src/core/matchers/toHaveSize.js b/src/core/matchers/toHaveSize.js index 4f6ace0c..680e5144 100644 --- a/src/core/matchers/toHaveSize.js +++ b/src/core/matchers/toHaveSize.js @@ -33,7 +33,7 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; } - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; + var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat function isLength(value) { return (typeof value == 'number') && value > -1 && value % 1 === 0 && value <= MAX_SAFE_INTEGER; }