evergreen 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -0
- data/bin/evergreen +18 -0
- data/lib/evergreen.rb +44 -0
- data/lib/evergreen/cli.rb +23 -0
- data/lib/evergreen/evergreen.js +3 -0
- data/lib/evergreen/runner.rb +56 -0
- data/lib/evergreen/server.rb +31 -0
- data/lib/evergreen/spec.rb +60 -0
- data/lib/evergreen/version.rb +3 -0
- data/lib/evergreen/views/list.erb +6 -0
- data/lib/evergreen/views/spec.erb +37 -0
- data/lib/jasmine/MIT.LICENSE +20 -0
- data/lib/jasmine/README.markdown +489 -0
- data/lib/jasmine/Rakefile +146 -0
- data/lib/jasmine/cruise_config.rb +21 -0
- data/lib/jasmine/doc/files.html +460 -0
- data/lib/jasmine/doc/index.html +322 -0
- data/lib/jasmine/doc/symbols/_global_.html +918 -0
- data/lib/jasmine/doc/symbols/jasmine.Block.html +417 -0
- data/lib/jasmine/doc/symbols/jasmine.Clock.html +678 -0
- data/lib/jasmine/doc/symbols/jasmine.Env.html +1169 -0
- data/lib/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
- data/lib/jasmine/doc/symbols/jasmine.Matchers.html +1474 -0
- data/lib/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
- data/lib/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
- data/lib/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
- data/lib/jasmine/doc/symbols/jasmine.Runner.html +710 -0
- data/lib/jasmine/doc/symbols/jasmine.Spec.html +1253 -0
- data/lib/jasmine/doc/symbols/jasmine.Spy.html +855 -0
- data/lib/jasmine/doc/symbols/jasmine.Suite.html +705 -0
- data/lib/jasmine/doc/symbols/jasmine.html +1345 -0
- data/lib/jasmine/doc/symbols/jasmine.util.html +535 -0
- data/lib/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +124 -0
- data/lib/jasmine/doc/symbols/src/src_Block.js.html +29 -0
- data/lib/jasmine/doc/symbols/src/src_Env.js.html +248 -0
- data/lib/jasmine/doc/symbols/src/src_JsApiReporter.js.html +111 -0
- data/lib/jasmine/doc/symbols/src/src_Matchers.js.html +344 -0
- data/lib/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
- data/lib/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
- data/lib/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +130 -0
- data/lib/jasmine/doc/symbols/src/src_Queue.js.html +102 -0
- data/lib/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
- data/lib/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
- data/lib/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
- data/lib/jasmine/doc/symbols/src/src_Spec.js.html +214 -0
- data/lib/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
- data/lib/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
- data/lib/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
- data/lib/jasmine/doc/symbols/src/src_base.js.html +585 -0
- data/lib/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
- data/lib/jasmine/doc/symbols/src/src_util.js.html +75 -0
- data/lib/jasmine/example/example_runner.html +22 -0
- data/lib/jasmine/example/spec/example_suite.js +11 -0
- data/lib/jasmine/images/fail-16.png +0 -0
- data/lib/jasmine/images/fail.png +0 -0
- data/lib/jasmine/images/go-16.png +0 -0
- data/lib/jasmine/images/go.png +0 -0
- data/lib/jasmine/images/pending-16.png +0 -0
- data/lib/jasmine/images/pending.png +0 -0
- data/lib/jasmine/images/question-bk.png +0 -0
- data/lib/jasmine/images/questionbk-16.png +0 -0
- data/lib/jasmine/images/spinner.gif +0 -0
- data/lib/jasmine/lib/TrivialReporter.js +171 -0
- data/lib/jasmine/lib/consolex.js +28 -0
- data/lib/jasmine/lib/jasmine-0.10.4.js +2371 -0
- data/lib/jasmine/lib/jasmine.css +166 -0
- data/lib/jasmine/lib/json2.js +478 -0
- data/lib/jasmine/spec/jasmine_helper.rb +44 -0
- data/lib/jasmine/spec/jasmine_spec.rb +31 -0
- data/lib/jasmine/spec/runner.html +80 -0
- data/lib/jasmine/spec/saucelabs.yml +24 -0
- data/lib/jasmine/spec/suites/CustomMatchersSpec.js +112 -0
- data/lib/jasmine/spec/suites/EnvSpec.js +158 -0
- data/lib/jasmine/spec/suites/ExceptionsSpec.js +107 -0
- data/lib/jasmine/spec/suites/JsApiReporterSpec.js +96 -0
- data/lib/jasmine/spec/suites/MatchersSpec.js +709 -0
- data/lib/jasmine/spec/suites/MockClockSpec.js +34 -0
- data/lib/jasmine/spec/suites/MultiReporterSpec.js +30 -0
- data/lib/jasmine/spec/suites/NestedResultsSpec.js +54 -0
- data/lib/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
- data/lib/jasmine/spec/suites/QueueSpec.js +23 -0
- data/lib/jasmine/spec/suites/ReporterSpec.js +60 -0
- data/lib/jasmine/spec/suites/RunnerSpec.js +267 -0
- data/lib/jasmine/spec/suites/SpecRunningSpec.js +1195 -0
- data/lib/jasmine/spec/suites/SpecSpec.js +110 -0
- data/lib/jasmine/spec/suites/SpySpec.js +201 -0
- data/lib/jasmine/spec/suites/SuiteSpec.js +120 -0
- data/lib/jasmine/spec/suites/TrivialReporterSpec.js +158 -0
- data/lib/jasmine/spec/suites/UtilSpec.js +40 -0
- data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +88 -0
- data/lib/jasmine/src/Block.js +22 -0
- data/lib/jasmine/src/Env.js +263 -0
- data/lib/jasmine/src/JsApiReporter.js +104 -0
- data/lib/jasmine/src/Matchers.js +336 -0
- data/lib/jasmine/src/MultiReporter.js +28 -0
- data/lib/jasmine/src/NestedResults.js +80 -0
- data/lib/jasmine/src/PrettyPrinter.js +122 -0
- data/lib/jasmine/src/Queue.js +94 -0
- data/lib/jasmine/src/Reporter.js +27 -0
- data/lib/jasmine/src/Reporters.js +43 -0
- data/lib/jasmine/src/Runner.js +77 -0
- data/lib/jasmine/src/Spec.js +206 -0
- data/lib/jasmine/src/Suite.js +82 -0
- data/lib/jasmine/src/WaitsBlock.js +13 -0
- data/lib/jasmine/src/WaitsForBlock.js +37 -0
- data/lib/jasmine/src/base.js +586 -0
- data/lib/jasmine/src/mock-timeout.js +177 -0
- data/lib/jasmine/src/util.js +67 -0
- data/lib/jasmine/src/version.json +5 -0
- metadata +238 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
describe("jasmine.util", function() {
|
2
|
+
describe("extend", function () {
|
3
|
+
it("should add properies to a destination object ", function() {
|
4
|
+
var destination = {baz: 'baz'};
|
5
|
+
jasmine.util.extend(destination, {
|
6
|
+
foo: 'foo', bar: 'bar'
|
7
|
+
});
|
8
|
+
expect(destination).toEqual({foo: 'foo', bar: 'bar', baz: 'baz'});
|
9
|
+
});
|
10
|
+
|
11
|
+
it("should replace properies that already exist on a destination object", function() {
|
12
|
+
var destination = {foo: 'foo'};
|
13
|
+
jasmine.util.extend(destination, {
|
14
|
+
foo: 'bar'
|
15
|
+
});
|
16
|
+
expect(destination).toEqual({foo: 'bar'});
|
17
|
+
jasmine.util.extend(destination, {
|
18
|
+
foo: null
|
19
|
+
});
|
20
|
+
expect(destination).toEqual({foo: null});
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
24
|
+
describe("isArray_", function() {
|
25
|
+
it("should return true if the argument is an array", function() {
|
26
|
+
expect(jasmine.isArray_([])).toBe(true);
|
27
|
+
expect(jasmine.isArray_(['a'])).toBe(true);
|
28
|
+
expect(jasmine.isArray_(new Array())).toBe(true);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("should return false if the argument is not an array", function() {
|
32
|
+
expect(jasmine.isArray_(undefined)).toBe(false);
|
33
|
+
expect(jasmine.isArray_({})).toBe(false);
|
34
|
+
expect(jasmine.isArray_(function() {})).toBe(false);
|
35
|
+
expect(jasmine.isArray_('foo')).toBe(false);
|
36
|
+
expect(jasmine.isArray_(5)).toBe(false);
|
37
|
+
expect(jasmine.isArray_(null)).toBe(false);
|
38
|
+
});
|
39
|
+
});
|
40
|
+
});
|
@@ -0,0 +1,88 @@
|
|
1
|
+
describe('WaitsForBlock', function () {
|
2
|
+
var env, suite, timeout, spec, message, onComplete, fakeTimer;
|
3
|
+
beforeEach(function() {
|
4
|
+
env = new jasmine.Env();
|
5
|
+
env.updateInterval = 0;
|
6
|
+
suite = new jasmine.Suite(env, 'suite 1');
|
7
|
+
timeout = 1000;
|
8
|
+
spec = new jasmine.Spec(env, suite);
|
9
|
+
message = "some error message";
|
10
|
+
onComplete = jasmine.createSpy("onComplete");
|
11
|
+
});
|
12
|
+
|
13
|
+
it('onComplete should be called if the latchFunction returns true', function () {
|
14
|
+
var latchFunction = function() {
|
15
|
+
return true;
|
16
|
+
};
|
17
|
+
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
18
|
+
expect(onComplete).wasNotCalled();
|
19
|
+
block.execute(onComplete);
|
20
|
+
expect(onComplete).wasCalled();
|
21
|
+
});
|
22
|
+
|
23
|
+
it('latchFunction should run in same scope as spec', function () {
|
24
|
+
var result;
|
25
|
+
var latchFunction = function() {
|
26
|
+
result = this.scopedValue;
|
27
|
+
};
|
28
|
+
spec.scopedValue = 'foo';
|
29
|
+
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
30
|
+
block.execute(onComplete);
|
31
|
+
expect(result).toEqual('foo');
|
32
|
+
});
|
33
|
+
|
34
|
+
it('should fail spec and call onComplete if there is an error in the latchFunction', function() {
|
35
|
+
var latchFunction = jasmine.createSpy('latchFunction').andThrow('some error');
|
36
|
+
spyOn(spec, 'fail');
|
37
|
+
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
38
|
+
block.execute(onComplete);
|
39
|
+
expect(spec.fail).wasCalledWith('some error');
|
40
|
+
expect(onComplete).wasCalled();
|
41
|
+
});
|
42
|
+
|
43
|
+
describe("if latchFunction returns false", function() {
|
44
|
+
var latchFunction, fakeTimer;
|
45
|
+
beforeEach(function() {
|
46
|
+
latchFunction = jasmine.createSpy('latchFunction').andReturn(false);
|
47
|
+
fakeTimer = new jasmine.FakeTimer();
|
48
|
+
env.setTimeout = fakeTimer.setTimeout;
|
49
|
+
env.clearTimeout = fakeTimer.clearTimeout;
|
50
|
+
env.setInterval = fakeTimer.setInterval;
|
51
|
+
env.clearInterval = fakeTimer.clearInterval;
|
52
|
+
});
|
53
|
+
|
54
|
+
it('latchFunction should be retried after 100 ms', function () {
|
55
|
+
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
56
|
+
expect(latchFunction).wasNotCalled();
|
57
|
+
block.execute(onComplete);
|
58
|
+
expect(latchFunction.callCount).toEqual(1);
|
59
|
+
fakeTimer.tick(50);
|
60
|
+
expect(latchFunction.callCount).toEqual(1);
|
61
|
+
fakeTimer.tick(50);
|
62
|
+
expect(latchFunction.callCount).toEqual(2);
|
63
|
+
});
|
64
|
+
|
65
|
+
it('onComplete should be called if latchFunction returns true before timeout', function () {
|
66
|
+
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
67
|
+
expect(onComplete).wasNotCalled();
|
68
|
+
block.execute(onComplete);
|
69
|
+
expect(onComplete).wasNotCalled();
|
70
|
+
latchFunction.andReturn(true);
|
71
|
+
fakeTimer.tick(100);
|
72
|
+
expect(onComplete).wasCalled();
|
73
|
+
});
|
74
|
+
|
75
|
+
it('spec should fail with the passed message if the timeout is reached (and not call onComplete)', function () {
|
76
|
+
spyOn(spec, 'fail');
|
77
|
+
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
78
|
+
block.execute(onComplete);
|
79
|
+
expect(spec.fail).wasNotCalled();
|
80
|
+
fakeTimer.tick(timeout);
|
81
|
+
expect(spec.fail).wasCalled();
|
82
|
+
var failMessage = spec.fail.mostRecentCall.args[0].message;
|
83
|
+
expect(failMessage).toMatch(message);
|
84
|
+
expect(onComplete).wasNotCalled();
|
85
|
+
|
86
|
+
});
|
87
|
+
});
|
88
|
+
});
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Blocks are functions with executable code that make up a spec.
|
3
|
+
*
|
4
|
+
* @constructor
|
5
|
+
* @param {jasmine.Env} env
|
6
|
+
* @param {Function} func
|
7
|
+
* @param {jasmine.Spec} spec
|
8
|
+
*/
|
9
|
+
jasmine.Block = function(env, func, spec) {
|
10
|
+
this.env = env;
|
11
|
+
this.func = func;
|
12
|
+
this.spec = spec;
|
13
|
+
};
|
14
|
+
|
15
|
+
jasmine.Block.prototype.execute = function(onComplete) {
|
16
|
+
try {
|
17
|
+
this.func.apply(this.spec);
|
18
|
+
} catch (e) {
|
19
|
+
this.spec.fail(e);
|
20
|
+
}
|
21
|
+
onComplete();
|
22
|
+
};
|
@@ -0,0 +1,263 @@
|
|
1
|
+
/**
|
2
|
+
* Environment for Jasmine
|
3
|
+
*
|
4
|
+
* @constructor
|
5
|
+
*/
|
6
|
+
jasmine.Env = function() {
|
7
|
+
this.currentSpec = null;
|
8
|
+
this.currentSuite = null;
|
9
|
+
this.currentRunner_ = new jasmine.Runner(this);
|
10
|
+
|
11
|
+
this.reporter = new jasmine.MultiReporter();
|
12
|
+
|
13
|
+
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
14
|
+
this.lastUpdate = 0;
|
15
|
+
this.specFilter = function() {
|
16
|
+
return true;
|
17
|
+
};
|
18
|
+
|
19
|
+
this.nextSpecId_ = 0;
|
20
|
+
this.nextSuiteId_ = 0;
|
21
|
+
this.equalityTesters_ = [];
|
22
|
+
|
23
|
+
// wrap matchers
|
24
|
+
this.matchersClass = function() {
|
25
|
+
jasmine.Matchers.apply(this, arguments);
|
26
|
+
};
|
27
|
+
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
|
28
|
+
|
29
|
+
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
|
30
|
+
};
|
31
|
+
|
32
|
+
|
33
|
+
jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
|
34
|
+
jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
35
|
+
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
36
|
+
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* @returns an object containing jasmine version build info, if set.
|
40
|
+
*/
|
41
|
+
jasmine.Env.prototype.version = function () {
|
42
|
+
if (jasmine.version_) {
|
43
|
+
return jasmine.version_;
|
44
|
+
} else {
|
45
|
+
throw new Error('Version not set');
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @returns string containing jasmine version build info, if set.
|
51
|
+
*/
|
52
|
+
jasmine.Env.prototype.versionString = function() {
|
53
|
+
if (jasmine.version_) {
|
54
|
+
var version = this.version();
|
55
|
+
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
|
56
|
+
} else {
|
57
|
+
return "version unknown";
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @returns a sequential integer starting at 0
|
63
|
+
*/
|
64
|
+
jasmine.Env.prototype.nextSpecId = function () {
|
65
|
+
return this.nextSpecId_++;
|
66
|
+
};
|
67
|
+
|
68
|
+
/**
|
69
|
+
* @returns a sequential integer starting at 0
|
70
|
+
*/
|
71
|
+
jasmine.Env.prototype.nextSuiteId = function () {
|
72
|
+
return this.nextSuiteId_++;
|
73
|
+
};
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Register a reporter to receive status updates from Jasmine.
|
77
|
+
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
78
|
+
*/
|
79
|
+
jasmine.Env.prototype.addReporter = function(reporter) {
|
80
|
+
this.reporter.addReporter(reporter);
|
81
|
+
};
|
82
|
+
|
83
|
+
jasmine.Env.prototype.execute = function() {
|
84
|
+
this.currentRunner_.execute();
|
85
|
+
};
|
86
|
+
|
87
|
+
jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
88
|
+
var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
|
89
|
+
|
90
|
+
var parentSuite = this.currentSuite;
|
91
|
+
if (parentSuite) {
|
92
|
+
parentSuite.add(suite);
|
93
|
+
} else {
|
94
|
+
this.currentRunner_.add(suite);
|
95
|
+
}
|
96
|
+
|
97
|
+
this.currentSuite = suite;
|
98
|
+
|
99
|
+
var declarationError = null;
|
100
|
+
try {
|
101
|
+
specDefinitions.call(suite);
|
102
|
+
} catch(e) {
|
103
|
+
declarationError = e;
|
104
|
+
}
|
105
|
+
|
106
|
+
this.currentSuite = parentSuite;
|
107
|
+
|
108
|
+
if (declarationError) {
|
109
|
+
this.it("encountered a declaration exception", function() {
|
110
|
+
throw declarationError;
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
return suite;
|
115
|
+
};
|
116
|
+
|
117
|
+
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
|
118
|
+
if (this.currentSuite) {
|
119
|
+
this.currentSuite.beforeEach(beforeEachFunction);
|
120
|
+
} else {
|
121
|
+
this.currentRunner_.beforeEach(beforeEachFunction);
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
jasmine.Env.prototype.currentRunner = function () {
|
126
|
+
return this.currentRunner_;
|
127
|
+
};
|
128
|
+
|
129
|
+
jasmine.Env.prototype.afterEach = function(afterEachFunction) {
|
130
|
+
if (this.currentSuite) {
|
131
|
+
this.currentSuite.afterEach(afterEachFunction);
|
132
|
+
} else {
|
133
|
+
this.currentRunner_.afterEach(afterEachFunction);
|
134
|
+
}
|
135
|
+
|
136
|
+
};
|
137
|
+
|
138
|
+
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
139
|
+
return {
|
140
|
+
execute: function() {
|
141
|
+
}
|
142
|
+
};
|
143
|
+
};
|
144
|
+
|
145
|
+
jasmine.Env.prototype.it = function(description, func) {
|
146
|
+
var spec = new jasmine.Spec(this, this.currentSuite, description);
|
147
|
+
this.currentSuite.add(spec);
|
148
|
+
this.currentSpec = spec;
|
149
|
+
|
150
|
+
if (func) {
|
151
|
+
spec.runs(func);
|
152
|
+
}
|
153
|
+
|
154
|
+
return spec;
|
155
|
+
};
|
156
|
+
|
157
|
+
jasmine.Env.prototype.xit = function(desc, func) {
|
158
|
+
return {
|
159
|
+
id: this.nextSpecId(),
|
160
|
+
runs: function() {
|
161
|
+
}
|
162
|
+
};
|
163
|
+
};
|
164
|
+
|
165
|
+
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
|
166
|
+
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
|
167
|
+
return true;
|
168
|
+
}
|
169
|
+
|
170
|
+
a.__Jasmine_been_here_before__ = b;
|
171
|
+
b.__Jasmine_been_here_before__ = a;
|
172
|
+
|
173
|
+
var hasKey = function(obj, keyName) {
|
174
|
+
return obj != null && obj[keyName] !== jasmine.undefined;
|
175
|
+
};
|
176
|
+
|
177
|
+
for (var property in b) {
|
178
|
+
if (!hasKey(a, property) && hasKey(b, property)) {
|
179
|
+
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
180
|
+
}
|
181
|
+
}
|
182
|
+
for (property in a) {
|
183
|
+
if (!hasKey(b, property) && hasKey(a, property)) {
|
184
|
+
mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
|
185
|
+
}
|
186
|
+
}
|
187
|
+
for (property in b) {
|
188
|
+
if (property == '__Jasmine_been_here_before__') continue;
|
189
|
+
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
|
190
|
+
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
|
195
|
+
mismatchValues.push("arrays were not the same length");
|
196
|
+
}
|
197
|
+
|
198
|
+
delete a.__Jasmine_been_here_before__;
|
199
|
+
delete b.__Jasmine_been_here_before__;
|
200
|
+
return (mismatchKeys.length == 0 && mismatchValues.length == 0);
|
201
|
+
};
|
202
|
+
|
203
|
+
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
204
|
+
mismatchKeys = mismatchKeys || [];
|
205
|
+
mismatchValues = mismatchValues || [];
|
206
|
+
|
207
|
+
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
208
|
+
var equalityTester = this.equalityTesters_[i];
|
209
|
+
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
210
|
+
if (result !== jasmine.undefined) return result;
|
211
|
+
}
|
212
|
+
|
213
|
+
if (a === b) return true;
|
214
|
+
|
215
|
+
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
216
|
+
return (a == jasmine.undefined && b == jasmine.undefined);
|
217
|
+
}
|
218
|
+
|
219
|
+
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
220
|
+
return a === b;
|
221
|
+
}
|
222
|
+
|
223
|
+
if (a instanceof Date && b instanceof Date) {
|
224
|
+
return a.getTime() == b.getTime();
|
225
|
+
}
|
226
|
+
|
227
|
+
if (a instanceof jasmine.Matchers.Any) {
|
228
|
+
return a.matches(b);
|
229
|
+
}
|
230
|
+
|
231
|
+
if (b instanceof jasmine.Matchers.Any) {
|
232
|
+
return b.matches(a);
|
233
|
+
}
|
234
|
+
|
235
|
+
if (jasmine.isString_(a) && jasmine.isString_(b)) {
|
236
|
+
return (a == b);
|
237
|
+
}
|
238
|
+
|
239
|
+
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
240
|
+
return (a == b);
|
241
|
+
}
|
242
|
+
|
243
|
+
if (typeof a === "object" && typeof b === "object") {
|
244
|
+
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
245
|
+
}
|
246
|
+
|
247
|
+
//Straight check
|
248
|
+
return (a === b);
|
249
|
+
};
|
250
|
+
|
251
|
+
jasmine.Env.prototype.contains_ = function(haystack, needle) {
|
252
|
+
if (jasmine.isArray_(haystack)) {
|
253
|
+
for (var i = 0; i < haystack.length; i++) {
|
254
|
+
if (this.equals_(haystack[i], needle)) return true;
|
255
|
+
}
|
256
|
+
return false;
|
257
|
+
}
|
258
|
+
return haystack.indexOf(needle) >= 0;
|
259
|
+
};
|
260
|
+
|
261
|
+
jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
|
262
|
+
this.equalityTesters_.push(equalityTester);
|
263
|
+
};
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/** JavaScript API reporter.
|
2
|
+
*
|
3
|
+
* @constructor
|
4
|
+
*/
|
5
|
+
jasmine.JsApiReporter = function() {
|
6
|
+
this.started = false;
|
7
|
+
this.finished = false;
|
8
|
+
this.suites_ = [];
|
9
|
+
this.results_ = {};
|
10
|
+
};
|
11
|
+
|
12
|
+
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
|
13
|
+
this.started = true;
|
14
|
+
var suites = runner.topLevelSuites();
|
15
|
+
for (var i = 0; i < suites.length; i++) {
|
16
|
+
var suite = suites[i];
|
17
|
+
this.suites_.push(this.summarize_(suite));
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
jasmine.JsApiReporter.prototype.suites = function() {
|
22
|
+
return this.suites_;
|
23
|
+
};
|
24
|
+
|
25
|
+
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
26
|
+
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
27
|
+
var summary = {
|
28
|
+
id: suiteOrSpec.id,
|
29
|
+
name: suiteOrSpec.description,
|
30
|
+
type: isSuite ? 'suite' : 'spec',
|
31
|
+
children: []
|
32
|
+
};
|
33
|
+
|
34
|
+
if (isSuite) {
|
35
|
+
var children = suiteOrSpec.children();
|
36
|
+
for (var i = 0; i < children.length; i++) {
|
37
|
+
summary.children.push(this.summarize_(children[i]));
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return summary;
|
41
|
+
};
|
42
|
+
|
43
|
+
jasmine.JsApiReporter.prototype.results = function() {
|
44
|
+
return this.results_;
|
45
|
+
};
|
46
|
+
|
47
|
+
jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
|
48
|
+
return this.results_[specId];
|
49
|
+
};
|
50
|
+
|
51
|
+
//noinspection JSUnusedLocalSymbols
|
52
|
+
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
|
53
|
+
this.finished = true;
|
54
|
+
};
|
55
|
+
|
56
|
+
//noinspection JSUnusedLocalSymbols
|
57
|
+
jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
|
58
|
+
};
|
59
|
+
|
60
|
+
//noinspection JSUnusedLocalSymbols
|
61
|
+
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
|
62
|
+
this.results_[spec.id] = {
|
63
|
+
messages: spec.results().getItems(),
|
64
|
+
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
65
|
+
};
|
66
|
+
};
|
67
|
+
|
68
|
+
//noinspection JSUnusedLocalSymbols
|
69
|
+
jasmine.JsApiReporter.prototype.log = function(str) {
|
70
|
+
};
|
71
|
+
|
72
|
+
jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
|
73
|
+
var results = {};
|
74
|
+
for (var i = 0; i < specIds.length; i++) {
|
75
|
+
var specId = specIds[i];
|
76
|
+
results[specId] = this.summarizeResult_(this.results_[specId]);
|
77
|
+
}
|
78
|
+
return results;
|
79
|
+
};
|
80
|
+
|
81
|
+
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
82
|
+
var summaryMessages = [];
|
83
|
+
var messagesLength = result.messages.length
|
84
|
+
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
|
85
|
+
var resultMessage = result.messages[messageIndex];
|
86
|
+
summaryMessages.push({
|
87
|
+
text: resultMessage.text,
|
88
|
+
passed: resultMessage.passed ? resultMessage.passed() : true,
|
89
|
+
type: resultMessage.type,
|
90
|
+
message: resultMessage.message,
|
91
|
+
trace: {
|
92
|
+
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
|
93
|
+
}
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
var summaryResult = {
|
98
|
+
result : result.result,
|
99
|
+
messages : summaryMessages
|
100
|
+
};
|
101
|
+
|
102
|
+
return summaryResult;
|
103
|
+
};
|
104
|
+
|