jasmine-core 2.9.0 → 2.99.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jasmine-core/jasmine-html.js +24 -1
- data/lib/jasmine-core/jasmine.css +1 -0
- data/lib/jasmine-core/jasmine.js +50 -6
- data/lib/jasmine-core/version.rb +1 -1
- metadata +3 -84
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +0 -270
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
- data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
- data/lib/jasmine-core/spec/core/ClockSpec.js +0 -754
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -270
- data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -63
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -68
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
- data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
- data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -337
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -620
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -79
- data/lib/jasmine-core/spec/core/SpecSpec.js +0 -441
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -356
- data/lib/jasmine-core/spec/core/SpySpec.js +0 -127
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -159
- data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -155
- data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -756
- data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
- data/lib/jasmine-core/spec/core/UtilSpec.js +0 -99
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -84
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -102
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
- data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -199
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2007
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -950
- data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
- data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
- data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -658
- data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
- data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
- data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -804
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -27
- data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
- data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
- data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
- data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -7
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -33
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -982
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -15
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -34
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
- data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
- data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,337 +0,0 @@
|
|
1
|
-
describe("jasmineUnderTest.pp", function () {
|
2
|
-
it("should wrap strings in single quotes", function() {
|
3
|
-
expect(jasmineUnderTest.pp("some string")).toEqual("'some string'");
|
4
|
-
expect(jasmineUnderTest.pp("som' string")).toEqual("'som' string'");
|
5
|
-
});
|
6
|
-
|
7
|
-
it("should stringify primitives properly", function() {
|
8
|
-
expect(jasmineUnderTest.pp(true)).toEqual("true");
|
9
|
-
expect(jasmineUnderTest.pp(false)).toEqual("false");
|
10
|
-
expect(jasmineUnderTest.pp(null)).toEqual("null");
|
11
|
-
expect(jasmineUnderTest.pp(jasmine.undefined)).toEqual("undefined");
|
12
|
-
expect(jasmineUnderTest.pp(3)).toEqual("3");
|
13
|
-
expect(jasmineUnderTest.pp(-3.14)).toEqual("-3.14");
|
14
|
-
expect(jasmineUnderTest.pp(-0)).toEqual("-0");
|
15
|
-
});
|
16
|
-
|
17
|
-
describe('stringify sets', function() {
|
18
|
-
it("should stringify sets properly", function() {
|
19
|
-
jasmine.getEnv().requireFunctioningSets();
|
20
|
-
var set = new Set();
|
21
|
-
set.add(1);
|
22
|
-
set.add(2);
|
23
|
-
expect(jasmineUnderTest.pp(set)).toEqual("Set( 1, 2 )");
|
24
|
-
});
|
25
|
-
|
26
|
-
it("should truncate sets with more elments than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
|
27
|
-
jasmine.getEnv().requireFunctioningSets();
|
28
|
-
var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
29
|
-
|
30
|
-
try {
|
31
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
32
|
-
var set = new Set();
|
33
|
-
set.add('a');
|
34
|
-
set.add('b');
|
35
|
-
set.add('c');
|
36
|
-
expect(jasmineUnderTest.pp(set)).toEqual("Set( 'a', 'b', ... )");
|
37
|
-
} finally {
|
38
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize;
|
39
|
-
}
|
40
|
-
})
|
41
|
-
});
|
42
|
-
|
43
|
-
describe('stringify maps', function() {
|
44
|
-
it("should stringify maps properly", function() {
|
45
|
-
jasmine.getEnv().requireFunctioningMaps();
|
46
|
-
var map = new Map();
|
47
|
-
map.set(1,2);
|
48
|
-
expect(jasmineUnderTest.pp(map)).toEqual("Map( [ 1, 2 ] )");
|
49
|
-
});
|
50
|
-
|
51
|
-
it("should truncate maps with more elments than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
|
52
|
-
jasmine.getEnv().requireFunctioningMaps();
|
53
|
-
var originalMaxSize = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
54
|
-
|
55
|
-
try {
|
56
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
57
|
-
var map = new Map();
|
58
|
-
map.set("a",1);
|
59
|
-
map.set("b",2);
|
60
|
-
map.set("c",3);
|
61
|
-
expect(jasmineUnderTest.pp(map)).toEqual("Map( [ 'a', 1 ], [ 'b', 2 ], ... )");
|
62
|
-
} finally {
|
63
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxSize;
|
64
|
-
}
|
65
|
-
})
|
66
|
-
});
|
67
|
-
|
68
|
-
|
69
|
-
describe('stringify arrays', function() {
|
70
|
-
it("should stringify arrays properly", function() {
|
71
|
-
expect(jasmineUnderTest.pp([1, 2])).toEqual("[ 1, 2 ]");
|
72
|
-
expect(jasmineUnderTest.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', Object({ }), undefined, null ]");
|
73
|
-
});
|
74
|
-
|
75
|
-
it("should truncate arrays that are longer than jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH", function() {
|
76
|
-
var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
77
|
-
var array = [1, 2, 3];
|
78
|
-
|
79
|
-
try {
|
80
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
81
|
-
expect(jasmineUnderTest.pp(array)).toEqual("[ 1, 2, ... ]");
|
82
|
-
} finally {
|
83
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
84
|
-
}
|
85
|
-
});
|
86
|
-
|
87
|
-
it("should stringify arrays with properties properly", function() {
|
88
|
-
var arr = [1, 2];
|
89
|
-
arr.foo = 'bar';
|
90
|
-
arr.baz = {};
|
91
|
-
expect(jasmineUnderTest.pp(arr)).toEqual("[ 1, 2, foo: 'bar', baz: Object({ }) ]");
|
92
|
-
});
|
93
|
-
|
94
|
-
it("should stringify empty arrays with properties properly", function() {
|
95
|
-
var empty = [];
|
96
|
-
empty.foo = 'bar';
|
97
|
-
empty.baz = {};
|
98
|
-
expect(jasmineUnderTest.pp(empty)).toEqual("[ foo: 'bar', baz: Object({ }) ]");
|
99
|
-
});
|
100
|
-
|
101
|
-
it("should stringify long arrays with properties properly", function() {
|
102
|
-
var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
103
|
-
var long = [1,2,3];
|
104
|
-
long.foo = 'bar';
|
105
|
-
long.baz = {};
|
106
|
-
|
107
|
-
try {
|
108
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
109
|
-
expect(jasmineUnderTest.pp(long)).toEqual("[ 1, 2, ..., foo: 'bar', baz: Object({ }) ]");
|
110
|
-
} finally {
|
111
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
112
|
-
}
|
113
|
-
});
|
114
|
-
|
115
|
-
it("should indicate circular array references", function() {
|
116
|
-
var array1 = [1, 2];
|
117
|
-
var array2 = [array1];
|
118
|
-
array1.push(array2);
|
119
|
-
expect(jasmineUnderTest.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
|
120
|
-
});
|
121
|
-
|
122
|
-
it("should not indicate circular references incorrectly", function() {
|
123
|
-
var array = [ [1] ];
|
124
|
-
expect(jasmineUnderTest.pp(array)).toEqual("[ [ 1 ] ]");
|
125
|
-
});
|
126
|
-
});
|
127
|
-
|
128
|
-
it("should stringify objects properly", function() {
|
129
|
-
expect(jasmineUnderTest.pp({foo: 'bar'})).toEqual("Object({ foo: 'bar' })");
|
130
|
-
expect(jasmineUnderTest.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("Object({ foo: 'bar', baz: 3, nullValue: null, undefinedValue: undefined })");
|
131
|
-
expect(jasmineUnderTest.pp({foo: function () {
|
132
|
-
}, bar: [1, 2, 3]})).toEqual("Object({ foo: Function, bar: [ 1, 2, 3 ] })");
|
133
|
-
});
|
134
|
-
|
135
|
-
it("should truncate objects with too many keys", function () {
|
136
|
-
var originalMaxLength = jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH;
|
137
|
-
var long = {a: 1, b: 2, c: 3};
|
138
|
-
|
139
|
-
try {
|
140
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = 2;
|
141
|
-
expect(jasmineUnderTest.pp(long)).toEqual("Object({ a: 1, b: 2, ... })");
|
142
|
-
} finally {
|
143
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_ARRAY_LENGTH = originalMaxLength;
|
144
|
-
}
|
145
|
-
});
|
146
|
-
|
147
|
-
function withMaxChars(maxChars, fn) {
|
148
|
-
var originalMaxChars = jasmineUnderTest.MAX_PRETTY_PRINT_CHARS;
|
149
|
-
|
150
|
-
try {
|
151
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_CHARS = maxChars;
|
152
|
-
fn();
|
153
|
-
} finally {
|
154
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_CHARS = originalMaxChars;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
it("should truncate outputs that are too long", function() {
|
159
|
-
var big = [
|
160
|
-
{ a: 1, b: "a long string" },
|
161
|
-
{}
|
162
|
-
];
|
163
|
-
|
164
|
-
withMaxChars(34, function() {
|
165
|
-
expect(jasmineUnderTest.pp(big)).toEqual("[ Object({ a: 1, b: 'a long st ...");
|
166
|
-
});
|
167
|
-
});
|
168
|
-
|
169
|
-
it("should not serialize more objects after hitting MAX_PRETTY_PRINT_CHARS", function() {
|
170
|
-
var a = { jasmineToString: function() { return 'object a'; } },
|
171
|
-
b = { jasmineToString: function() { return 'object b'; } },
|
172
|
-
c = { jasmineToString: jasmine.createSpy('c jasmineToString').and.returnValue('') },
|
173
|
-
d = { jasmineToString: jasmine.createSpy('d jasmineToString').and.returnValue('') };
|
174
|
-
|
175
|
-
withMaxChars(30, function() {
|
176
|
-
jasmineUnderTest.pp([{a: a, b: b, c: c}, d]);
|
177
|
-
expect(c.jasmineToString).not.toHaveBeenCalled();
|
178
|
-
expect(d.jasmineToString).not.toHaveBeenCalled();
|
179
|
-
});
|
180
|
-
});
|
181
|
-
|
182
|
-
it("should print 'null' as the constructor of an object with its own constructor property", function() {
|
183
|
-
expect(jasmineUnderTest.pp({constructor: function() {}})).toContain("null({");
|
184
|
-
expect(jasmineUnderTest.pp({constructor: 'foo'})).toContain("null({");
|
185
|
-
});
|
186
|
-
|
187
|
-
it("should not include inherited properties when stringifying an object", function() {
|
188
|
-
var SomeClass = function SomeClass() {};
|
189
|
-
SomeClass.prototype.foo = "inherited foo";
|
190
|
-
var instance = new SomeClass();
|
191
|
-
instance.bar = "my own bar";
|
192
|
-
expect(jasmineUnderTest.pp(instance)).toEqual("SomeClass({ bar: 'my own bar' })");
|
193
|
-
});
|
194
|
-
|
195
|
-
it("should not recurse objects and arrays more deeply than jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH", function() {
|
196
|
-
var originalMaxDepth = jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH;
|
197
|
-
var nestedObject = { level1: { level2: { level3: { level4: "leaf" } } } };
|
198
|
-
var nestedArray = [1, [2, [3, [4, "leaf"]]]];
|
199
|
-
|
200
|
-
try {
|
201
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 2;
|
202
|
-
expect(jasmineUnderTest.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object }) })");
|
203
|
-
expect(jasmineUnderTest.pp(nestedArray)).toEqual("[ 1, [ 2, Array ] ]");
|
204
|
-
|
205
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 3;
|
206
|
-
expect(jasmineUnderTest.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object({ level3: Object }) }) })");
|
207
|
-
expect(jasmineUnderTest.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, Array ] ] ]");
|
208
|
-
|
209
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = 4;
|
210
|
-
expect(jasmineUnderTest.pp(nestedObject)).toEqual("Object({ level1: Object({ level2: Object({ level3: Object({ level4: 'leaf' }) }) }) })");
|
211
|
-
expect(jasmineUnderTest.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, [ 4, 'leaf' ] ] ] ]");
|
212
|
-
} finally {
|
213
|
-
jasmineUnderTest.MAX_PRETTY_PRINT_DEPTH = originalMaxDepth;
|
214
|
-
}
|
215
|
-
});
|
216
|
-
|
217
|
-
it("should stringify immutable circular objects", function(){
|
218
|
-
if(Object.freeze){
|
219
|
-
var frozenObject = {foo: {bar: 'baz'}};
|
220
|
-
frozenObject.circular = frozenObject;
|
221
|
-
frozenObject = Object.freeze(frozenObject);
|
222
|
-
expect(jasmineUnderTest.pp(frozenObject)).toEqual("Object({ foo: Object({ bar: 'baz' }), circular: <circular reference: Object> })");
|
223
|
-
}
|
224
|
-
});
|
225
|
-
|
226
|
-
it("should stringify RegExp objects properly", function() {
|
227
|
-
expect(jasmineUnderTest.pp(/x|y|z/)).toEqual("/x|y|z/");
|
228
|
-
});
|
229
|
-
|
230
|
-
it("should indicate circular object references", function() {
|
231
|
-
var sampleValue = {foo: 'hello'};
|
232
|
-
sampleValue.nested = sampleValue;
|
233
|
-
expect(jasmineUnderTest.pp(sampleValue)).toEqual("Object({ foo: 'hello', nested: <circular reference: Object> })");
|
234
|
-
});
|
235
|
-
|
236
|
-
it("should indicate getters on objects as such", function() {
|
237
|
-
var sampleValue = {id: 1};
|
238
|
-
if (sampleValue.__defineGetter__) {
|
239
|
-
//not supported in IE!
|
240
|
-
sampleValue.__defineGetter__('calculatedValue', function() {
|
241
|
-
throw new Error("don't call me!");
|
242
|
-
});
|
243
|
-
}
|
244
|
-
if (sampleValue.__defineGetter__) {
|
245
|
-
expect(jasmineUnderTest.pp(sampleValue)).toEqual("Object({ id: 1, calculatedValue: <getter> })");
|
246
|
-
}
|
247
|
-
else {
|
248
|
-
expect(jasmineUnderTest.pp(sampleValue)).toEqual("Object({ id: 1 })");
|
249
|
-
}
|
250
|
-
});
|
251
|
-
|
252
|
-
it('should not do HTML escaping of strings', function() {
|
253
|
-
expect(jasmineUnderTest.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
|
254
|
-
});
|
255
|
-
|
256
|
-
it("should abbreviate the global (usually window) object", function() {
|
257
|
-
expect(jasmineUnderTest.pp(jasmine.getGlobal())).toEqual("<global>");
|
258
|
-
});
|
259
|
-
|
260
|
-
it("should stringify Date objects properly", function() {
|
261
|
-
var now = new Date();
|
262
|
-
expect(jasmineUnderTest.pp(now)).toEqual("Date(" + now.toString() + ")");
|
263
|
-
});
|
264
|
-
|
265
|
-
it("should stringify spy objects properly", function() {
|
266
|
-
var TestObject = {
|
267
|
-
someFunction: function() {}
|
268
|
-
},
|
269
|
-
env = new jasmineUnderTest.Env();
|
270
|
-
|
271
|
-
var spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() {return [];}});
|
272
|
-
|
273
|
-
spyRegistry.spyOn(TestObject, 'someFunction');
|
274
|
-
expect(jasmineUnderTest.pp(TestObject.someFunction)).toEqual("spy on someFunction");
|
275
|
-
|
276
|
-
expect(jasmineUnderTest.pp(jasmineUnderTest.createSpy("something"))).toEqual("spy on something");
|
277
|
-
});
|
278
|
-
|
279
|
-
it("should stringify objects that implement jasmineToString", function () {
|
280
|
-
var obj = {
|
281
|
-
jasmineToString: function () { return "strung"; }
|
282
|
-
};
|
283
|
-
|
284
|
-
expect(jasmineUnderTest.pp(obj)).toEqual("strung");
|
285
|
-
});
|
286
|
-
|
287
|
-
it("should stringify objects that implement custom toString", function () {
|
288
|
-
var obj = {
|
289
|
-
toString: function () { return "my toString"; }
|
290
|
-
};
|
291
|
-
|
292
|
-
expect(jasmineUnderTest.pp(obj)).toEqual("my toString");
|
293
|
-
|
294
|
-
// Simulate object from another global context (e.g. an iframe or Web Worker) that does not actually have a custom
|
295
|
-
// toString despite obj.toString !== Object.prototype.toString
|
296
|
-
var objFromOtherContext = {
|
297
|
-
foo: 'bar',
|
298
|
-
toString: function () { return Object.prototype.toString.call(this); }
|
299
|
-
};
|
300
|
-
|
301
|
-
if (jasmine.getEnv().ieVersion < 9) {
|
302
|
-
expect(jasmineUnderTest.pp(objFromOtherContext)).toEqual("Object({ foo: 'bar' })");
|
303
|
-
} else {
|
304
|
-
expect(jasmineUnderTest.pp(objFromOtherContext)).toEqual("Object({ foo: 'bar', toString: Function })");
|
305
|
-
}
|
306
|
-
});
|
307
|
-
|
308
|
-
it("should stringify objects have have a toString that isn't a function", function() {
|
309
|
-
var obj = {
|
310
|
-
toString: "foo"
|
311
|
-
};
|
312
|
-
|
313
|
-
if (jasmine.getEnv().ieVersion < 9) {
|
314
|
-
expect(jasmineUnderTest.pp(obj)).toEqual("Object({ })");
|
315
|
-
} else {
|
316
|
-
expect(jasmineUnderTest.pp(obj)).toEqual("Object({ toString: 'foo' })");
|
317
|
-
}
|
318
|
-
});
|
319
|
-
|
320
|
-
it("should stringify objects from anonymous constructors with custom toString", function () {
|
321
|
-
var MyAnonymousConstructor = (function() { return function () {}; })();
|
322
|
-
MyAnonymousConstructor.toString = function () { return ''; };
|
323
|
-
|
324
|
-
var a = new MyAnonymousConstructor();
|
325
|
-
|
326
|
-
expect(jasmineUnderTest.pp(a)).toEqual("<anonymous>({ })");
|
327
|
-
});
|
328
|
-
|
329
|
-
it("should handle objects with null prototype", function() {
|
330
|
-
if (jasmine.getEnv().ieVersion < 9) { return; }
|
331
|
-
|
332
|
-
var obj = Object.create(null);
|
333
|
-
obj.foo = 'bar';
|
334
|
-
|
335
|
-
expect(jasmineUnderTest.pp(obj)).toEqual("null({ foo: 'bar' })");
|
336
|
-
});
|
337
|
-
});
|