Run Prettier on all files
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
describe('Asymmetric equality testers (Integration)', function () {
|
||||
describe('Asymmetric equality testers (Integration)', function() {
|
||||
function verifyPasses(expectations, setup) {
|
||||
it('passes', function (done) {
|
||||
it('passes', function(done) {
|
||||
var env = new jasmineUnderTest.Env();
|
||||
env.it('a spec', function () {
|
||||
env.it('a spec', function() {
|
||||
expectations(env);
|
||||
});
|
||||
|
||||
var specExpectations = function (result) {
|
||||
var specExpectations = function(result) {
|
||||
expect(result.status).toEqual('passed');
|
||||
expect(result.passedExpectations.length)
|
||||
.withContext('Number of passed expectations')
|
||||
@@ -14,115 +14,122 @@ describe('Asymmetric equality testers (Integration)', function () {
|
||||
expect(result.failedExpectations.length)
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(0);
|
||||
expect(result.failedExpectations[0] && result.failedExpectations[0].message)
|
||||
expect(
|
||||
result.failedExpectations[0] && result.failedExpectations[0].message
|
||||
)
|
||||
.withContext('Failure message')
|
||||
.toBeUndefined();
|
||||
};
|
||||
|
||||
env.addReporter({specDone: specExpectations});
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
env.execute(null, done);
|
||||
});
|
||||
}
|
||||
|
||||
function verifyFails(expectations) {
|
||||
it('fails', function (done) {
|
||||
it('fails', function(done) {
|
||||
var env = new jasmineUnderTest.Env();
|
||||
env.it('a spec', function () {
|
||||
env.it('a spec', function() {
|
||||
expectations(env);
|
||||
});
|
||||
|
||||
var specExpectations = function (result) {
|
||||
var specExpectations = function(result) {
|
||||
expect(result.status).toEqual('failed');
|
||||
expect(result.failedExpectations.length)
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(1);
|
||||
expect(result.failedExpectations[0].message)
|
||||
.withContext('Failed with a thrown error rather than a matcher failure')
|
||||
.withContext(
|
||||
'Failed with a thrown error rather than a matcher failure'
|
||||
)
|
||||
.not.toMatch(/^Error: /);
|
||||
expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
|
||||
expect(result.failedExpectations[0].matcherName)
|
||||
.withContext('Matcher name')
|
||||
.not.toEqual('');
|
||||
};
|
||||
|
||||
env.addReporter({specDone: specExpectations});
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
env.execute(null, done);
|
||||
});
|
||||
}
|
||||
|
||||
describe('any', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('any', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect(5).toEqual(jasmineUnderTest.any(Number));
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
env.expect("five").toEqual(jasmineUnderTest.any(Number));
|
||||
verifyFails(function(env) {
|
||||
env.expect('five').toEqual(jasmineUnderTest.any(Number));
|
||||
});
|
||||
});
|
||||
|
||||
describe('anything', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('anything', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect('').toEqual(jasmineUnderTest.anything());
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect(null).toEqual(jasmineUnderTest.anything());
|
||||
});
|
||||
});
|
||||
|
||||
describe('arrayContaining', function () {
|
||||
verifyPasses(function (env) {
|
||||
env.addCustomEqualityTester(function (a, b) {
|
||||
describe('arrayContaining', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
env.expect([1, 2, 3]).toEqual(jasmineUnderTest.arrayContaining(["2"]));
|
||||
env.expect([1, 2, 3]).toEqual(jasmineUnderTest.arrayContaining(['2']));
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect(null).toEqual(jasmineUnderTest.arrayContaining([2]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('arrayWithExactContents', function () {
|
||||
verifyPasses(function (env) {
|
||||
env.addCustomEqualityTester(function (a, b) {
|
||||
describe('arrayWithExactContents', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
env.expect([1, 2]).toEqual(jasmineUnderTest.arrayWithExactContents(["2", "1"]));
|
||||
env
|
||||
.expect([1, 2])
|
||||
.toEqual(jasmineUnderTest.arrayWithExactContents(['2', '1']));
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect([]).toEqual(jasmineUnderTest.arrayWithExactContents([2]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('empty', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('empty', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect([]).toEqual(jasmineUnderTest.empty());
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect([1]).toEqual(jasmineUnderTest.empty());
|
||||
});
|
||||
});
|
||||
|
||||
describe('falsy', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('falsy', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect(false).toEqual(jasmineUnderTest.falsy());
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect(true).toEqual(jasmineUnderTest.falsy());
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapContaining', function () {
|
||||
describe('mapContaining', function() {
|
||||
if (jasmine.getEnv().hasFunctioningMaps()) {
|
||||
verifyPasses(function (env) {
|
||||
verifyPasses(function(env) {
|
||||
var actual = new Map();
|
||||
actual.set('a', "2");
|
||||
actual.set('a', '2');
|
||||
var expected = new Map();
|
||||
expected.set('a', 2);
|
||||
|
||||
env.addCustomEqualityTester(function (a, b) {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
|
||||
@@ -130,54 +137,62 @@ describe('Asymmetric equality testers (Integration)', function () {
|
||||
});
|
||||
} else {
|
||||
it('passes', function() {
|
||||
jasmine.getEnv().pending('Browser has incomplete or missing support for Maps');
|
||||
jasmine
|
||||
.getEnv()
|
||||
.pending('Browser has incomplete or missing support for Maps');
|
||||
});
|
||||
}
|
||||
|
||||
if (jasmine.getEnv().hasFunctioningMaps()) {
|
||||
verifyFails(function (env) {
|
||||
env.expect('something').toEqual(jasmineUnderTest.mapContaining(new Map()));
|
||||
verifyFails(function(env) {
|
||||
env
|
||||
.expect('something')
|
||||
.toEqual(jasmineUnderTest.mapContaining(new Map()));
|
||||
});
|
||||
} else {
|
||||
it('fails', function() {
|
||||
jasmine.getEnv().pending('Browser has incomplete or missing support for Maps');
|
||||
jasmine
|
||||
.getEnv()
|
||||
.pending('Browser has incomplete or missing support for Maps');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('notEmpty', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('notEmpty', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect([1]).toEqual(jasmineUnderTest.notEmpty());
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect([]).toEqual(jasmineUnderTest.notEmpty());
|
||||
});
|
||||
});
|
||||
|
||||
describe('objectContaining', function () {
|
||||
verifyPasses(function (env) {
|
||||
env.addCustomEqualityTester(function (a, b) {
|
||||
describe('objectContaining', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
|
||||
env.expect({a: 1, b: 2}).toEqual(jasmineUnderTest.objectContaining({a: "1"}));
|
||||
env
|
||||
.expect({ a: 1, b: 2 })
|
||||
.toEqual(jasmineUnderTest.objectContaining({ a: '1' }));
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
env.expect({}).toEqual(jasmineUnderTest.objectContaining({a: "1"}));
|
||||
verifyFails(function(env) {
|
||||
env.expect({}).toEqual(jasmineUnderTest.objectContaining({ a: '1' }));
|
||||
});
|
||||
});
|
||||
|
||||
describe('setContaining', function () {
|
||||
describe('setContaining', function() {
|
||||
if (jasmine.getEnv().hasFunctioningSets()) {
|
||||
verifyPasses(function (env) {
|
||||
verifyPasses(function(env) {
|
||||
var actual = new Set();
|
||||
actual.add("1");
|
||||
actual.add('1');
|
||||
var expected = new Set();
|
||||
actual.add(1);
|
||||
|
||||
env.addCustomEqualityTester(function (a, b) {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
|
||||
@@ -185,37 +200,43 @@ describe('Asymmetric equality testers (Integration)', function () {
|
||||
});
|
||||
} else {
|
||||
it('pases', function() {
|
||||
jasmine.getEnv().pending('Browser has incomplete or missing support for Sets');
|
||||
jasmine
|
||||
.getEnv()
|
||||
.pending('Browser has incomplete or missing support for Sets');
|
||||
});
|
||||
}
|
||||
|
||||
if (jasmine.getEnv().hasFunctioningSets()) {
|
||||
verifyFails(function (env) {
|
||||
env.expect('something').toEqual(jasmineUnderTest.setContaining(new Set()));
|
||||
verifyFails(function(env) {
|
||||
env
|
||||
.expect('something')
|
||||
.toEqual(jasmineUnderTest.setContaining(new Set()));
|
||||
});
|
||||
} else {
|
||||
it('fails', function() {
|
||||
jasmine.getEnv().pending('Browser has incomplete or missing support for Sets');
|
||||
jasmine
|
||||
.getEnv()
|
||||
.pending('Browser has incomplete or missing support for Sets');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('stringMatching', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('stringMatching', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect('foo').toEqual(jasmineUnderTest.stringMatching(/o/));
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect('bar').toEqual(jasmineUnderTest.stringMatching(/o/));
|
||||
});
|
||||
});
|
||||
|
||||
describe('truthy', function () {
|
||||
verifyPasses(function (env) {
|
||||
describe('truthy', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect(true).toEqual(jasmineUnderTest.truthy());
|
||||
});
|
||||
|
||||
verifyFails(function (env) {
|
||||
verifyFails(function(env) {
|
||||
env.expect(false).toEqual(jasmineUnderTest.truthy());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -17,7 +17,11 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
env.it('spec using custom async matcher', function() {
|
||||
env.addAsyncMatchers({
|
||||
toBeReal: function() {
|
||||
return { compare: function() { return Promise.resolve({ pass: true }); } };
|
||||
return {
|
||||
compare: function() {
|
||||
return Promise.resolve({ pass: true });
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -39,8 +43,12 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
env.addAsyncMatchers({
|
||||
toBeReal: function() {
|
||||
return {
|
||||
compare: function() { return Promise.resolve({ pass: true }); },
|
||||
negativeCompare: function() { return Promise.resolve({ pass: true }); }
|
||||
compare: function() {
|
||||
return Promise.resolve({ pass: true });
|
||||
},
|
||||
negativeCompare: function() {
|
||||
return Promise.resolve({ pass: true });
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -74,7 +82,9 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
});
|
||||
|
||||
var specExpectations = function(result) {
|
||||
expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
|
||||
expect(result.failedExpectations[0].message).toEqual(
|
||||
"Expected 'a' to be real."
|
||||
);
|
||||
};
|
||||
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
@@ -82,22 +92,24 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
});
|
||||
|
||||
// TODO: remove this in the next major release.
|
||||
it("passes the jasmine utility and current equality testers to the matcher factory", function(done) {
|
||||
it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matcherFactory = function () {
|
||||
var matcherFactory = function() {
|
||||
return {
|
||||
compare: function () {
|
||||
return Promise.resolve({pass: true});
|
||||
compare: function() {
|
||||
return Promise.resolve({ pass: true });
|
||||
}
|
||||
};
|
||||
},
|
||||
matcherFactorySpy = jasmine.createSpy("matcherFactorySpy").and.callFake(matcherFactory),
|
||||
customEqualityFn = function () {
|
||||
matcherFactorySpy = jasmine
|
||||
.createSpy('matcherFactorySpy')
|
||||
.and.callFake(matcherFactory),
|
||||
customEqualityFn = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
env.it("spec with expectation", function() {
|
||||
env.it('spec with expectation', function() {
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.addAsyncMatchers({
|
||||
toBeReal: matcherFactorySpy
|
||||
@@ -117,31 +129,35 @@ describe('Custom Async Matchers (Integration)', function() {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("provides custom equality testers to the matcher factory via matchersUtil", function(done) {
|
||||
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matcherFactory = function (matchersUtil) {
|
||||
var matcherFactory = function(matchersUtil) {
|
||||
return {
|
||||
compare: function (actual, expected) {
|
||||
return Promise.resolve({pass: matchersUtil.equals(actual[0], expected)});
|
||||
compare: function(actual, expected) {
|
||||
return Promise.resolve({
|
||||
pass: matchersUtil.equals(actual[0], expected)
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
customEqualityFn = jasmine.createSpy("customEqualityFn").and.callFake(function (a, b) {
|
||||
return a.toString() === b;
|
||||
});
|
||||
customEqualityFn = jasmine
|
||||
.createSpy('customEqualityFn')
|
||||
.and.callFake(function(a, b) {
|
||||
return a.toString() === b;
|
||||
});
|
||||
|
||||
env.it("spec with expectation", function() {
|
||||
env.it('spec with expectation', function() {
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.addAsyncMatchers({
|
||||
toBeArrayWithFirstElement: matcherFactory
|
||||
});
|
||||
|
||||
return env.expectAsync([1, 2]).toBeArrayWithFirstElement("1");
|
||||
return env.expectAsync([1, 2]).toBeArrayWithFirstElement('1');
|
||||
});
|
||||
|
||||
var specExpectations = function(result) {
|
||||
expect(customEqualityFn).toHaveBeenCalledWith(1, "1");
|
||||
expect(customEqualityFn).toHaveBeenCalledWith(1, '1');
|
||||
expect(result.failedExpectations).toEqual([]);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,52 +1,65 @@
|
||||
describe("Custom Matchers (Integration)", function () {
|
||||
describe('Custom Matchers (Integration)', function() {
|
||||
var env;
|
||||
var fakeTimer;
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
env.cleanup_();
|
||||
});
|
||||
|
||||
it("allows adding more matchers local to a spec", function (done) {
|
||||
env.it('spec defining a custom matcher', function () {
|
||||
it('allows adding more matchers local to a spec', function(done) {
|
||||
env.it('spec defining a custom matcher', function() {
|
||||
env.addMatchers({
|
||||
matcherForSpec: function () {
|
||||
matcherForSpec: function() {
|
||||
return {
|
||||
compare: function (actual, expected) {
|
||||
return {pass: false, message: "matcherForSpec: actual: " + actual + "; expected: " + expected};
|
||||
compare: function(actual, expected) {
|
||||
return {
|
||||
pass: false,
|
||||
message:
|
||||
'matcherForSpec: actual: ' +
|
||||
actual +
|
||||
'; expected: ' +
|
||||
expected
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
env.expect("zzz").matcherForSpec("yyy");
|
||||
env.expect('zzz').matcherForSpec('yyy');
|
||||
});
|
||||
|
||||
env.it("spec without custom matcher defined", function() {
|
||||
expect(env.expect("zzz").matcherForSpec).toBeUndefined();
|
||||
env.it('spec without custom matcher defined', function() {
|
||||
expect(env.expect('zzz').matcherForSpec).toBeUndefined();
|
||||
});
|
||||
|
||||
var specDoneSpy = jasmine.createSpy("specDoneSpy");
|
||||
var specDoneSpy = jasmine.createSpy('specDoneSpy');
|
||||
var expectations = function() {
|
||||
var firstSpecResult = specDoneSpy.calls.first().args[0];
|
||||
expect(firstSpecResult.status).toEqual("failed");
|
||||
expect(firstSpecResult.failedExpectations[0].message).toEqual("matcherForSpec: actual: zzz; expected: yyy");
|
||||
expect(firstSpecResult.status).toEqual('failed');
|
||||
expect(firstSpecResult.failedExpectations[0].message).toEqual(
|
||||
'matcherForSpec: actual: zzz; expected: yyy'
|
||||
);
|
||||
done();
|
||||
};
|
||||
env.addReporter({ specDone:specDoneSpy });
|
||||
env.addReporter({ specDone: specDoneSpy });
|
||||
|
||||
env.execute(null, expectations);
|
||||
});
|
||||
|
||||
it("passes the spec if the custom matcher passes", function(done) {
|
||||
env.it("spec using custom matcher", function() {
|
||||
it('passes the spec if the custom matcher passes', function(done) {
|
||||
env.it('spec using custom matcher', function() {
|
||||
env.addMatchers({
|
||||
toBeReal: function() {
|
||||
return { compare: function() { return { pass: true }; } };
|
||||
return {
|
||||
compare: function() {
|
||||
return { pass: true };
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -61,20 +74,30 @@ describe("Custom Matchers (Integration)", function () {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
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() {
|
||||
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) {
|
||||
// All "foo*" strings match each other.
|
||||
if (typeof a == "string" && typeof b == "string" &&
|
||||
a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
|
||||
if (
|
||||
typeof a == 'string' &&
|
||||
typeof b == 'string' &&
|
||||
a.substr(0, 3) == 'foo' &&
|
||||
b.substr(0, 3) == 'foo'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.expect({foo: 'fooValue'}).toEqual(jasmineUnderTest.objectContaining({foo: 'fooBar'}));
|
||||
env.expect(['fooValue', 'things']).toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
|
||||
env.expect(['fooValue']).toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
|
||||
env
|
||||
.expect({ foo: 'fooValue' })
|
||||
.toEqual(jasmineUnderTest.objectContaining({ foo: 'fooBar' }));
|
||||
env
|
||||
.expect(['fooValue', 'things'])
|
||||
.toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
|
||||
env
|
||||
.expect(['fooValue'])
|
||||
.toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
|
||||
});
|
||||
|
||||
var specExpectations = function(result) {
|
||||
@@ -85,26 +108,30 @@ describe("Custom Matchers (Integration)", function () {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("supports asymmetric equality testers that take a list of custom equality testers", function(done) {
|
||||
it('supports asymmetric equality testers that take a list of custom equality testers', function(done) {
|
||||
// TODO: remove this in the next major release.
|
||||
spyOn(jasmineUnderTest, 'getEnv').and.returnValue(env);
|
||||
|
||||
env.it("spec using custom asymmetric equality tester", function() {
|
||||
env.it('spec using custom asymmetric equality tester', function() {
|
||||
var customEqualityFn = function(a, b) {
|
||||
if (a === 2 && b === "two") {
|
||||
if (a === 2 && b === 'two') {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var arrayWithFirstElement = function(sample) {
|
||||
return {
|
||||
asymmetricMatch: function (actual, customEqualityTesters) {
|
||||
return jasmineUnderTest.matchersUtil.equals(sample, actual[0], customEqualityTesters);
|
||||
asymmetricMatch: function(actual, customEqualityTesters) {
|
||||
return jasmineUnderTest.matchersUtil.equals(
|
||||
sample,
|
||||
actual[0],
|
||||
customEqualityTesters
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.expect(["two"]).toEqual(arrayWithFirstElement(2));
|
||||
env.expect(['two']).toEqual(arrayWithFirstElement(2));
|
||||
});
|
||||
|
||||
var specExpectations = function(result) {
|
||||
@@ -115,8 +142,8 @@ describe("Custom Matchers (Integration)", function () {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("displays an appropriate failure message if a custom equality matcher fails", function(done) {
|
||||
env.it("spec using custom equality matcher", 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) {
|
||||
// "foo" is not equal to anything
|
||||
if (a === 'foo' || b === 'foo') {
|
||||
@@ -125,7 +152,7 @@ describe("Custom Matchers (Integration)", function () {
|
||||
};
|
||||
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.expect({foo: 'foo'}).toEqual({foo: 'foo'});
|
||||
env.expect({ foo: 'foo' }).toEqual({ foo: 'foo' });
|
||||
});
|
||||
|
||||
var specExpectations = function(result) {
|
||||
@@ -139,13 +166,17 @@ describe("Custom Matchers (Integration)", function () {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("uses the negative compare function for a negative comparison, if provided", function(done) {
|
||||
env.it("spec with custom negative comparison matcher", function() {
|
||||
it('uses the negative compare function for a negative comparison, if provided', function(done) {
|
||||
env.it('spec with custom negative comparison matcher', function() {
|
||||
env.addMatchers({
|
||||
toBeReal: function() {
|
||||
return {
|
||||
compare: function() { return { pass: true }; },
|
||||
negativeCompare: function() { return { pass: true }; }
|
||||
compare: function() {
|
||||
return { pass: true };
|
||||
},
|
||||
negativeCompare: function() {
|
||||
return { pass: true };
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -161,7 +192,7 @@ describe("Custom Matchers (Integration)", function () {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
|
||||
it('generates messages with the same rules as built in matchers absent a custom message', function(done) {
|
||||
env.it('spec with an expectation', function() {
|
||||
env.addMatchers({
|
||||
toBeReal: function() {
|
||||
@@ -169,25 +200,29 @@ describe("Custom Matchers (Integration)", function () {
|
||||
compare: function() {
|
||||
return { pass: false };
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
env.expect("a").toBeReal();
|
||||
env.expect('a').toBeReal();
|
||||
});
|
||||
|
||||
var specExpectations = function(result) {
|
||||
expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
|
||||
expect(result.failedExpectations[0].message).toEqual(
|
||||
"Expected 'a' to be real."
|
||||
);
|
||||
};
|
||||
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("passes the expected and actual arguments to the comparison function", function(done) {
|
||||
var argumentSpy = jasmine.createSpy("argument spy").and.returnValue({ pass: true });
|
||||
it('passes the expected and actual arguments to the comparison function', function(done) {
|
||||
var argumentSpy = jasmine
|
||||
.createSpy('argument spy')
|
||||
.and.returnValue({ pass: true });
|
||||
|
||||
env.it('spec with an expectation', function () {
|
||||
env.it('spec with an expectation', function() {
|
||||
env.addMatchers({
|
||||
toBeReal: function() {
|
||||
return { compare: argumentSpy };
|
||||
@@ -195,14 +230,14 @@ describe("Custom Matchers (Integration)", function () {
|
||||
});
|
||||
|
||||
env.expect(true).toBeReal();
|
||||
env.expect(true).toBeReal("arg");
|
||||
env.expect(true).toBeReal("arg1", "arg2");
|
||||
env.expect(true).toBeReal('arg');
|
||||
env.expect(true).toBeReal('arg1', 'arg2');
|
||||
});
|
||||
|
||||
var specExpectations = function() {
|
||||
expect(argumentSpy).toHaveBeenCalledWith(true);
|
||||
expect(argumentSpy).toHaveBeenCalledWith(true, "arg");
|
||||
expect(argumentSpy).toHaveBeenCalledWith(true, "arg1", "arg2");
|
||||
expect(argumentSpy).toHaveBeenCalledWith(true, 'arg');
|
||||
expect(argumentSpy).toHaveBeenCalledWith(true, 'arg1', 'arg2');
|
||||
};
|
||||
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
@@ -210,13 +245,22 @@ describe("Custom Matchers (Integration)", function () {
|
||||
});
|
||||
|
||||
// TODO: remove this in the next major release.
|
||||
it("passes the jasmine utility and current equality testers to the matcher factory", function(done) {
|
||||
var matcherFactory = function() { return { compare: function() { return {pass: true}; }}; },
|
||||
matcherFactorySpy = jasmine.createSpy("matcherFactorySpy").and.callFake(matcherFactory),
|
||||
customEqualityFn = function() { return true; };
|
||||
it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
|
||||
var matcherFactory = function() {
|
||||
return {
|
||||
compare: function() {
|
||||
return { pass: true };
|
||||
}
|
||||
};
|
||||
},
|
||||
matcherFactorySpy = jasmine
|
||||
.createSpy('matcherFactorySpy')
|
||||
.and.callFake(matcherFactory),
|
||||
customEqualityFn = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
env.it("spec with expectation", function() {
|
||||
env.it('spec with expectation', function() {
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.addMatchers({
|
||||
toBeReal: matcherFactorySpy
|
||||
@@ -236,33 +280,35 @@ describe("Custom Matchers (Integration)", function () {
|
||||
env.execute(null, done);
|
||||
});
|
||||
|
||||
it("provides custom equality testers to the matcher factory via matchersUtil", function (done) {
|
||||
var matcherFactory = function (matchersUtil) {
|
||||
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
|
||||
var matcherFactory = function(matchersUtil) {
|
||||
return {
|
||||
compare: function (actual, expected) {
|
||||
return {pass: matchersUtil.equals(actual[0], expected)};
|
||||
compare: function(actual, expected) {
|
||||
return { pass: matchersUtil.equals(actual[0], expected) };
|
||||
}
|
||||
};
|
||||
},
|
||||
customEqualityFn = jasmine.createSpy("customEqualityFn").and.callFake(function (a, b) {
|
||||
return a.toString() === b;
|
||||
});
|
||||
customEqualityFn = jasmine
|
||||
.createSpy('customEqualityFn')
|
||||
.and.callFake(function(a, b) {
|
||||
return a.toString() === b;
|
||||
});
|
||||
|
||||
env.it("spec with expectation", function () {
|
||||
env.it('spec with expectation', function() {
|
||||
env.addCustomEqualityTester(customEqualityFn);
|
||||
env.addMatchers({
|
||||
toBeArrayWithFirstElement: matcherFactory
|
||||
});
|
||||
|
||||
env.expect([1, 2]).toBeArrayWithFirstElement("1");
|
||||
env.expect([1, 2]).toBeArrayWithFirstElement('1');
|
||||
});
|
||||
|
||||
var specExpectations = function (result) {
|
||||
expect(customEqualityFn).toHaveBeenCalledWith(1, "1");
|
||||
var specExpectations = function(result) {
|
||||
expect(customEqualityFn).toHaveBeenCalledWith(1, '1');
|
||||
expect(result.failedExpectations).toEqual([]);
|
||||
};
|
||||
|
||||
env.addReporter({specDone: specExpectations});
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
env.execute(null, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
describe("Custom object formatters", function() {
|
||||
describe('Custom object formatters', function() {
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
it("scopes custom object formatters to a spec", function(done) {
|
||||
it('scopes custom object formatters to a spec', function(done) {
|
||||
env.it('a spec with custom pretty-printer', function() {
|
||||
env.addCustomObjectFormatter(function(obj) { return 'custom(' + obj + ')'; });
|
||||
env.addCustomObjectFormatter(function(obj) {
|
||||
return 'custom(' + obj + ')';
|
||||
});
|
||||
env.expect(42).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -21,23 +23,29 @@ describe("Custom object formatters", function() {
|
||||
specResults.push(result);
|
||||
};
|
||||
var expectations = function() {
|
||||
expect(specResults[0].failedExpectations[0].message).toEqual("Expected custom(42) to be undefined.");
|
||||
expect(specResults[1].failedExpectations[0].message).toEqual("Expected 42 to be undefined.");
|
||||
expect(specResults[0].failedExpectations[0].message).toEqual(
|
||||
'Expected custom(42) to be undefined.'
|
||||
);
|
||||
expect(specResults[1].failedExpectations[0].message).toEqual(
|
||||
'Expected 42 to be undefined.'
|
||||
);
|
||||
done();
|
||||
};
|
||||
env.addReporter({ specDone:specDone });
|
||||
env.addReporter({ specDone: specDone });
|
||||
|
||||
env.execute(null, expectations);
|
||||
});
|
||||
|
||||
it("scopes custom object formatters to a suite", function(done) {
|
||||
it('scopes custom object formatters to a suite', function(done) {
|
||||
env.it('a spec without custom pretty-printer', function() {
|
||||
env.expect(42).toBeUndefined();
|
||||
});
|
||||
|
||||
env.describe('with custom pretty-printer', function() {
|
||||
env.beforeEach(function() {
|
||||
env.addCustomObjectFormatter(function(obj) { return 'custom(' + obj + ')'; });
|
||||
env.addCustomObjectFormatter(function(obj) {
|
||||
return 'custom(' + obj + ')';
|
||||
});
|
||||
});
|
||||
|
||||
env.it('a spec', function() {
|
||||
@@ -50,18 +58,24 @@ describe("Custom object formatters", function() {
|
||||
specResults.push(result);
|
||||
};
|
||||
var expectations = function() {
|
||||
expect(specResults[0].failedExpectations[0].message).toEqual("Expected 42 to be undefined.");
|
||||
expect(specResults[1].failedExpectations[0].message).toEqual("Expected custom(42) to be undefined.");
|
||||
expect(specResults[0].failedExpectations[0].message).toEqual(
|
||||
'Expected 42 to be undefined.'
|
||||
);
|
||||
expect(specResults[1].failedExpectations[0].message).toEqual(
|
||||
'Expected custom(42) to be undefined.'
|
||||
);
|
||||
done();
|
||||
};
|
||||
env.addReporter({ specDone:specDone });
|
||||
env.addReporter({ specDone: specDone });
|
||||
|
||||
env.execute(null, expectations);
|
||||
});
|
||||
|
||||
it("throws an exception if you try to add a custom object formatter outside a runable", function() {
|
||||
it('throws an exception if you try to add a custom object formatter outside a runable', function() {
|
||||
expect(function() {
|
||||
env.addCustomObjectFormatter(function() {});
|
||||
}).toThrowError('Custom object formatters must be added in a before function or a spec')
|
||||
}).toThrowError(
|
||||
'Custom object formatters must be added in a before function or a spec'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -11,10 +11,8 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
});
|
||||
|
||||
it('allows adding more strategies local to a suite', function(done) {
|
||||
var plan = jasmine.createSpy('custom strategy plan')
|
||||
.and.returnValue(42);
|
||||
var strategy = jasmine.createSpy('custom strategy')
|
||||
.and.returnValue(plan);
|
||||
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
||||
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
||||
|
||||
env.describe('suite defining a custom spy strategy', function() {
|
||||
@@ -45,10 +43,8 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
});
|
||||
|
||||
it('allows adding more strategies local to a spec', function(done) {
|
||||
var plan = jasmine.createSpy('custom strategy plan')
|
||||
.and.returnValue(42);
|
||||
var strategy = jasmine.createSpy('custom strategy')
|
||||
.and.returnValue(plan);
|
||||
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
||||
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
||||
|
||||
env.it('spec defining a custom spy strategy', function() {
|
||||
@@ -74,17 +70,17 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
});
|
||||
|
||||
it('allows using custom strategies on a per-argument basis', function(done) {
|
||||
var plan = jasmine.createSpy('custom strategy plan')
|
||||
.and.returnValue(42);
|
||||
var strategy = jasmine.createSpy('custom strategy')
|
||||
.and.returnValue(plan);
|
||||
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
||||
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
||||
|
||||
env.it('spec defining a custom spy strategy', function() {
|
||||
env.addSpyStrategy('frobnicate', strategy);
|
||||
var spy = env.createSpy('something')
|
||||
var spy = env
|
||||
.createSpy('something')
|
||||
.and.returnValue('no args return')
|
||||
.withArgs(1, 2, 3).and.frobnicate(17);
|
||||
.withArgs(1, 2, 3)
|
||||
.and.frobnicate(17);
|
||||
|
||||
expect(spy()).toEqual('no args return');
|
||||
expect(plan).not.toHaveBeenCalled();
|
||||
@@ -114,7 +110,6 @@ describe('Custom Spy Strategies (Integration)', function() {
|
||||
specDone = jasmine.createSpy('specDone'),
|
||||
jasmineDone = jasmine.createSpy('jasmineDone');
|
||||
|
||||
|
||||
env.beforeEach(function() {
|
||||
env.addSpyStrategy('frobnicate', strategy1);
|
||||
env.addSpyStrategy('jiggle', strategy2);
|
||||
|
||||
@@ -3,7 +3,7 @@ describe('Default Spy Strategy (Integration)', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmineUnderTest.Env();
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -13,7 +13,7 @@ describe('Default Spy Strategy (Integration)', function() {
|
||||
it('allows defining a default spy strategy', function(done) {
|
||||
env.describe('suite with default strategy', function() {
|
||||
env.beforeEach(function() {
|
||||
env.setDefaultSpyStrategy(function (and) {
|
||||
env.setDefaultSpyStrategy(function(and) {
|
||||
and.returnValue(42);
|
||||
});
|
||||
});
|
||||
@@ -40,12 +40,16 @@ describe('Default Spy Strategy (Integration)', function() {
|
||||
env.execute(null, expectations);
|
||||
});
|
||||
|
||||
it('uses the default spy strategy defined when the spy is created', function (done) {
|
||||
it('uses the default spy strategy defined when the spy is created', function(done) {
|
||||
env.it('spec', function() {
|
||||
var a = env.createSpy('a');
|
||||
env.setDefaultSpyStrategy(function (and) { and.returnValue(42); });
|
||||
env.setDefaultSpyStrategy(function(and) {
|
||||
and.returnValue(42);
|
||||
});
|
||||
var b = env.createSpy('b');
|
||||
env.setDefaultSpyStrategy(function (and) { and.stub(); });
|
||||
env.setDefaultSpyStrategy(function(and) {
|
||||
and.stub();
|
||||
});
|
||||
var c = env.createSpy('c');
|
||||
env.setDefaultSpyStrategy();
|
||||
var d = env.createSpy('d');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,9 @@ describe('Matchers (Integration)', function() {
|
||||
expect(result.failedExpectations.length)
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(0);
|
||||
expect(result.failedExpectations[0] && result.failedExpectations[0].message)
|
||||
expect(
|
||||
result.failedExpectations[0] && result.failedExpectations[0].message
|
||||
)
|
||||
.withContext('Failure message')
|
||||
.toBeUndefined();
|
||||
};
|
||||
@@ -45,12 +47,17 @@ describe('Matchers (Integration)', function() {
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(1);
|
||||
expect(result.failedExpectations[0].message)
|
||||
.withContext('Failed with a thrown error rather than a matcher failure')
|
||||
.withContext(
|
||||
'Failed with a thrown error rather than a matcher failure'
|
||||
)
|
||||
.not.toMatch(/^Error: /);
|
||||
expect(result.failedExpectations[0].message)
|
||||
.withContext('Failed with a thrown type error rather than a matcher failure')
|
||||
.withContext(
|
||||
'Failed with a thrown type error rather than a matcher failure'
|
||||
)
|
||||
.not.toMatch(/^TypeError: /);
|
||||
expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
|
||||
expect(result.failedExpectations[0].matcherName)
|
||||
.withContext('Matcher name')
|
||||
.not.toEqual('');
|
||||
};
|
||||
|
||||
@@ -61,18 +68,19 @@ describe('Matchers (Integration)', function() {
|
||||
|
||||
function verifyFailsWithCustomObjectFormatters(config) {
|
||||
it('uses custom object formatters', function(done) {
|
||||
env.it('a spec', function () {
|
||||
env.it('a spec', function() {
|
||||
env.addCustomObjectFormatter(config.formatter);
|
||||
config.expectations(env);
|
||||
});
|
||||
|
||||
var specExpectations = function (result) {
|
||||
var specExpectations = function(result) {
|
||||
expect(result.status).toEqual('failed');
|
||||
expect(result.failedExpectations.length)
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(1);
|
||||
expect(result.failedExpectations[0].message)
|
||||
.toEqual(config.expectedMessage);
|
||||
expect(result.failedExpectations[0].message).toEqual(
|
||||
config.expectedMessage
|
||||
);
|
||||
};
|
||||
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
@@ -96,7 +104,9 @@ describe('Matchers (Integration)', function() {
|
||||
expect(result.failedExpectations.length)
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(0);
|
||||
expect(result.failedExpectations[0] && result.failedExpectations[0].message)
|
||||
expect(
|
||||
result.failedExpectations[0] && result.failedExpectations[0].message
|
||||
)
|
||||
.withContext('Failure message')
|
||||
.toBeUndefined();
|
||||
};
|
||||
@@ -120,9 +130,12 @@ describe('Matchers (Integration)', function() {
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(1);
|
||||
expect(result.failedExpectations[0].message)
|
||||
.withContext('Failed with a thrown error rather than a matcher failure')
|
||||
.withContext(
|
||||
'Failed with a thrown error rather than a matcher failure'
|
||||
)
|
||||
.not.toMatch(/^Error: /);
|
||||
expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
|
||||
expect(result.failedExpectations[0].matcherName)
|
||||
.withContext('Matcher name')
|
||||
.not.toEqual('');
|
||||
};
|
||||
|
||||
@@ -135,18 +148,19 @@ describe('Matchers (Integration)', function() {
|
||||
it('uses custom object formatters', function(done) {
|
||||
var env = new jasmineUnderTest.Env();
|
||||
jasmine.getEnv().requirePromises();
|
||||
env.it('a spec', function () {
|
||||
env.it('a spec', function() {
|
||||
env.addCustomObjectFormatter(config.formatter);
|
||||
return config.expectations(env);
|
||||
});
|
||||
|
||||
var specExpectations = function (result) {
|
||||
var specExpectations = function(result) {
|
||||
expect(result.status).toEqual('failed');
|
||||
expect(result.failedExpectations.length)
|
||||
.withContext('Number of failed expectations')
|
||||
.toEqual(1);
|
||||
expect(result.failedExpectations[0].message)
|
||||
.toEqual(config.expectedMessage);
|
||||
expect(result.failedExpectations[0].message).toEqual(
|
||||
config.expectedMessage
|
||||
);
|
||||
};
|
||||
|
||||
env.addReporter({ specDone: specExpectations });
|
||||
@@ -154,7 +168,6 @@ describe('Matchers (Integration)', function() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
describe('nothing', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect().nothing();
|
||||
@@ -330,16 +343,18 @@ describe('Matchers (Integration)', function() {
|
||||
env.expect(1).toBePositiveInfinity();
|
||||
},
|
||||
expectedMessage: 'Expected |1| to be Infinity.'
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('toBeResolved', function() {
|
||||
verifyPassesAsync(function(env) {
|
||||
return env.expectAsync(Promise.resolve()).toBeResolved(); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve()).toBeResolved();
|
||||
});
|
||||
|
||||
verifyFailsAsync(function(env) {
|
||||
return env.expectAsync(Promise.reject()).toBeResolved(); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.reject()).toBeResolved();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -348,11 +363,13 @@ describe('Matchers (Integration)', function() {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5);
|
||||
});
|
||||
|
||||
verifyFailsAsync(function(env) {
|
||||
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar'); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar');
|
||||
});
|
||||
|
||||
verifyFailsWithCustomObjectFormattersAsync({
|
||||
@@ -360,20 +377,24 @@ describe('Matchers (Integration)', function() {
|
||||
return '|' + val + '|';
|
||||
},
|
||||
expectations: function(env) {
|
||||
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y'); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y');
|
||||
},
|
||||
expectedMessage: 'Expected a promise to be resolved to |y| ' +
|
||||
expectedMessage:
|
||||
'Expected a promise to be resolved to |y| ' +
|
||||
'but it was resolved to |x|.'
|
||||
});
|
||||
});
|
||||
|
||||
describe('toBeRejected', function() {
|
||||
verifyPassesAsync(function(env) {
|
||||
return env.expectAsync(Promise.reject('nope')).toBeRejected(); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.reject('nope')).toBeRejected();
|
||||
});
|
||||
|
||||
verifyFailsAsync(function(env) {
|
||||
return env.expectAsync(Promise.resolve()).toBeRejected(); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve()).toBeRejected();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -382,11 +403,13 @@ describe('Matchers (Integration)', function() {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5);
|
||||
});
|
||||
|
||||
verifyFailsAsync(function(env) {
|
||||
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope'); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope');
|
||||
});
|
||||
|
||||
verifyFailsWithCustomObjectFormattersAsync({
|
||||
@@ -394,20 +417,28 @@ describe('Matchers (Integration)', function() {
|
||||
return '|' + val + '|';
|
||||
},
|
||||
expectations: function(env) {
|
||||
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y'); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y');
|
||||
},
|
||||
expectedMessage: 'Expected a promise to be rejected with |y| ' +
|
||||
expectedMessage:
|
||||
'Expected a promise to be rejected with |y| ' +
|
||||
'but it was rejected with |x|.'
|
||||
});
|
||||
});
|
||||
|
||||
describe('toBeRejectedWithError', function() {
|
||||
verifyPassesAsync(function(env) {
|
||||
return env.expectAsync(Promise.reject(new Error())).toBeRejectedWithError(Error); // eslint-disable-line compat/compat
|
||||
return (
|
||||
env
|
||||
// eslint-disable-next-line compat/compat
|
||||
.expectAsync(Promise.reject(new Error()))
|
||||
.toBeRejectedWithError(Error)
|
||||
);
|
||||
});
|
||||
|
||||
verifyFailsAsync(function(env) {
|
||||
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error); // eslint-disable-line compat/compat
|
||||
// eslint-disable-next-line compat/compat
|
||||
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error);
|
||||
});
|
||||
|
||||
verifyFailsWithCustomObjectFormattersAsync({
|
||||
@@ -415,9 +446,15 @@ describe('Matchers (Integration)', function() {
|
||||
return '|' + val + '|';
|
||||
},
|
||||
expectations: function(env) {
|
||||
return env.expectAsync(Promise.reject('foo')).toBeRejectedWithError('foo'); // eslint-disable-line compat/compat
|
||||
return (
|
||||
env
|
||||
// eslint-disable-next-line compat/compat
|
||||
.expectAsync(Promise.reject('foo'))
|
||||
.toBeRejectedWithError('foo')
|
||||
);
|
||||
},
|
||||
expectedMessage: 'Expected a promise to be rejected with Error: |foo| ' +
|
||||
expectedMessage:
|
||||
'Expected a promise to be rejected with Error: |foo| ' +
|
||||
'but it was rejected with |foo|.'
|
||||
});
|
||||
});
|
||||
@@ -486,7 +523,7 @@ describe('Matchers (Integration)', function() {
|
||||
}
|
||||
},
|
||||
expectations: function(env) {
|
||||
env.expect([{foo: 4}]).toEqual([{foo: 5}]);
|
||||
env.expect([{ foo: 4 }]).toEqual([{ foo: 5 }]);
|
||||
},
|
||||
expectedMessage: 'Expected $[0].foo = four to equal five.'
|
||||
});
|
||||
@@ -494,11 +531,11 @@ describe('Matchers (Integration)', function() {
|
||||
|
||||
describe('toHaveSize', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect(['a','b']).toHaveSize(2);
|
||||
env.expect(['a', 'b']).toHaveSize(2);
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
env.expect(['a','b']).toHaveSize(1);
|
||||
env.expect(['a', 'b']).toHaveSize(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -517,14 +554,16 @@ describe('Matchers (Integration)', function() {
|
||||
|
||||
describe('toHaveBeenCalledBefore', function() {
|
||||
verifyPasses(function(env) {
|
||||
var a = env.createSpy('a'), b = env.createSpy('b');
|
||||
var a = env.createSpy('a'),
|
||||
b = env.createSpy('b');
|
||||
a();
|
||||
b();
|
||||
env.expect(a).toHaveBeenCalledBefore(b);
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
var a = env.createSpy('a'), b = env.createSpy('b');
|
||||
var a = env.createSpy('a'),
|
||||
b = env.createSpy('b');
|
||||
b();
|
||||
a();
|
||||
env.expect(a).toHaveBeenCalledBefore(b);
|
||||
@@ -567,7 +606,8 @@ describe('Matchers (Integration)', function() {
|
||||
var spy = env.createSpy('foo');
|
||||
env.expect(spy).toHaveBeenCalledWith('x');
|
||||
},
|
||||
expectedMessage: 'Expected spy foo to have been called with:\n' +
|
||||
expectedMessage:
|
||||
'Expected spy foo to have been called with:\n' +
|
||||
' |x|\n' +
|
||||
'but it was never called.'
|
||||
});
|
||||
@@ -622,7 +662,11 @@ describe('Matchers (Integration)', function() {
|
||||
env.addCustomEqualityTester(function(a, b) {
|
||||
return a.toString() === b.toString();
|
||||
});
|
||||
env.expect(function() { throw '5'; }).toThrow(5);
|
||||
env
|
||||
.expect(function() {
|
||||
throw '5';
|
||||
})
|
||||
.toThrow(5);
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
@@ -635,9 +679,11 @@ describe('Matchers (Integration)', function() {
|
||||
},
|
||||
expectations: function(env) {
|
||||
var spy = env.createSpy('foo');
|
||||
env.expect(function() {
|
||||
throw 'x'
|
||||
}).not.toThrow();
|
||||
env
|
||||
.expect(function() {
|
||||
throw 'x';
|
||||
})
|
||||
.not.toThrow();
|
||||
},
|
||||
expectedMessage: 'Expected function not to throw, but it threw |x|.'
|
||||
});
|
||||
@@ -645,11 +691,15 @@ describe('Matchers (Integration)', function() {
|
||||
|
||||
describe('toThrowError', function() {
|
||||
verifyPasses(function(env) {
|
||||
env.expect(function() { throw new Error(); }).toThrowError();
|
||||
env
|
||||
.expect(function() {
|
||||
throw new Error();
|
||||
})
|
||||
.toThrowError();
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
env.expect(function() { }).toThrowError();
|
||||
env.expect(function() {}).toThrowError();
|
||||
});
|
||||
|
||||
verifyFailsWithCustomObjectFormatters({
|
||||
@@ -658,9 +708,11 @@ describe('Matchers (Integration)', function() {
|
||||
},
|
||||
expectations: function(env) {
|
||||
var spy = env.createSpy('foo');
|
||||
env.expect(function() {
|
||||
throw 'x'
|
||||
}).toThrowError();
|
||||
env
|
||||
.expect(function() {
|
||||
throw 'x';
|
||||
})
|
||||
.toThrowError();
|
||||
},
|
||||
expectedMessage: 'Expected function to throw an Error, but it threw |x|.'
|
||||
});
|
||||
@@ -672,11 +724,15 @@ describe('Matchers (Integration)', function() {
|
||||
}
|
||||
|
||||
verifyPasses(function(env) {
|
||||
env.expect(throws).toThrowMatching(function() { return true; });
|
||||
env.expect(throws).toThrowMatching(function() {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
verifyFails(function(env) {
|
||||
env.expect(throws).toThrowMatching(function() { return false; });
|
||||
env.expect(throws).toThrowMatching(function() {
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
verifyFailsWithCustomObjectFormatters({
|
||||
@@ -685,13 +741,16 @@ describe('Matchers (Integration)', function() {
|
||||
},
|
||||
expectations: function(env) {
|
||||
var spy = env.createSpy('foo');
|
||||
env.expect(function() {
|
||||
throw new Error('nope')
|
||||
}).toThrowMatching(function() {
|
||||
return false;
|
||||
});
|
||||
env
|
||||
.expect(function() {
|
||||
throw new Error('nope');
|
||||
})
|
||||
.toThrowMatching(function() {
|
||||
return false;
|
||||
});
|
||||
},
|
||||
expectedMessage: 'Expected function to throw an exception matching ' +
|
||||
expectedMessage:
|
||||
'Expected function to throw an exception matching ' +
|
||||
'a predicate, but it threw Error with message |nope|.'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
describe("spec running", function () {
|
||||
describe('spec running', function() {
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
jasmine.getEnv().registerIntegrationMatchers();
|
||||
env = new jasmineUnderTest.Env();
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -14,18 +14,13 @@ describe("spec running", function () {
|
||||
it('should assign spec ids sequentially', function() {
|
||||
var it0, it1, it2, it3, it4;
|
||||
env.describe('test suite', function() {
|
||||
it0 = env.it('spec 0', function() {
|
||||
});
|
||||
it1 = env.it('spec 1', function() {
|
||||
});
|
||||
it2 = env.xit('spec 2', function() {
|
||||
});
|
||||
it3 = env.it('spec 3', function() {
|
||||
});
|
||||
it0 = env.it('spec 0', function() {});
|
||||
it1 = env.it('spec 1', function() {});
|
||||
it2 = env.xit('spec 2', function() {});
|
||||
it3 = env.it('spec 3', function() {});
|
||||
});
|
||||
env.describe('test suite 2', function() {
|
||||
it4 = env.it('spec 4', function() {
|
||||
});
|
||||
it4 = env.it('spec 4', function() {});
|
||||
});
|
||||
|
||||
expect(it0.id).toEqual('spec0');
|
||||
@@ -35,29 +30,28 @@ describe("spec running", function () {
|
||||
expect(it4.id).toEqual('spec4');
|
||||
});
|
||||
|
||||
it('nested suites', function (done) {
|
||||
|
||||
it('nested suites', function(done) {
|
||||
var foo = 0;
|
||||
var bar = 0;
|
||||
var baz = 0;
|
||||
var quux = 0;
|
||||
var nested = env.describe('suite', function () {
|
||||
env.describe('nested', function () {
|
||||
env.it('should run nested suites', function () {
|
||||
var nested = env.describe('suite', function() {
|
||||
env.describe('nested', function() {
|
||||
env.it('should run nested suites', function() {
|
||||
foo++;
|
||||
});
|
||||
env.it('should run nested suites', function () {
|
||||
env.it('should run nested suites', function() {
|
||||
bar++;
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('nested 2', function () {
|
||||
env.it('should run suites following nested suites', function () {
|
||||
env.describe('nested 2', function() {
|
||||
env.it('should run suites following nested suites', function() {
|
||||
baz++;
|
||||
});
|
||||
});
|
||||
|
||||
env.it('should run tests following nested suites', function () {
|
||||
env.it('should run tests following nested suites', function() {
|
||||
quux++;
|
||||
});
|
||||
});
|
||||
@@ -76,14 +70,14 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("should permit nested describes", function(done) {
|
||||
it('should permit nested describes', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.beforeEach(function () {
|
||||
env.beforeEach(function() {
|
||||
actions.push('topSuite beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function () {
|
||||
env.afterEach(function() {
|
||||
actions.push('topSuite afterEach');
|
||||
});
|
||||
|
||||
@@ -135,40 +129,40 @@ describe("spec running", function () {
|
||||
|
||||
env.execute(null, function() {
|
||||
var expected = [
|
||||
"topSuite beforeEach",
|
||||
"outer beforeEach",
|
||||
"outer it 1",
|
||||
"outer afterEach",
|
||||
"topSuite afterEach",
|
||||
'topSuite beforeEach',
|
||||
'outer beforeEach',
|
||||
'outer it 1',
|
||||
'outer afterEach',
|
||||
'topSuite afterEach',
|
||||
|
||||
"topSuite beforeEach",
|
||||
"outer beforeEach",
|
||||
"inner 1 beforeEach",
|
||||
"inner 1 it",
|
||||
"inner 1 afterEach",
|
||||
"outer afterEach",
|
||||
"topSuite afterEach",
|
||||
'topSuite beforeEach',
|
||||
'outer beforeEach',
|
||||
'inner 1 beforeEach',
|
||||
'inner 1 it',
|
||||
'inner 1 afterEach',
|
||||
'outer afterEach',
|
||||
'topSuite afterEach',
|
||||
|
||||
"topSuite beforeEach",
|
||||
"outer beforeEach",
|
||||
"outer it 2",
|
||||
"outer afterEach",
|
||||
"topSuite afterEach",
|
||||
'topSuite beforeEach',
|
||||
'outer beforeEach',
|
||||
'outer it 2',
|
||||
'outer afterEach',
|
||||
'topSuite afterEach',
|
||||
|
||||
"topSuite beforeEach",
|
||||
"outer beforeEach",
|
||||
"inner 2 beforeEach",
|
||||
"inner 2 it",
|
||||
"inner 2 afterEach",
|
||||
"outer afterEach",
|
||||
"topSuite afterEach"
|
||||
'topSuite beforeEach',
|
||||
'outer beforeEach',
|
||||
'inner 2 beforeEach',
|
||||
'inner 2 it',
|
||||
'inner 2 afterEach',
|
||||
'outer afterEach',
|
||||
'topSuite afterEach'
|
||||
];
|
||||
expect(actions).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
|
||||
it('should run multiple befores and afters ordered so functions declared later are treated as more specific', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.beforeAll(function() {
|
||||
@@ -187,19 +181,19 @@ describe("spec running", function () {
|
||||
actions.push('runner afterAll2');
|
||||
});
|
||||
|
||||
env.beforeEach(function () {
|
||||
env.beforeEach(function() {
|
||||
actions.push('runner beforeEach1');
|
||||
});
|
||||
|
||||
env.afterEach(function () {
|
||||
env.afterEach(function() {
|
||||
actions.push('runner afterEach1');
|
||||
});
|
||||
|
||||
env.beforeEach(function () {
|
||||
env.beforeEach(function() {
|
||||
actions.push('runner beforeEach2');
|
||||
});
|
||||
|
||||
env.afterEach(function () {
|
||||
env.afterEach(function() {
|
||||
actions.push('runner afterEach2');
|
||||
});
|
||||
|
||||
@@ -227,19 +221,19 @@ describe("spec running", function () {
|
||||
|
||||
env.execute(null, function() {
|
||||
var expected = [
|
||||
"runner beforeAll1",
|
||||
"runner beforeAll2",
|
||||
"runner beforeEach1",
|
||||
"runner beforeEach2",
|
||||
"beforeEach1",
|
||||
"beforeEach2",
|
||||
"outer it 1",
|
||||
"afterEach2",
|
||||
"afterEach1",
|
||||
"runner afterEach2",
|
||||
"runner afterEach1",
|
||||
"runner afterAll2",
|
||||
"runner afterAll1"
|
||||
'runner beforeAll1',
|
||||
'runner beforeAll2',
|
||||
'runner beforeEach1',
|
||||
'runner beforeEach2',
|
||||
'beforeEach1',
|
||||
'beforeEach2',
|
||||
'outer it 1',
|
||||
'afterEach2',
|
||||
'afterEach1',
|
||||
'runner afterEach2',
|
||||
'runner afterEach1',
|
||||
'runner afterAll2',
|
||||
'runner afterAll1'
|
||||
];
|
||||
expect(actions).toEqual(expected);
|
||||
done();
|
||||
@@ -257,11 +251,11 @@ describe("spec running", function () {
|
||||
actions.push('runner afterAll');
|
||||
});
|
||||
|
||||
env.beforeEach(function () {
|
||||
env.beforeEach(function() {
|
||||
actions.push('runner beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function () {
|
||||
env.afterEach(function() {
|
||||
actions.push('runner afterEach');
|
||||
});
|
||||
|
||||
@@ -289,15 +283,15 @@ describe("spec running", function () {
|
||||
|
||||
env.execute(null, function() {
|
||||
var expected = [
|
||||
"runner beforeAll",
|
||||
"inner beforeAll",
|
||||
"runner beforeEach",
|
||||
"inner beforeEach",
|
||||
"it",
|
||||
"inner afterEach",
|
||||
"runner afterEach",
|
||||
"inner afterAll",
|
||||
"runner afterAll"
|
||||
'runner beforeAll',
|
||||
'inner beforeAll',
|
||||
'runner beforeEach',
|
||||
'inner beforeEach',
|
||||
'it',
|
||||
'inner afterEach',
|
||||
'runner afterEach',
|
||||
'inner afterAll',
|
||||
'runner afterAll'
|
||||
];
|
||||
expect(actions).toEqual(expected);
|
||||
done();
|
||||
@@ -317,11 +311,11 @@ describe("spec running", function () {
|
||||
actions.push('runner afterAll');
|
||||
});
|
||||
|
||||
env.beforeEach(function () {
|
||||
env.beforeEach(function() {
|
||||
actions.push('runner beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function () {
|
||||
env.afterEach(function() {
|
||||
actions.push('runner afterEach');
|
||||
});
|
||||
|
||||
@@ -353,38 +347,38 @@ describe("spec running", function () {
|
||||
|
||||
env.execute([spec2.id, spec.id], function() {
|
||||
var expected = [
|
||||
"runner beforeAll",
|
||||
"inner beforeAll",
|
||||
"runner beforeEach",
|
||||
"inner beforeEach",
|
||||
"it2",
|
||||
"inner afterEach",
|
||||
"runner afterEach",
|
||||
'runner beforeAll',
|
||||
'inner beforeAll',
|
||||
'runner beforeEach',
|
||||
'inner beforeEach',
|
||||
'it2',
|
||||
'inner afterEach',
|
||||
'runner afterEach',
|
||||
|
||||
"runner beforeEach",
|
||||
"inner beforeEach",
|
||||
"it",
|
||||
"inner afterEach",
|
||||
"runner afterEach",
|
||||
"inner afterAll",
|
||||
"runner afterAll"
|
||||
'runner beforeEach',
|
||||
'inner beforeEach',
|
||||
'it',
|
||||
'inner afterEach',
|
||||
'runner afterEach',
|
||||
'inner afterAll',
|
||||
'runner afterAll'
|
||||
];
|
||||
expect(actions).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('only runs *Alls once in a focused suite', function(done){
|
||||
it('only runs *Alls once in a focused suite', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.fdescribe('Suite', function() {
|
||||
env.beforeAll(function(){
|
||||
env.beforeAll(function() {
|
||||
actions.push('beforeAll');
|
||||
});
|
||||
env.it('should run beforeAll once', function() {
|
||||
actions.push('spec');
|
||||
});
|
||||
env.afterAll(function(){
|
||||
env.afterAll(function() {
|
||||
actions.push('afterAll');
|
||||
});
|
||||
});
|
||||
@@ -398,20 +392,28 @@ describe("spec running", function () {
|
||||
describe('focused runnables', function() {
|
||||
it('runs the relevant alls and eachs for each runnable', function(done) {
|
||||
var actions = [];
|
||||
env.beforeAll(function() {actions.push('beforeAll')});
|
||||
env.afterAll(function() {actions.push('afterAll')});
|
||||
env.beforeEach(function() {actions.push('beforeEach')});
|
||||
env.afterEach(function() {actions.push('afterEach')});
|
||||
env.beforeAll(function() {
|
||||
actions.push('beforeAll');
|
||||
});
|
||||
env.afterAll(function() {
|
||||
actions.push('afterAll');
|
||||
});
|
||||
env.beforeEach(function() {
|
||||
actions.push('beforeEach');
|
||||
});
|
||||
env.afterEach(function() {
|
||||
actions.push('afterEach');
|
||||
});
|
||||
|
||||
env.fdescribe('a focused suite', function() {
|
||||
env.it('is run', function() {
|
||||
actions.push('spec in fdescribe')
|
||||
actions.push('spec in fdescribe');
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('an unfocused suite', function() {
|
||||
env.fit('has a focused spec', function() {
|
||||
actions.push('focused spec')
|
||||
actions.push('focused spec');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -432,15 +434,15 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('focused specs in focused suites cause non-focused siblings to not run', function(done){
|
||||
it('focused specs in focused suites cause non-focused siblings to not run', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.fdescribe('focused suite', function() {
|
||||
env.it('unfocused spec', function() {
|
||||
actions.push('unfocused spec')
|
||||
actions.push('unfocused spec');
|
||||
});
|
||||
env.fit('focused spec', function() {
|
||||
actions.push('focused spec')
|
||||
actions.push('focused spec');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -451,12 +453,12 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('focused suites in focused suites cause non-focused siblings to not run', function(done){
|
||||
it('focused suites in focused suites cause non-focused siblings to not run', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.fdescribe('focused suite', function() {
|
||||
env.it('unfocused spec', function() {
|
||||
actions.push('unfocused spec')
|
||||
actions.push('unfocused spec');
|
||||
});
|
||||
env.fdescribe('inner focused suite', function() {
|
||||
env.it('inner spec', function() {
|
||||
@@ -477,7 +479,7 @@ describe("spec running", function () {
|
||||
|
||||
env.fdescribe('focused suite', function() {
|
||||
env.it('unfocused spec', function() {
|
||||
actions.push('unfocused spec')
|
||||
actions.push('unfocused spec');
|
||||
});
|
||||
env.describe('inner focused suite', function() {
|
||||
env.fit('focused spec', function() {
|
||||
@@ -495,12 +497,12 @@ describe("spec running", function () {
|
||||
});
|
||||
|
||||
it("shouldn't run disabled suites", function(done) {
|
||||
var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
|
||||
suite = env.describe('A Suite', function() {
|
||||
env.xdescribe('with a disabled suite', function(){
|
||||
env.it('spec inside a disabled suite', specInADisabledSuite);
|
||||
var specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
|
||||
suite = env.describe('A Suite', function() {
|
||||
env.xdescribe('with a disabled suite', function() {
|
||||
env.it('spec inside a disabled suite', specInADisabledSuite);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
||||
@@ -509,16 +511,16 @@ describe("spec running", function () {
|
||||
});
|
||||
|
||||
it("shouldn't run before/after functions in disabled suites", function(done) {
|
||||
var shouldNotRun = jasmine.createSpy("shouldNotRun"),
|
||||
suite = env.xdescribe('A disabled Suite', function() {
|
||||
// None of the before/after functions should run.
|
||||
env.beforeAll(shouldNotRun);
|
||||
env.beforeEach(shouldNotRun);
|
||||
env.afterEach(shouldNotRun);
|
||||
env.afterAll(shouldNotRun);
|
||||
var shouldNotRun = jasmine.createSpy('shouldNotRun'),
|
||||
suite = env.xdescribe('A disabled Suite', function() {
|
||||
// None of the before/after functions should run.
|
||||
env.beforeAll(shouldNotRun);
|
||||
env.beforeEach(shouldNotRun);
|
||||
env.afterEach(shouldNotRun);
|
||||
env.afterAll(shouldNotRun);
|
||||
|
||||
env.it('spec inside a disabled suite', shouldNotRun);
|
||||
});
|
||||
env.it('spec inside a disabled suite', shouldNotRun);
|
||||
});
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(shouldNotRun).not.toHaveBeenCalled();
|
||||
@@ -526,9 +528,9 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("should allow top level suites to be disabled", function(done) {
|
||||
var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
|
||||
otherSpec = jasmine.createSpy("otherSpec");
|
||||
it('should allow top level suites to be disabled', function(done) {
|
||||
var specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
|
||||
otherSpec = jasmine.createSpy('otherSpec');
|
||||
|
||||
env.xdescribe('A disabled suite', function() {
|
||||
env.it('spec inside a disabled suite', specInADisabledSuite);
|
||||
@@ -544,19 +546,19 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("should set all pending specs to pending when a suite is run", function(done) {
|
||||
it('should set all pending specs to pending when a suite is run', function(done) {
|
||||
var pendingSpec,
|
||||
suite = env.describe('default current suite', function() {
|
||||
pendingSpec = env.it("I am a pending spec");
|
||||
pendingSpec = env.it('I am a pending spec');
|
||||
});
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(pendingSpec.status()).toBe("pending");
|
||||
expect(pendingSpec.status()).toBe('pending');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should recover gracefully when there are errors in describe functions", function(done) {
|
||||
it('should recover gracefully when there are errors in describe functions', function(done) {
|
||||
var specs = [],
|
||||
reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
||||
|
||||
@@ -565,83 +567,95 @@ describe("spec running", function () {
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
env.describe("outer1", function() {
|
||||
env.describe("inner1", function() {
|
||||
env.it("should thingy", function() {
|
||||
env.describe('outer1', function() {
|
||||
env.describe('inner1', function() {
|
||||
env.it('should thingy', function() {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
throw new Error("inner error");
|
||||
throw new Error('inner error');
|
||||
});
|
||||
|
||||
env.describe("inner2", function() {
|
||||
env.it("should other thingy", function() {
|
||||
env.describe('inner2', function() {
|
||||
env.it('should other thingy', function() {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
throw new Error("outer error");
|
||||
|
||||
throw new Error('outer error');
|
||||
});
|
||||
}).not.toThrow();
|
||||
|
||||
env.describe("outer2", function() {
|
||||
env.it("should xxx", function() {
|
||||
env.describe('outer2', function() {
|
||||
env.it('should xxx', function() {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
env.execute(null, function() {
|
||||
expect(specs).toEqual(['outer1 inner1 should thingy', 'outer1 inner2 should other thingy', 'outer2 should xxx']);
|
||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1 inner1', [/inner error/]);
|
||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [/outer error/]);
|
||||
expect(specs).toEqual([
|
||||
'outer1 inner1 should thingy',
|
||||
'outer1 inner2 should other thingy',
|
||||
'outer2 should xxx'
|
||||
]);
|
||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
|
||||
'outer1 inner1',
|
||||
[/inner error/]
|
||||
);
|
||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [
|
||||
/outer error/
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("re-enters suites that have no *Alls", function(done) {
|
||||
it('re-enters suites that have no *Alls', function(done) {
|
||||
var actions = [],
|
||||
spec1, spec2, spec3;
|
||||
spec1,
|
||||
spec2,
|
||||
spec3;
|
||||
|
||||
env.describe("top", function() {
|
||||
spec1 = env.it("spec1", function() {
|
||||
actions.push("spec1");
|
||||
env.describe('top', function() {
|
||||
spec1 = env.it('spec1', function() {
|
||||
actions.push('spec1');
|
||||
});
|
||||
|
||||
spec2 = env.it("spec2", function() {
|
||||
actions.push("spec2");
|
||||
spec2 = env.it('spec2', function() {
|
||||
actions.push('spec2');
|
||||
});
|
||||
});
|
||||
|
||||
spec3 = env.it("spec3", function() {
|
||||
actions.push("spec3");
|
||||
spec3 = env.it('spec3', function() {
|
||||
actions.push('spec3');
|
||||
});
|
||||
|
||||
env.execute([spec2.id, spec3.id, spec1.id], function() {
|
||||
expect(actions).toEqual(["spec2", "spec3", "spec1"]);
|
||||
expect(actions).toEqual(['spec2', 'spec3', 'spec1']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("refuses to re-enter suites with a beforeAll", function() {
|
||||
it('refuses to re-enter suites with a beforeAll', function() {
|
||||
var actions = [],
|
||||
spec1, spec2, spec3;
|
||||
spec1,
|
||||
spec2,
|
||||
spec3;
|
||||
|
||||
env.describe("top", function() {
|
||||
env.describe('top', function() {
|
||||
env.beforeAll(function() {});
|
||||
|
||||
spec1 = env.it("spec1", function() {
|
||||
actions.push("spec1");
|
||||
spec1 = env.it('spec1', function() {
|
||||
actions.push('spec1');
|
||||
});
|
||||
|
||||
spec2 = env.it("spec2", function() {
|
||||
actions.push("spec2");
|
||||
spec2 = env.it('spec2', function() {
|
||||
actions.push('spec2');
|
||||
});
|
||||
});
|
||||
|
||||
spec3 = env.it("spec3", function() {
|
||||
actions.push("spec3");
|
||||
spec3 = env.it('spec3', function() {
|
||||
actions.push('spec3');
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
@@ -650,24 +664,26 @@ describe("spec running", function () {
|
||||
expect(actions).toEqual([]);
|
||||
});
|
||||
|
||||
it("refuses to re-enter suites with a afterAll", function() {
|
||||
it('refuses to re-enter suites with a afterAll', function() {
|
||||
var actions = [],
|
||||
spec1, spec2, spec3;
|
||||
spec1,
|
||||
spec2,
|
||||
spec3;
|
||||
|
||||
env.describe("top", function() {
|
||||
env.describe('top', function() {
|
||||
env.afterAll(function() {});
|
||||
|
||||
spec1 = env.it("spec1", function() {
|
||||
actions.push("spec1");
|
||||
spec1 = env.it('spec1', function() {
|
||||
actions.push('spec1');
|
||||
});
|
||||
|
||||
spec2 = env.it("spec2", function() {
|
||||
actions.push("spec2");
|
||||
spec2 = env.it('spec2', function() {
|
||||
actions.push('spec2');
|
||||
});
|
||||
});
|
||||
|
||||
spec3 = env.it("spec3", function() {
|
||||
actions.push("spec3");
|
||||
spec3 = env.it('spec3', function() {
|
||||
actions.push('spec3');
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
@@ -676,15 +692,15 @@ describe("spec running", function () {
|
||||
expect(actions).toEqual([]);
|
||||
});
|
||||
|
||||
it("should run the tests in a consistent order when a seed is supplied", function(done) {
|
||||
it('should run the tests in a consistent order when a seed is supplied', function(done) {
|
||||
var actions = [];
|
||||
env.configure({random: true, seed: '123456'});
|
||||
env.configure({ random: true, seed: '123456' });
|
||||
|
||||
env.beforeEach(function () {
|
||||
env.beforeEach(function() {
|
||||
actions.push('topSuite beforeEach');
|
||||
});
|
||||
|
||||
env.afterEach(function () {
|
||||
env.afterEach(function() {
|
||||
actions.push('topSuite afterEach');
|
||||
});
|
||||
|
||||
@@ -769,14 +785,14 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("When throwOnExpectationFailure is set", function() {
|
||||
it("skips to cleanup functions after an error", function(done) {
|
||||
describe('When throwOnExpectationFailure is set', function() {
|
||||
it('skips to cleanup functions after an error', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.describe('Something', function() {
|
||||
env.beforeEach(function() {
|
||||
actions.push('outer beforeEach');
|
||||
throw new Error("error");
|
||||
throw new Error('error');
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
@@ -792,13 +808,13 @@ describe("spec running", function () {
|
||||
actions.push('inner afterEach');
|
||||
});
|
||||
|
||||
env.it('does it' , function() {
|
||||
env.it('does it', function() {
|
||||
actions.push('inner it');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.configure({oneFailurePerSpec: true});
|
||||
env.configure({ oneFailurePerSpec: true });
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual([
|
||||
@@ -810,7 +826,7 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("skips to cleanup functions after done.fail is called", function(done) {
|
||||
it('skips to cleanup functions after done.fail is called', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.describe('Something', function() {
|
||||
@@ -824,23 +840,20 @@ describe("spec running", function () {
|
||||
actions.push('afterEach');
|
||||
});
|
||||
|
||||
env.it('does it' , function() {
|
||||
env.it('does it', function() {
|
||||
actions.push('it');
|
||||
});
|
||||
});
|
||||
|
||||
env.configure({oneFailurePerSpec: true});
|
||||
env.configure({ oneFailurePerSpec: true });
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual([
|
||||
'beforeEach',
|
||||
'afterEach'
|
||||
]);
|
||||
expect(actions).toEqual(['beforeEach', 'afterEach']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("skips to cleanup functions when an async function times out", function(done) {
|
||||
it('skips to cleanup functions when an async function times out', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.describe('Something', function() {
|
||||
@@ -852,23 +865,20 @@ describe("spec running", function () {
|
||||
actions.push('afterEach');
|
||||
});
|
||||
|
||||
env.it('does it' , function() {
|
||||
env.it('does it', function() {
|
||||
actions.push('it');
|
||||
});
|
||||
});
|
||||
|
||||
env.configure({oneFailurePerSpec: true});
|
||||
env.configure({ oneFailurePerSpec: true });
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual([
|
||||
'beforeEach',
|
||||
'afterEach'
|
||||
]);
|
||||
expect(actions).toEqual(['beforeEach', 'afterEach']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("skips to cleanup functions after an error with deprecations", function(done) {
|
||||
it('skips to cleanup functions after an error with deprecations', function(done) {
|
||||
var actions = [];
|
||||
|
||||
spyOn(env, 'deprecated');
|
||||
@@ -876,7 +886,7 @@ describe("spec running", function () {
|
||||
env.describe('Something', function() {
|
||||
env.beforeEach(function() {
|
||||
actions.push('outer beforeEach');
|
||||
throw new Error("error");
|
||||
throw new Error('error');
|
||||
});
|
||||
|
||||
env.afterEach(function() {
|
||||
@@ -892,7 +902,7 @@ describe("spec running", function () {
|
||||
actions.push('inner afterEach');
|
||||
});
|
||||
|
||||
env.it('does it' , function() {
|
||||
env.it('does it', function() {
|
||||
actions.push('inner it');
|
||||
});
|
||||
});
|
||||
@@ -911,7 +921,7 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("skips to cleanup functions after done.fail is called with deprecations", function(done) {
|
||||
it('skips to cleanup functions after done.fail is called with deprecations', function(done) {
|
||||
var actions = [];
|
||||
|
||||
spyOn(env, 'deprecated');
|
||||
@@ -927,7 +937,7 @@ describe("spec running", function () {
|
||||
actions.push('afterEach');
|
||||
});
|
||||
|
||||
env.it('does it' , function() {
|
||||
env.it('does it', function() {
|
||||
actions.push('it');
|
||||
});
|
||||
});
|
||||
@@ -935,16 +945,13 @@ describe("spec running", function () {
|
||||
env.throwOnExpectationFailure(true);
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual([
|
||||
'beforeEach',
|
||||
'afterEach'
|
||||
]);
|
||||
expect(actions).toEqual(['beforeEach', 'afterEach']);
|
||||
expect(env.deprecated).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("skips to cleanup functions when an async function times out with deprecations", function(done) {
|
||||
it('skips to cleanup functions when an async function times out with deprecations', function(done) {
|
||||
var actions = [];
|
||||
|
||||
spyOn(env, 'deprecated');
|
||||
@@ -958,7 +965,7 @@ describe("spec running", function () {
|
||||
actions.push('afterEach');
|
||||
});
|
||||
|
||||
env.it('does it' , function() {
|
||||
env.it('does it', function() {
|
||||
actions.push('it');
|
||||
});
|
||||
});
|
||||
@@ -966,18 +973,15 @@ describe("spec running", function () {
|
||||
env.throwOnExpectationFailure(true);
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual([
|
||||
'beforeEach',
|
||||
'afterEach'
|
||||
]);
|
||||
expect(actions).toEqual(['beforeEach', 'afterEach']);
|
||||
expect(env.deprecated).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when stopOnSpecFailure is on", function() {
|
||||
it("does not run further specs when one fails", function(done) {
|
||||
describe('when stopOnSpecFailure is on', function() {
|
||||
it('does not run further specs when one fails', function(done) {
|
||||
var actions = [];
|
||||
|
||||
env.describe('wrapper', function() {
|
||||
@@ -993,7 +997,7 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
env.configure({random: false, failFast: true});
|
||||
env.configure({ random: false, failFast: true });
|
||||
|
||||
env.execute(null, function() {
|
||||
expect(actions).toEqual(['fails']);
|
||||
@@ -1001,7 +1005,7 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not run further specs when one fails when configured with deprecated option", function(done) {
|
||||
it('does not run further specs when one fails when configured with deprecated option', function(done) {
|
||||
var actions = [];
|
||||
|
||||
spyOn(env, 'deprecated');
|
||||
@@ -1019,7 +1023,7 @@ describe("spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
env.configure({random: false});
|
||||
env.configure({ random: false });
|
||||
env.stopOnSpecFailure(true);
|
||||
|
||||
env.execute(null, function() {
|
||||
|
||||
Reference in New Issue
Block a user