/
adapter.spec.js
112 lines (85 loc) · 2.8 KB
/
adapter.spec.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
Tests for adapter/qunit.src.js
These tests are executed in browser.
*/
describe('adapter qunit', function() {
var Karma = window.__karma__.constructor;
describe('reporter', function() {
var runner, tc;
beforeEach(function() {
tc = new Karma(new MockSocket(), {});
runner = new MockRunner();
reporter = new (createQUnitStartFn(tc, runner))();
});
describe('done', function() {
it('should report complete', function() {
spyOn(tc, 'complete');
runner.emit('done');
expect(tc.complete).toHaveBeenCalled();
});
});
describe('total number of tests', function() {
it('should use the tracking in qunit if available', function() {
spyOn(tc, 'info').andCallFake(function(result) {
expect(result.total).toBe(1);
});
var mockQUnitResult = {
totalTests: 1
};
runner.emit('begin', mockQUnitResult);
expect(tc.info).toHaveBeenCalled();
});
it('should use our own tracking if none is available', function() {
spyOn(tc, 'info').andCallFake(function(result) {
expect(result.total).toBe(1);
});
var mockQUnitResult = {
name: 'should do something',
module: 'desc1',
failed: 0
};
runner.emit('testStart', mockQUnitResult);
runner.emit('testDone', mockQUnitResult);
runner.emit('done');
expect(tc.info).toHaveBeenCalled();
});
});
describe('test end', function() {
it('should report result', function() {
spyOn(tc, 'result').andCallFake(function(result) {
expect(result.description).toBe('should do something');
expect(result.suite instanceof Array).toBe(true);
expect(result.success).toBe(true);
expect(result.log instanceof Array).toBe(true);
});
var mockQUnitResult = {
name: 'should do something',
module: 'desc1',
failed: 0
};
runner.emit('testStart', mockQUnitResult);
runner.emit('testDone', mockQUnitResult);
expect(tc.result).toHaveBeenCalled();
});
it('should report failed result', function() {
spyOn(tc, 'result').andCallFake(function(result) {
expect(result.success).toBe(false);
expect(result.log).toEqual(['Big trouble.\n']);
});
var mockQUnitResult = {
module: 'desc1',
failed: 1,
name: 'should do something'
};
var mockQUnitLog = {
result: false,
message: 'Big trouble.',
};
runner.emit('testStart', mockQUnitResult);
runner.emit('log', mockQUnitLog);
runner.emit('testDone', mockQUnitResult);
expect(tc.result).toHaveBeenCalled();
});
});
});
});