From 9d27abc45c513dfb82d84ce0d9fadde4fafc4f70 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Thu, 17 Jan 2019 05:23:55 +0900 Subject: [PATCH] patch jasmine beforeAll/afterAll (#1176) --- 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', () => {