-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient-fixture.js
47 lines (41 loc) · 1.59 KB
/
client-fixture.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*jshint -W117, -W030 */
(function () {
'use strict';
Meteor.call('velocityIsMirror', function (e, isMirror) {
if (isMirror) {
/**
* We register every client that connects to the mirror so that we can get back the
* coverage reports from all of them
*/
Meteor.call('velocityRegisterCoverageClient', Meteor.connection._lastSessionId);
/**
* When the coverage reporter is called by velocity, it creates an timestamped object in the VelocityCoverageMessages collection
* This client listens to that collection, and then posts back its coverage report into the VelocityClientCoverage collection
*/
VelocityCoverageMessages.find().observeChanges({
changed: function () {
Meteor.call('velocityClientCoverageInsert', {
coverage: JSON.stringify(__coverage__),
connectionId: Meteor.connection._lastSessionId
});
window.coverageCollected = true;
}
});
/**
* We also need to handle the case when the test navigates away from the app. In this case
* we post the current coverage object back to the server which only keeps the coverage object,
* until all tests are completed.
*/
Meteor.startup(function () {
$(window).bind('beforeunload', function () {
if (!window.coverageCollected) {
Meteor.call('velocityClientCoverageInsert', {
coverage: JSON.stringify(__coverage__),
connectionId: Meteor.connection._lastSessionId
});
}
});
});
}
});
})();