This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathstats.test.js
More file actions
98 lines (78 loc) · 2.59 KB
/
Copy pathstats.test.js
File metadata and controls
98 lines (78 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
AC94
div>
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
var EventEmitter = require('events').EventEmitter,
assert = require('chai').assert,
inherit = require('inherit'),
Stats = require('../lib/stats'),
RunnerEvents = require('../lib/constants/runner-events');
describe('stats', function() {
var stats;
beforeEach(function() {
stats = new Stats();
});
it('should return \'undefined\' before adding keys', function() {
assert.isUndefined(stats.get('counter'));
});
it('should allow to add new key', function() {
stats.add('counter');
assert.equal(stats.get('counter'), 1);
});
it('should increment existing keys', function() {
stats.add('counter');
stats.add('counter');
assert.equal(stats.get('counter'), 2);
});
it('should return all full stat', function() {
stats.add('counter');
stats.add('counter');
stats.add('counter');
stats.add('counter2');
stats.add('counter3');
stats.add('counter3');
assert.deepEqual(stats.get(), {
counter: 3,
counter2: 1,
counter3: 2
});
});
});
describe('stats listener', function() {
var stats,
Runner = inherit(EventEmitter, {}),
runner;
beforeEach(function() {
runner = new Runner();
stats = new Stats(runner);
});
it('should return undefined before triggering any events', function() {
assert.isUndefined(stats.get('total'));
});
it('should count on beginState event', function() {
runner.emit(RunnerEvents.BEGIN_STATE);
assert.equal(stats.get('total'), 1);
});
it('should count on skipState event', function() {
runner.emit(RunnerEvents.SKIP_STATE);
assert.equal(stats.get('total'), 1);
assert.equal(stats.get('skipped'), 1);
});
it('should count on warning event', function() {
runner.emit(RunnerEvents.WARNING);
assert.equal(stats.get('warned'), 1);
});
it('should count on error event', function() {
runner.emit(RunnerEvents.ERROR);
assert.equal(stats.get('errored'), 1);
});
it('should count on capture event', function() {
runner.emit(RunnerEvents.CAPTURE);
assert.equal(stats.get('gathered'), 1);
});
it('should count test passed', function() {
runner.emit(RunnerEvents.END_TEST, {equal: true});
assert.equal(stats.get('passed'), 1);
});
it('should count test failed', function() {
runner.emit(RunnerEvents.END_TEST, {equal: false});
assert.equal(stats.get('failed'), 1);
});
});