@ -9,17 +9,17 @@
|
||||
// Extra Mocha-specific typings to make sure typescript compiler is happy
|
||||
// Didn't want to add @types/mocha because of duplication in typings-file with @types/jasmine
|
||||
declare function suite(description: string, suiteFn: () => void): void;
|
||||
declare function test(description: string, testFn: () => void): void;
|
||||
declare function specify(description: string, testFn: () => void): void;
|
||||
declare function setup(fn: () => void): void; declare function teardown(fn: () => void): void;
|
||||
declare function suiteSetup(fn: () => void): void;
|
||||
declare function suiteTeardown(fn: () => void): void;
|
||||
declare function before(fn: () => void): void; declare function after(fn: () => void): void;
|
||||
//
|
||||
declare function test(description: string, testFn: () => void): void;
|
||||
declare function specify(description: string, testFn: () => void): void;
|
||||
declare function setup(fn: () => void): void;
|
||||
declare function teardown(fn: () => void): void;
|
||||
declare function suiteSetup(fn: () => void): void;
|
||||
declare function suiteTeardown(fn: () => void): void;
|
||||
declare function before(fn: () => void): void;
|
||||
declare function after(fn: () => void): void;
|
||||
//
|
||||
|
||||
import {
|
||||
ifEnvSupports
|
||||
} from './test-util';
|
||||
import {ifEnvSupports} from './test-util';
|
||||
|
||||
ifEnvSupports('Mocha', function() {
|
||||
describe('Mocha BDD-style', () => {
|
||||
@ -29,7 +29,9 @@ ifEnvSupports('Mocha', function() {
|
||||
const syncZone = Zone.current;
|
||||
let beforeZone: Zone|null = null;
|
||||
|
||||
before(() => { beforeZone = Zone.current; });
|
||||
before(() => {
|
||||
beforeZone = Zone.current;
|
||||
});
|
||||
|
||||
try {
|
||||
Zone.current.scheduleMicroTask('dontallow', (): any => null);
|
||||
@ -53,7 +55,9 @@ ifEnvSupports('Mocha', function() {
|
||||
expect(itZone).toBe(zone);
|
||||
});
|
||||
|
||||
after(() => { expect(beforeZone).toBe(Zone.current); });
|
||||
after(() => {
|
||||
expect(beforeZone).toBe(Zone.current);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Mocha TDD-style', () => {
|
||||
@ -61,9 +65,13 @@ ifEnvSupports('Mocha', function() {
|
||||
let beforeEachZone: Zone|null = null;
|
||||
let suiteSetupZone: Zone|null = null;
|
||||
|
||||
suiteSetup(() => { suiteSetupZone = Zone.current; });
|
||||
suiteSetup(() => {
|
||||
suiteSetupZone = Zone.current;
|
||||
});
|
||||
|
||||
setup(() => { beforeEachZone = Zone.current; });
|
||||
setup(() => {
|
||||
beforeEachZone = Zone.current;
|
||||
});
|
||||
|
||||
test('should run in Zone with "test"-syntax in TDD-mode', () => {
|
||||
testZone = Zone.current;
|
||||
@ -83,12 +91,16 @@ ifEnvSupports('Mocha', function() {
|
||||
expect(testZone).toBe(Zone.current);
|
||||
});
|
||||
|
||||
suiteTeardown(() => { expect(suiteSetupZone).toBe(Zone.current); });
|
||||
suiteTeardown(() => {
|
||||
expect(suiteSetupZone).toBe(Zone.current);
|
||||
});
|
||||
});
|
||||
|
||||
describe('return promise', () => {
|
||||
let log: string[];
|
||||
beforeEach(() => { log = []; });
|
||||
beforeEach(() => {
|
||||
log = [];
|
||||
});
|
||||
|
||||
it('should wait for promise to resolve', () => {
|
||||
return new Promise((res, _) => {
|
||||
@ -99,6 +111,8 @@ ifEnvSupports('Mocha', function() {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => { expect(log).toEqual(['resolved']); });
|
||||
afterEach(() => {
|
||||
expect(log).toEqual(['resolved']);
|
||||
});
|
||||
});
|
||||
})();
|
Reference in New Issue
Block a user