Run Prettier on all files

This commit is contained in:
Steve Gravrock
2020-09-29 18:05:38 -07:00
parent 7d5ca27b9d
commit d27bb8fa96
108 changed files with 4399 additions and 2926 deletions

View File

@@ -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() {