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

Commit b52cf02

Browse files
committed
fix: stop using class extends as it breaks rollup
1 parent 7da0c52 commit b52cf02

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
sudo: false
33
node_js:
4-
- '4.2.1'
4+
- '6.3.1'
55
env:
66
global:
77
- BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready

lib/jasmine/jasmine.ts

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
'use strict';
22
(() => {
3+
var __extends = function (d, b) {
4+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5+
function __() { this.constructor = d; }
6+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7+
};
38
// Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs
49
// in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503)
510
if (!Zone) throw new Error("Missing: zone.js");
6-
if (typeof jasmine == 'undefined') throw new Error("Missing: jasmine.js");
11+
if (typeof jasmine == 'undefined') throw new Error("Missing: jasmine.js");
712
if (jasmine['__zone_patch__']) throw new Error("'jasmine' has already been patched with 'Zone'.");
813
jasmine['__zone_patch__'] = true;
914

@@ -13,19 +18,19 @@
1318
if (!ProxyZoneSpec) throw new Error("Missing: ProxyZoneSpec");
1419

1520
const ambientZone = Zone.current;
16-
// Create a synchronous-only zone in which to run `describe` blocks in order to raise an
17-
// error if any asynchronous operations are attempted inside of a `describe` but outside of
21+
// Create a synchronous-only zone in which to run `describe` blocks in order to raise an
22+
// error if any asynchronous operations are attempted inside of a `describe` but outside of
1823
// a `beforeEach` or `it`.
1924
const syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe'));
2025

2126
// This is the zone which will be used for running individual tests.
2227
// It will be a proxy zone, so that the tests function can retroactively install
23-
// different zones.
28+
// different zones.
2429
// Example:
2530
// - In beforeEach() do childZone = Zone.current.fork(...);
26-
// - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the
31+
// - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the
2732
// zone outside of fakeAsync it will be able to escope the fakeAsync rules.
28-
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add
33+
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add
2934
// fakeAsync behavior to the childZone.
3035
let testProxyZone: Zone = null;
3136

@@ -35,43 +40,43 @@
3540
let originalJasmineFn: Function = jasmineEnv[methodName];
3641
jasmineEnv[methodName] = function(description: string, specDefinitions: Function) {
3742
return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions));
38-
}
43+
}
3944
});
4045
['it', 'xit', 'fit'].forEach((methodName) => {
4146
let originalJasmineFn: Function = jasmineEnv[methodName];
4247
jasmineEnv[methodName] = function(description: string, specDefinitions: Function, timeout: number) {
4348
arguments[1] = wrapTestInZone(specDefinitions);
4449
return originalJasmineFn.apply(this, arguments);
45-
}
50+
}
4651
});
4752
['beforeEach', 'afterEach'].forEach((methodName) => {
4853
let originalJasmineFn: Function = jasmineEnv[methodName];
4954
jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) {
5055
arguments[0] = wrapTestInZone(specDefinitions);
5156
return originalJasmineFn.apply(this, arguments);
52-
}
57+
}
5358
});
5459

55-
/**
56-
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a
57-
* synchronous-only zone.
60+
/**
61+
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a
62+
* synchronous-only zone.
5863
*/
5964
function wrapDescribeInZone(describeBody: Function): Function {
6065
return function() {
6166
return syncZone.run(describeBody, this, arguments as any as any[]);
6267
}
6368
}
6469

65-
/**
66-
* Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to
67-
* execute in a ProxyZone zone.
70+
/**
71+
* Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to
72+
* execute in a ProxyZone zone.
6873
* This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner`
6974
*/
7075
function wrapTestInZone(testBody: Function): Function {
7176
// The `done` callback is only passed through if the function expects at least one argument.
7277
// Note we have to make a function with correct number of arguments, otherwise jasmine will
7378
// think that all functions are sync or async.
74-
return (testBody.length == 0)
79+
return (testBody.length == 0)
7580
? function() { return testProxyZone.run(testBody, this); }
7681
: function(done) { return testProxyZone.run(testBody, this, [done]); };
7782
}
@@ -90,17 +95,17 @@
9095
}
9196

9297
const QueueRunner = (jasmine as any).QueueRunner as { new(attrs: QueueRunnerAttrs): QueueRunner };
93-
(jasmine as any).QueueRunner = class ZoneQueueRunner extends QueueRunner {
94-
constructor(attrs: QueueRunnerAttrs) {
98+
(jasmine as any).QueueRunner = (function (_super) {
99+
__extends(ZoneQueueRunner, _super);
100+
function ZoneQueueRunner(attrs) {
95101
attrs.onComplete = ((fn) => () => {
96102
// All functions are done, clear the test zone.
97103
testProxyZone = null;
98104
ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
99105
})(attrs.onComplete);
100-
super(attrs);
106+
_super.call(this, attrs);
101107
}
102-
103-
execute() {
108+
ZoneQueueRunner.prototype.execute = function () {
104109
if(Zone.current !== ambientZone) throw new Error("Unexpected Zone: " + Zone.current.name);
105110
testProxyZone = ambientZone.fork(new ProxyZoneSpec());
106111
if (!Zone.currentTask) {
@@ -109,10 +114,12 @@
109114
// addEventListener callback would think that it is the top most task and would
110115
// drain the microtask queue on element.click() which would be incorrect.
111116
// For this reason we always force a task when running jasmine tests.
112-
Zone.current.scheduleMicroTask('jasmine.execute().forceTask', () => super.execute());
117+
Zone.current.scheduleMicroTask('jasmine.execute().forceTask',
118+
() => QueueRunner.prototype.execute.call(this));
113119
} else {
114-
super.execute();
120+
_super.prototype.execute.call(this);
115121
}
116-
}
117-
};
122+
};
123+
return ZoneQueueRunner;
124+
}(QueueRunner));
118125
})();

0 commit comments

Comments
 (0)