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
|
/**
* @fileoverview Jasmine JsTestDriver Adapter.
* @author ibolmo@gmail.com (Olmo Maldonado)
*/
(function() {
// Suite/TestCase before and after function stacks.
var before = [];
var after = [];
jasmine.Env.prototype.describe = (function(describe){
// TODO(ibolmo): Support nested describes.
return function(description, specDefinitions){
this.currentTestCase = TestCase(description);
return describe.call(this, description, specDefinitions);
};
})(jasmine.Env.prototype.describe);
jasmine.Env.prototype.it = (function(it){
return function(desc, func){
var spec = it.call(this, desc, func);
this.currentTestCase.prototype['test that it ' + desc] = func;
return spec;
};
})(jasmine.Env.prototype.it);
jasmine.Env.prototype.beforeEach = (function(beforeEach){
// TODO(ibolmo): Support beforeEach TestCase.
return function(beforeEachFunction) {
beforeEach.call(this, beforeEachFunction);
if (this.currentTestCase) {
this.currentTestCase.prototype.setUp = beforeEachFunction;
} else {
before.push(beforeEachFunction);
}
};
})(jasmine.Env.prototype.beforeEach);
jasmine.Env.prototype.afterEach = (function(afterEach){
// TODO(ibolmo): Support afterEach TestCase.
return function(afterEachFunction) {
afterEach.call(this, afterEachFunction);
if (this.currentTestCase) {
this.currentTestCase.prototype.tearDown = afterEachFunction;
} else {
after.push(afterEachFunction);
}
};
})(jasmine.Env.prototype.afterEach);
jasmine.NestedResults.prototype.addResult = (function(addResult){
return function(result) {
addResult.call(this, result);
if (result.type != 'MessageResult' && !result.passed()) fail(result.message);
};
})(jasmine.NestedResults.prototype.addResult);
jstestdriver.plugins.TestRunnerPlugin.prototype.runTestConfiguration = (function(runTestConfiguration){
return function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){
for (var i = 0, l = before.length; i < l; i++) before[i]();
onTestRunConfigurationComplete = (function(configurationComplete){
return function() {
for (var i = 0, l = after.length; i < l; i++) after[i]();
configurationComplete();
};
})(onTestRunConfigurationComplete);
runTestConfiguration.call(this, testRunConfiguration, onTestDone, onTestRunConfigurationComplete);
};
})(jstestdriver.plugins.TestRunnerPlugin.prototype.runTestConfiguration);
// Reset environment with overriden methods.
jasmine.currentEnv_ = null;
jasmine.getEnv();
})();
|