From 37166492e8eae9d97a6edaaa52464895913a39b8 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sun, 13 Jan 2019 12:53:52 +0900 Subject: [PATCH] patch jasmine beforeAll/afterAll --- lib/jasmine/jasmine.ts | 2 +- test/jasmine-patch.spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 33b0654c7..ee9dd029a 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -59,7 +59,7 @@ return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach(methodName => { + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { diff --git a/test/jasmine-patch.spec.ts b/test/jasmine-patch.spec.ts index 71ecf240f..5193e3e92 100644 --- a/test/jasmine-patch.spec.ts +++ b/test/jasmine-patch.spec.ts @@ -23,6 +23,7 @@ ifEnvSupports(supportJasmineSpec, () => { describe('jasmine', () => { let throwOnAsync = false; let beforeEachZone: Zone|null = null; + let beforeAllZone: Zone|null = null; let itZone: Zone|null = null; const syncZone = Zone.current; try { @@ -31,6 +32,8 @@ ifEnvSupports(supportJasmineSpec, () => { throwOnAsync = true; } + beforeAll(() => beforeAllZone = Zone.current); + beforeEach(() => beforeEachZone = Zone.current); it('should throw on async in describe', () => { @@ -47,6 +50,12 @@ ifEnvSupports(supportJasmineSpec, () => { expect(beforeEachZone!.name).toEqual(zone.name); expect(itZone).toBe(zone); }); + + afterAll(() => { + let zone = Zone.current; + expect(zone.name).toEqual('ProxyZone'); + expect(beforeAllZone!.name).toEqual(zone.name); + }); }); describe('return promise', () => {