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

Commit 96cb3d0

Browse files
petebacondarwinmhevery
authored andcommitted
fix(jasmine): support "pending" it clauses with no test body
Closes #659
1 parent 36c0899 commit 96cb3d0

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

lib/jasmine/jasmine.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@
8989
// The `done` callback is only passed through if the function expects at least one argument.
9090
// Note we have to make a function with correct number of arguments, otherwise jasmine will
9191
// think that all functions are sync or async.
92-
return (testBody.length == 0) ? function() {
93-
return testProxyZone.run(testBody, this);
94-
} : function(done) {
92+
return testBody && (testBody.length ? function(done) {
9593
return testProxyZone.run(testBody, this, [done]);
96-
};
94+
} : function() {
95+
return testProxyZone.run(testBody, this);
96+
});
9797
}
9898
interface QueueRunner {
9999
execute(): void;

test/browser_entry_point.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ import './browser/requestAnimationFrame.spec';
2020
import './browser/WebSocket.spec';
2121
import './browser/XMLHttpRequest.spec';
2222
import './browser/MediaQuery.spec';
23-
import './mocha-patch.spec';
23+
import './mocha-patch.spec';
24+
import './jasmine-patch.spec';

test/jasmine-patch.spec.ts

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {ifEnvSupports} from './test-util';
12
/**
23
* @license
34
* Copyright Google Inc. All Rights Reserved.
@@ -6,37 +7,39 @@
67
* found in the LICENSE file at https://angular.io/license
78
*/
89

9-
beforeEach(() => {
10-
// assert that each jasmine run has a task, so that drainMicrotask works properly.
11-
expect(Zone.currentTask).toBeTruthy();
12-
});
10+
ifEnvSupports(() => jasmine && jasmine['Spec'], () => {
11+
beforeEach(() => {
12+
// assert that each jasmine run has a task, so that drainMicrotask works properly.
13+
expect(Zone.currentTask).toBeTruthy();
14+
});
1315

14-
describe('jasmine', () => {
15-
let throwOnAsync = false;
16-
let beforeEachZone: Zone = null;
17-
let itZone: Zone = null;
18-
const syncZone = Zone.current;
19-
try {
20-
Zone.current.scheduleMicroTask('dontallow', () => null);
21-
} catch (e) {
22-
throwOnAsync = true;
23-
}
16+
describe('jasmine', () => {
17+
let throwOnAsync = false;
18+
let beforeEachZone: Zone = null;
19+
let itZone: Zone = null;
20+
const syncZone = Zone.current;
21+
try {
22+
Zone.current.scheduleMicroTask('dontallow', () => null);
23+
} catch (e) {
24+
throwOnAsync = true;
25+
}
2426

25-
beforeEach(() => beforeEachZone = Zone.current);
27+
beforeEach(() => beforeEachZone = Zone.current);
2628

27-
it('should throw on async in describe', () => {
28-
expect(throwOnAsync).toBe(true);
29-
expect(syncZone.name).toEqual('syncTestZone for jasmine.describe');
30-
itZone = Zone.current;
31-
});
29+
it('should throw on async in describe', () => {
30+
expect(throwOnAsync).toBe(true);
31+
expect(syncZone.name).toEqual('syncTestZone for jasmine.describe');
32+
itZone = Zone.current;
33+
});
3234

33-
afterEach(() => {
34-
let zone = Zone.current;
35-
expect(zone.name).toEqual('ProxyZone');
36-
expect(beforeEachZone).toBe(zone);
37-
expect(itZone).toBe(zone);
38-
});
35+
it('should cope with pending tests, which have no test body');
3936

40-
});
37+
afterEach(() => {
38+
let zone = Zone.current;
39+
expect(zone.name).toEqual('ProxyZone');
40+
expect(beforeEachZone).toBe(zone);
41+
expect(itZone).toBe(zone);
42+
});
4143

42-
export let _something_so_that_i_am_treated_as_es6_module;
44+
});
45+
})();

0 commit comments

Comments
 (0)