-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmethods.e2e.tests.js
83 lines (78 loc) · 2.35 KB
/
methods.e2e.tests.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import Meteor from 'meteor/lmieulet:meteor-coverage';
import chai from 'chai';
const {assert, expect, should} = chai;
var _should = should();
var testCoverage = function(done, operation, reportType) {
this.timeout(0);
try {
let params = operation === 'export' ? [reportType] : [];
params.push(function (err) {
assert.isUndefined(err);
done();
});
Meteor[`${operation}Coverage`].apply(this, params);
} catch (e) {
console.error(e, e.stack);
done(e);
}
};
describe('meteor-coverage', function () {
it('send client coverage', function (done) {
this.timeout(10000);
try {
Meteor.sendCoverage(
function (stats, err) {
assert.isTrue(stats.TOTAL > 0, 'no client coverage');
assert.isTrue(stats.SUCCESS > 0, 'none of the client coverage have been saved');
assert.isTrue(stats.FAILED === 0, 'an export failed');
done();
}
);
} catch (e) {
console.error(e, e.stack);
done(e);
}
});
// test implemented report types
let coverage = {
export: ['coverage', 'html', 'json', 'json-summary', 'lcovonly', 'remap', 'text-summary'],
import: ['coverage']
};
for (let operation in coverage) {
if (Object.hasOwn(coverage, operation)) {
coverage[operation].forEach(function (reportType) {
it(`${operation} [${reportType}]`, function (done) {
testCoverage.call(this, done, operation, reportType); // pass mocha context
});
});
}
}
// test non-implemented report types
let reportTypes = {
disallowed: ['', 'none', 'random-invented'],
pending: ['clover', 'cobertura', 'lcov', 'text', 'text-lcov']
};
for (let group in reportTypes) {
if (Object.hasOwn(reportTypes,group)) {
reportTypes[group].forEach(function (reportType) {
it(`export [${reportType}] should fail`, function (done) {
this.timeout(0);
try {
Meteor.exportCoverage(reportType, function (err) {
if (group === 'disallowed') {
expect(err).to.be.undefined;
} else {
err.should.be.a('string');
assert.isTrue(err.startsWith('Error: '));
}
done();
});
} catch (e) {
console.error(e, e.stack);
done(e);
}
});
});
}
}
});