Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix(jasmine): spelling error of 'describe' in jasmine patch prevented…
Browse files Browse the repository at this point in the history
… application of sync zone

Looks like a spelling error was preventing the jasmine patch from patching "describe".
This in turn meant that the describe would not run in the sync zone.

Closes #412
  • Loading branch information
abierbaum authored and mhevery committed Aug 22, 2016
1 parent d4dd351 commit d38ccde
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion lib/jasmine/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// Monkey patch all of the jasmine DSL so that each function runs in appropriate zone.
const jasmineEnv = jasmine.getEnv();
['desribe', 'xdescribe', 'fdescribe'].forEach((methodName) => {
['describe', 'xdescribe', 'fdescribe'].forEach((methodName) => {
let originalJasmineFn: Function = jasmineEnv[methodName];
jasmineEnv[methodName] = function(description: string, specDefinitions: Function) {
return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions));
Expand Down
6 changes: 5 additions & 1 deletion test/browser/XMLHttpRequest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {ifEnvSupports} from '../test-util';

describe('XMLHttpRequest', function () {
var testZone = Zone.current.fork({name: 'test'});
var testZone: Zone;

beforeEach(() => {
testZone = Zone.current.fork({name: 'test'});
});

it('should intercept XHRs and treat them as MacroTasks', function(done) {
var req: any;
Expand Down
44 changes: 24 additions & 20 deletions test/common/Promise.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ function flushMicrotasks() {

describe('Promise', ifEnvSupports('Promise', function () {
if (!global.Promise) return;
var testZone = Zone.current.fork({name: 'TestZone'});

var log;
var pZone = Zone.current.fork({
name: 'promise-zone',
onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: MicroTask): any =>
{
log.push('scheduleTask');
parentZoneDelegate.scheduleTask(targetZone, task);
}
});

var queueZone = Zone.current.fork(new MicroTaskQueueZoneSpec());
var log: string[];
var queueZone: Zone;
var testZone: Zone;
var pZone: Zone;

beforeEach(() => {
testZone = Zone.current.fork({name: 'TestZone'});

pZone = Zone.current.fork({
name: 'promise-zone',
onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: MicroTask): any =>
{
log.push('scheduleTask');
parentZoneDelegate.scheduleTask(targetZone, task);
}
});

queueZone = Zone.current.fork(new MicroTaskQueueZoneSpec());

log = [];
});

Expand Down Expand Up @@ -91,12 +95,12 @@ describe('Promise', ifEnvSupports('Promise', function () {
queueZone.run(() => {
var flush = Zone.current.get('flush');
var queue = Zone.current.get('queue');
var p = new Promise(function (resolve, reject) {
var p = new Promise<string>(function (resolve, reject) {
resolve('RValue');
}).then((v) => {
}).then((v: string) => {
log.push(v);
return 'second value';
}).then((v) => {
}).then((v: string) => {
log.push(v);
});
expect(queue.length).toEqual(1);
Expand All @@ -110,12 +114,12 @@ describe('Promise', ifEnvSupports('Promise', function () {
queueZone.run(() => {
var flush = Zone.current.get('flush');
var queue = Zone.current.get('queue');
var p = new Promise(function (resolve, reject) {
var p = new Promise<string>(function (resolve, reject) {
resolve(Promise.resolve('RValue'));
}).then((v) => {
}).then((v: string) => {
log.push(v);
return Promise.resolve('second value');
}).then((v) => {
}).then((v: string) => {
log.push(v);
});
expect(queue.length).toEqual(1);
Expand Down
23 changes: 12 additions & 11 deletions test/zone-spec/long-stack-trace-zone.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
describe('longStackTraceZone', function () {
var log;

var lstz = Zone.current.fork(Zone['longStackTraceZoneSpec']).fork({
name: 'long-stack-trace-zone-test',
onHandleError: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean => {
parentZoneDelegate.handleError(targetZone, error);
log.push(error.stack);
return false;
}
});
let log;
let lstz: Zone;

beforeEach(function () {
lstz = Zone.current.fork(Zone['longStackTraceZoneSpec']).fork({
name: 'long-stack-trace-zone-test',
onHandleError: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean => {
parentZoneDelegate.handleError(targetZone, error);
log.push(error.stack);
return false;
}
});

log = [];
});

Expand Down

0 comments on commit d38ccde

Please sign in to comment.