Use const/let in specs, not var
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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([]);
|
||||
};
|
||||
|
||||
@@ -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([]);
|
||||
};
|
||||
|
||||
@@ -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.'
|
||||
);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
+194
-209
File diff suppressed because it is too large
Load Diff
@@ -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')
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user