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

Commit

Permalink
fix(jasmine): support "pending" it clauses with no test body
Browse files Browse the repository at this point in the history
Closes #659
  • Loading branch information
petebacondarwin authored and mhevery committed Mar 7, 2017
1 parent 36c0899 commit 96cb3d0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 33 deletions.
8 changes: 4 additions & 4 deletions lib/jasmine/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@
// The `done` callback is only passed through if the function expects at least one argument.
// Note we have to make a function with correct number of arguments, otherwise jasmine will
// think that all functions are sync or async.
return (testBody.length == 0) ? function() {
return testProxyZone.run(testBody, this);
} : function(done) {
return testBody && (testBody.length ? function(done) {
return testProxyZone.run(testBody, this, [done]);
};
} : function() {
return testProxyZone.run(testBody, this);
});
}
interface QueueRunner {
execute(): void;
Expand Down
3 changes: 2 additions & 1 deletion test/browser_entry_point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ import './browser/requestAnimationFrame.spec';
import './browser/WebSocket.spec';
import './browser/XMLHttpRequest.spec';
import './browser/MediaQuery.spec';
import './mocha-patch.spec';
import './mocha-patch.spec';
import './jasmine-patch.spec';
59 changes: 31 additions & 28 deletions test/jasmine-patch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {ifEnvSupports} from './test-util';
/**
* @license
* Copyright Google Inc. All Rights Reserved.
Expand All @@ -6,37 +7,39 @@
* found in the LICENSE file at https://angular.io/license
*/

beforeEach(() => {
// assert that each jasmine run has a task, so that drainMicrotask works properly.
expect(Zone.currentTask).toBeTruthy();
});
ifEnvSupports(() => jasmine && jasmine['Spec'], () => {
beforeEach(() => {
// assert that each jasmine run has a task, so that drainMicrotask works properly.
expect(Zone.currentTask).toBeTruthy();
});

describe('jasmine', () => {
let throwOnAsync = false;
let beforeEachZone: Zone = null;
let itZone: Zone = null;
const syncZone = Zone.current;
try {
Zone.current.scheduleMicroTask('dontallow', () => null);
} catch (e) {
throwOnAsync = true;
}
describe('jasmine', () => {
let throwOnAsync = false;
let beforeEachZone: Zone = null;
let itZone: Zone = null;
const syncZone = Zone.current;
try {
Zone.current.scheduleMicroTask('dontallow', () => null);
} catch (e) {
throwOnAsync = true;
}

beforeEach(() => beforeEachZone = Zone.current);
beforeEach(() => beforeEachZone = Zone.current);

it('should throw on async in describe', () => {
expect(throwOnAsync).toBe(true);
expect(syncZone.name).toEqual('syncTestZone for jasmine.describe');
itZone = Zone.current;
});
it('should throw on async in describe', () => {
expect(throwOnAsync).toBe(true);
expect(syncZone.name).toEqual('syncTestZone for jasmine.describe');
itZone = Zone.current;
});

afterEach(() => {
let zone = Zone.current;
expect(zone.name).toEqual('ProxyZone');
expect(beforeEachZone).toBe(zone);
expect(itZone).toBe(zone);
});
it('should cope with pending tests, which have no test body');

});
afterEach(() => {
let zone = Zone.current;
expect(zone.name).toEqual('ProxyZone');
expect(beforeEachZone).toBe(zone);
expect(itZone).toBe(zone);
});

export let _something_so_that_i_am_treated_as_es6_module;
});
})();

0 comments on commit 96cb3d0

Please sign in to comment.