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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jasmine-core/jasmine-html.js +24 -1
  3. data/lib/jasmine-core/jasmine.css +1 -0
  4. data/lib/jasmine-core/jasmine.js +50 -6
  5. data/lib/jasmine-core/version.rb +1 -1
  6. metadata +3 -84
  7. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +0 -270
  8. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
  9. data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
  10. data/lib/jasmine-core/spec/core/ClockSpec.js +0 -754
  11. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -270
  12. data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
  13. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -63
  14. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -68
  15. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
  16. data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
  17. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
  18. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
  19. data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
  20. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -337
  21. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -620
  22. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -79
  23. data/lib/jasmine-core/spec/core/SpecSpec.js +0 -441
  24. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -356
  25. data/lib/jasmine-core/spec/core/SpySpec.js +0 -127
  26. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -159
  27. data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -155
  28. data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
  29. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -756
  30. data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
  31. data/lib/jasmine-core/spec/core/UtilSpec.js +0 -99
  32. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -84
  33. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
  34. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
  35. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
  36. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -102
  37. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
  38. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
  39. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -199
  40. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2007
  41. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -950
  42. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
  43. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
  44. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
  45. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -658
  46. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
  47. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
  48. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
  49. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
  50. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
  51. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
  52. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
  53. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
  54. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
  55. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
  56. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
  57. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
  58. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
  59. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
  60. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
  61. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
  62. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -804
  63. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
  64. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
  65. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
  66. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
  67. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
  68. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
  69. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
  70. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -27
  71. data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
  72. data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
  73. data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
  74. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
  75. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
  76. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -7
  77. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -33
  78. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -982
  79. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
  80. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
  81. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -15
  82. data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
  83. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
  84. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -34
  85. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
  86. data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
  87. data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,756 +0,0 @@
1
- describe("TreeProcessor", function() {
2
- var nodeNumber = 0, leafNumber = 0;
3
-
4
- function Node(attrs) {
5
- attrs = attrs || {};
6
- this.id = 'node' + nodeNumber++;
7
- this.children = attrs.children || [];
8
- this.canBeReentered = function() {
9
- return !attrs.noReenter;
10
- };
11
- this.isExecutable = function() {
12
- return attrs.executable !== false;
13
- };
14
- this.sharedUserContext = function() {
15
- return attrs.userContext || {};
16
- };
17
- this.getResult = jasmine.createSpy(this.id + '#execute');
18
- this.beforeAllFns = attrs.beforeAllFns || [];
19
- this.afterAllFns = attrs.afterAllFns || [];
20
- }
21
-
22
- function Leaf(attrs) {
23
- attrs = attrs || {};
24
- this.id = 'leaf' + leafNumber++;
25
- this.isExecutable = function() {
26
- return attrs.executable !== false;
27
- };
28
- this.execute = jasmine.createSpy(this.id + '#execute');
29
- }
30
-
31
- it("processes a single executable leaf", function() {
32
- var leaf = new Leaf(),
33
- processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
34
- result = processor.processTree();
35
-
36
- expect(result.valid).toBe(true);
37
-
38
- expect(result[leaf.id]).toEqual({
39
- executable: true,
40
- segments: jasmine.any(Array)
41
- });
42
- });
43
-
44
- it("processes a single non-executable leaf", function() {
45
- var leaf = new Leaf({ executable: false }),
46
- processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
47
- result = processor.processTree();
48
-
49
- expect(result.valid).toBe(true);
50
-
51
- expect(result[leaf.id]).toEqual({
52
- executable: false,
53
- segments: jasmine.any(Array)
54
- });
55
- });
56
-
57
- it("processes a single non-specified leaf", function() {
58
- var leaf = new Leaf(),
59
- processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [] }),
60
- result = processor.processTree();
61
-
62
- expect(result.valid).toBe(true);
63
-
64
- expect(result[leaf.id]).toEqual({
65
- executable: false,
66
- segments: jasmine.any(Array)
67
- });
68
- });
69
-
70
- it("processes a tree with a single leaf with the root specified", function() {
71
- var leaf = new Leaf(),
72
- parent = new Node({ children: [leaf] }),
73
- processor = new jasmineUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
74
- result = processor.processTree();
75
-
76
- expect(result.valid).toBe(true);
77
-
78
- expect(result[parent.id]).toEqual({
79
- executable: true,
80
- segments: jasmine.any(Array)
81
- });
82
-
83
- expect(result[leaf.id]).toEqual({
84
- executable: true,
85
- segments: jasmine.any(Array)
86
- });
87
- });
88
-
89
- it("processes a tree with a single non-executable leaf, with the root specified", function() {
90
- var leaf = new Leaf({ executable: false }),
91
- parent = new Node({ children: [leaf] }),
92
- processor = new jasmineUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
93
- result = processor.processTree();
94
-
95
- expect(result.valid).toBe(true);
96
-
97
- expect(result[parent.id]).toEqual({
98
- executable: false,
99
- segments: jasmine.any(Array)
100
- });
101
-
102
- expect(result[leaf.id]).toEqual({
103
- executable: false,
104
- segments: jasmine.any(Array)
105
- });
106
- });
107
-
108
- it("processes a complicated tree with the root specified", function() {
109
- var nonExecutable = new Leaf({ executable: false }),
110
- executable = new Leaf({ executable: true }),
111
- parent = new Node({ children: [nonExecutable, executable] }),
112
- childless = new Node(),
113
- childOfDisabled = new Leaf({ executable: true }),
114
- disabledNode = new Node({ executable: false, children: [childOfDisabled] }),
115
- root = new Node({ children: [parent, childless, disabledNode] }),
116
- processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }),
117
- result = processor.processTree();
118
-
119
- expect(result.valid).toBe(true);
120
-
121
- expect(result[root.id]).toEqual({
122
- executable: true,
123
- segments: jasmine.any(Array)
124
- });
125
-
126
- expect(result[childless.id]).toEqual({
127
- executable: false,
128
- segments: jasmine.any(Array)
129
- });
130
-
131
- expect(result[nonExecutable.id]).toEqual({
132
- executable: false,
133
- segments: jasmine.any(Array)
134
- });
135
-
136
- expect(result[executable.id]).toEqual({
137
- executable: true,
138
- segments: jasmine.any(Array)
139
- });
140
-
141
- expect(result[parent.id]).toEqual({
142
- executable: true,
143
- segments: jasmine.any(Array)
144
- });
145
-
146
- expect(result[disabledNode.id]).toEqual({
147
- executable: false,
148
- segments: jasmine.any(Array)
149
- });
150
-
151
- expect(result[childOfDisabled.id]).toEqual({
152
- executable: false,
153
- segments: jasmine.any(Array)
154
- });
155
- });
156
-
157
- it("marks the run order invalid if it would re-enter a node that does not allow re-entry", function() {
158
- var leaf1 = new Leaf(),
159
- leaf2 = new Leaf(),
160
- leaf3 = new Leaf(),
161
- reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }),
162
- root = new Node({ children: [reentered, leaf3] }),
163
- processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }),
164
- result = processor.processTree();
165
-
166
- expect(result).toEqual({ valid: false });
167
- });
168
-
169
- it("marks the run order valid if a node being re-entered allows re-entry", function() {
170
- var leaf1 = new Leaf(),
171
- leaf2 = new Leaf(),
172
- leaf3 = new Leaf(),
173
- reentered = new Node({ children: [leaf1, leaf2] }),
174
- root = new Node({ children: [reentered, leaf3] }),
175
- processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf1.id, leaf3.id, leaf2.id] }),
176
- result = processor.processTree();
177
-
178
- expect(result.valid).toBe(true);
179
- });
180
-
181
- it("marks the run order valid if a node which can't be re-entered is only entered once", function() {
182
- var leaf1 = new Leaf(),
183
- leaf2 = new Leaf(),
184
- leaf3 = new Leaf(),
185
- noReentry = new Node({ noReenter: true }),
186
- root = new Node({ children: [noReentry] }),
187
- processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [leaf2.id, leaf1.id, leaf3.id] }),
188
- result = processor.processTree();
189
-
190
- expect(result.valid).toBe(true);
191
- });
192
-
193
- it("marks the run order valid if a node which can't be re-entered is run directly", function() {
194
- var leaf1 = new Leaf(),
195
- noReentry = new Node({ noReenter: true }),
196
- root = new Node({ children: [noReentry] }),
197
- processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }),
198
- result = processor.processTree();
199
-
200
- expect(result.valid).toBe(true);
201
- });
202
-
203
- it("runs a single leaf", function() {
204
- var leaf = new Leaf(),
205
- node = new Node({ children: [leaf], userContext: { root: 'context' } }),
206
- queueRunner = jasmine.createSpy('queueRunner'),
207
- processor = new jasmineUnderTest.TreeProcessor({ tree: node, runnableIds: [leaf.id], queueRunnerFactory: queueRunner }),
208
- treeComplete = jasmine.createSpy('treeComplete');
209
-
210
- processor.execute(treeComplete);
211
-
212
- expect(queueRunner).toHaveBeenCalledWith({
213
- onComplete: treeComplete,
214
- onException: jasmine.any(Function),
215
- userContext: { root: 'context' },
216
- queueableFns: [{ fn: jasmine.any(Function) }]
217
- });
218
-
219
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
220
-
221
- expect(leaf.execute).toHaveBeenCalledWith('foo', true);
222
- });
223
-
224
- it("runs a node with no children", function() {
225
- var node = new Node({ userContext: { node: 'context' } }),
226
- root = new Node({ children: [node], userContext: { root: 'context' } }),
227
- nodeStart = jasmine.createSpy('nodeStart'),
228
- nodeComplete = jasmine.createSpy('nodeComplete'),
229
- queueRunner = jasmine.createSpy('queueRunner'),
230
- processor = new jasmineUnderTest.TreeProcessor({
231
- tree: root,
232
- runnableIds: [node.id],
233
- nodeStart: nodeStart,
234
- nodeComplete: nodeComplete,
235
- queueRunnerFactory: queueRunner
236
- }),
237
- treeComplete = jasmine.createSpy('treeComplete'),
238
- nodeDone = jasmine.createSpy('nodeDone');
239
-
240
- processor.execute(treeComplete);
241
-
242
- expect(queueRunner).toHaveBeenCalledWith({
243
- onComplete: treeComplete,
244
- onException: jasmine.any(Function),
245
- userContext: { root: 'context' },
246
- queueableFns: [{ fn: jasmine.any(Function) }]
247
- });
248
-
249
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn(nodeDone);
250
-
251
- expect(nodeStart).toHaveBeenCalledWith(node);
252
- expect(queueRunner).toHaveBeenCalledWith({
253
- onComplete: jasmine.any(Function),
254
- queueableFns: [],
255
- userContext: { node: 'context' },
256
- onException: jasmine.any(Function)
257
- });
258
-
259
- node.getResult.and.returnValue({ my: 'result' });
260
-
261
- queueRunner.calls.mostRecent().args[0].onComplete();
262
- expect(nodeComplete).toHaveBeenCalledWith(node, { my: 'result' });
263
- expect(nodeDone).toHaveBeenCalled();
264
- });
265
-
266
- it("runs a node with children", function() {
267
- var leaf1 = new Leaf(),
268
- leaf2 = new Leaf(),
269
- node = new Node({ children: [leaf1, leaf2] }),
270
- root = new Node({ children: [node] }),
271
- queueRunner = jasmine.createSpy('queueRunner'),
272
- processor = new jasmineUnderTest.TreeProcessor({
273
- tree: root,
274
- runnableIds: [node.id],
275
- queueRunnerFactory: queueRunner
276
- }),
277
- treeComplete = jasmine.createSpy('treeComplete'),
278
- nodeDone = jasmine.createSpy('nodeDone');
279
-
280
- processor.execute(treeComplete);
281
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
282
- queueableFns[0].fn(nodeDone);
283
-
284
- queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
285
- expect(queueableFns.length).toBe(2);
286
-
287
- queueableFns[0].fn('foo');
288
- expect(leaf1.execute).toHaveBeenCalledWith('foo', true);
289
-
290
- queueableFns[1].fn('bar');
291
- expect(leaf2.execute).toHaveBeenCalledWith('bar', true);
292
- });
293
-
294
- it("runs a disabled node", function() {
295
- var leaf1 = new Leaf(),
296
- node = new Node({ children: [leaf1], executable: false }),
297
- root = new Node({ children: [node] }),
298
- queueRunner = jasmine.createSpy('queueRunner'),
299
- nodeStart = jasmine.createSpy('nodeStart'),
300
- nodeComplete = jasmine.createSpy('nodeComplete'),
301
- processor = new jasmineUnderTest.TreeProcessor({
302
- tree: root,
303
- runnableIds: [node.id],
304
- queueRunnerFactory: queueRunner,
305
- nodeStart: nodeStart,
306
- nodeComplete: nodeComplete
307
- }),
308
- treeComplete = jasmine.createSpy('treeComplete'),
309
- nodeDone = jasmine.createSpy('nodeDone');
310
-
311
- processor.execute(treeComplete);
312
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
313
- queueableFns[0].fn(nodeDone);
314
-
315
- expect(nodeStart).toHaveBeenCalledWith(node);
316
-
317
- queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
318
- expect(queueableFns.length).toBe(1);
319
-
320
- queueableFns[0].fn('foo');
321
- expect(leaf1.execute).toHaveBeenCalledWith('foo', false);
322
-
323
- node.getResult.and.returnValue({ im: 'disabled' });
324
-
325
- queueRunner.calls.mostRecent().args[0].onComplete();
326
- expect(nodeComplete).toHaveBeenCalledWith(node, { im: 'disabled' });
327
- });
328
-
329
- it("runs beforeAlls for a node with children", function() {
330
- var leaf = new Leaf(),
331
- node = new Node({
332
- children: [leaf],
333
- beforeAllFns: ['beforeAll1', 'beforeAll2']
334
- }),
335
- root = new Node({ children: [node] }),
336
- queueRunner = jasmine.createSpy('queueRunner'),
337
- processor = new jasmineUnderTest.TreeProcessor({
338
- tree: root,
339
- runnableIds: [node.id],
340
- queueRunnerFactory: queueRunner
341
- }),
342
- treeComplete = jasmine.createSpy('treeComplete'),
343
- nodeDone = jasmine.createSpy('nodeDone');
344
-
345
- processor.execute(treeComplete);
346
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
347
- queueableFns[0].fn(nodeDone);
348
-
349
- queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
350
-
351
- expect(queueableFns).toEqual(['beforeAll1', 'beforeAll2', { fn: jasmine.any(Function) }]);
352
- });
353
-
354
- it("runs afterAlls for a node with children", function() {
355
- var leaf = new Leaf(),
356
- node = new Node({
357
- children: [leaf],
358
- afterAllFns: ['afterAll1', 'afterAll2']
359
- }),
360
- root = new Node({ children: [node] }),
361
- queueRunner = jasmine.createSpy('queueRunner'),
362
- processor = new jasmineUnderTest.TreeProcessor({
363
- tree: root,
364
- runnableIds: [node.id],
365
- queueRunnerFactory: queueRunner
366
- }),
367
- treeComplete = jasmine.createSpy('treeComplete'),
368
- nodeDone = jasmine.createSpy('nodeDone');
369
-
370
- processor.execute(treeComplete);
371
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
372
- queueableFns[0].fn(nodeDone);
373
-
374
- queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
375
-
376
- expect(queueableFns).toEqual([{ fn: jasmine.any(Function) }, 'afterAll1', 'afterAll2']);
377
- });
378
-
379
- it("does not run beforeAlls or afterAlls for a node with no children", function() {
380
- var node = new Node({
381
- beforeAllFns: ['before'],
382
- afterAllFns: ['after']
383
- }),
384
- root = new Node({ children: [node] }),
385
- queueRunner = jasmine.createSpy('queueRunner'),
386
- processor = new jasmineUnderTest.TreeProcessor({
387
- tree: root,
388
- runnableIds: [node.id],
389
- queueRunnerFactory: queueRunner
390
- }),
391
- treeComplete = jasmine.createSpy('treeComplete'),
392
- nodeDone = jasmine.createSpy('nodeDone');
393
-
394
- processor.execute(treeComplete);
395
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
396
- queueableFns[0].fn(nodeDone);
397
-
398
- queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
399
-
400
- expect(queueableFns).toEqual([]);
401
- });
402
-
403
- it("does not run beforeAlls or afterAlls for a disabled node", function() {
404
- var leaf = new Leaf(),
405
- node = new Node({
406
- children: [leaf],
407
- beforeAllFns: ['before'],
408
- afterAllFns: ['after'],
409
- executable: false
410
- }),
411
- root = new Node({ children: [node] }),
412
- queueRunner = jasmine.createSpy('queueRunner'),
413
- processor = new jasmineUnderTest.TreeProcessor({
414
- tree: root,
415
- runnableIds: [node.id],
416
- queueRunnerFactory: queueRunner
417
- }),
418
- treeComplete = jasmine.createSpy('treeComplete'),
419
- nodeDone = jasmine.createSpy('nodeDone');
420
-
421
- processor.execute(treeComplete);
422
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
423
- queueableFns[0].fn(nodeDone);
424
-
425
- queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
426
-
427
- expect(queueableFns).toEqual([{ fn: jasmine.any(Function) }]);
428
- });
429
-
430
- it("runs leaves in the order specified", function() {
431
- var leaf1 = new Leaf(),
432
- leaf2 = new Leaf(),
433
- root = new Node({ children: [leaf1, leaf2] }),
434
- queueRunner = jasmine.createSpy('queueRunner'),
435
- processor = new jasmineUnderTest.TreeProcessor({
436
- tree: root,
437
- runnableIds: [leaf2.id, leaf1.id],
438
- queueRunnerFactory: queueRunner
439
- }),
440
- treeComplete = jasmine.createSpy('treeComplete');
441
-
442
- processor.execute(treeComplete);
443
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
444
- queueableFns[0].fn();
445
-
446
- expect(leaf1.execute).not.toHaveBeenCalled();
447
- expect(leaf2.execute).toHaveBeenCalled();
448
-
449
- queueableFns[1].fn();
450
-
451
- expect(leaf1.execute).toHaveBeenCalled();
452
- });
453
-
454
- it("runs specified leaves before non-specified leaves", function() {
455
- var specified = new Leaf(),
456
- nonSpecified = new Leaf(),
457
- root = new Node({ children: [nonSpecified, specified] }),
458
- queueRunner = jasmine.createSpy('queueRunner'),
459
- processor = new jasmineUnderTest.TreeProcessor({
460
- tree: root,
461
- runnableIds: [specified.id],
462
- queueRunnerFactory: queueRunner
463
- }),
464
- treeComplete = jasmine.createSpy('treeComplete');
465
-
466
- processor.execute(treeComplete);
467
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
468
- queueableFns[0].fn();
469
-
470
- expect(nonSpecified.execute).not.toHaveBeenCalled();
471
- expect(specified.execute).toHaveBeenCalledWith(undefined, true);
472
-
473
- queueableFns[1].fn();
474
-
475
- expect(nonSpecified.execute).toHaveBeenCalledWith(undefined, false);
476
- });
477
-
478
- it("runs nodes and leaves with a specified order", function() {
479
- var specifiedLeaf = new Leaf(),
480
- childLeaf = new Leaf(),
481
- specifiedNode = new Node({ children: [childLeaf] }),
482
- root = new Node({ children: [specifiedLeaf, specifiedNode] }),
483
- queueRunner = jasmine.createSpy('queueRunner'),
484
- processor = new jasmineUnderTest.TreeProcessor({
485
- tree: root,
486
- runnableIds: [specifiedNode.id, specifiedLeaf.id],
487
- queueRunnerFactory: queueRunner
488
- });
489
-
490
- processor.execute();
491
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
492
- queueableFns[0].fn();
493
-
494
- expect(specifiedLeaf.execute).not.toHaveBeenCalled();
495
- var nodeQueueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
496
- nodeQueueableFns[0].fn();
497
-
498
- expect(childLeaf.execute).toHaveBeenCalled();
499
-
500
- queueableFns[1].fn();
501
-
502
- expect(specifiedLeaf.execute).toHaveBeenCalled();
503
- });
504
-
505
- it("runs a node multiple times if the order specified leaves and re-enters it", function() {
506
- var leaf1 = new Leaf(),
507
- leaf2 = new Leaf(),
508
- leaf3 = new Leaf(),
509
- leaf4 = new Leaf(),
510
- leaf5 = new Leaf(),
511
- reentered = new Node({ children: [leaf1, leaf2, leaf3] }),
512
- root = new Node({ children: [reentered, leaf4, leaf5] }),
513
- queueRunner = jasmine.createSpy('queueRunner'),
514
- processor = new jasmineUnderTest.TreeProcessor({
515
- tree: root,
516
- runnableIds: [leaf1.id, leaf4.id, leaf2.id, leaf5.id, leaf3.id],
517
- queueRunnerFactory: queueRunner
518
- });
519
-
520
- processor.execute();
521
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
522
- expect(queueableFns.length).toBe(5);
523
-
524
- queueableFns[0].fn();
525
- expect(queueRunner.calls.mostRecent().args[0].queueableFns.length).toBe(1);
526
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
527
- expect(leaf1.execute).toHaveBeenCalled();
528
-
529
- queueableFns[1].fn();
530
- expect(leaf4.execute).toHaveBeenCalled();
531
-
532
- queueableFns[2].fn();
533
- expect(queueRunner.calls.count()).toBe(3);
534
- expect(queueRunner.calls.mostRecent().args[0].queueableFns.length).toBe(1);
535
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
536
- expect(leaf2.execute).toHaveBeenCalled();
537
-
538
- queueableFns[3].fn();
539
- expect(leaf5.execute).toHaveBeenCalled();
540
-
541
- queueableFns[4].fn();
542
- expect(queueRunner.calls.count()).toBe(4);
543
- expect(queueRunner.calls.mostRecent().args[0].queueableFns.length).toBe(1);
544
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
545
- expect(leaf3.execute).toHaveBeenCalled();
546
- });
547
-
548
- it("runs a parent of a node with segments correctly", function() {
549
- var leaf1 = new Leaf(),
550
- leaf2 = new Leaf(),
551
- leaf3 = new Leaf(),
552
- leaf4 = new Leaf(),
553
- leaf5 = new Leaf(),
554
- parent = new Node({ children: [leaf1, leaf2, leaf3] }),
555
- grandparent = new Node({ children: [parent] }),
556
- root = new Node({ children: [grandparent, leaf4, leaf5] }),
557
- queueRunner = jasmine.createSpy('queueRunner'),
558
- processor = new jasmineUnderTest.TreeProcessor({
559
- tree: root,
560
- runnableIds: [leaf1.id, leaf4.id, leaf2.id, leaf5.id, leaf3.id],
561
- queueRunnerFactory: queueRunner
562
- });
563
-
564
- processor.execute();
565
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
566
- expect(queueableFns.length).toBe(5);
567
-
568
- queueableFns[0].fn();
569
- expect(queueRunner.calls.count()).toBe(2);
570
- expect(queueRunner.calls.mostRecent().args[0].queueableFns.length).toBe(1);
571
-
572
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
573
- expect(queueRunner.calls.count()).toBe(3);
574
-
575
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
576
- expect(leaf1.execute).toHaveBeenCalled();
577
-
578
- queueableFns[1].fn();
579
- expect(leaf4.execute).toHaveBeenCalled();
580
-
581
- queueableFns[2].fn();
582
- expect(queueRunner.calls.count()).toBe(4);
583
- expect(queueRunner.calls.mostRecent().args[0].queueableFns.length).toBe(1);
584
-
585
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
586
- expect(queueRunner.calls.count()).toBe(5);
587
-
588
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
589
- expect(leaf2.execute).toHaveBeenCalled();
590
-
591
- queueableFns[3].fn();
592
- expect(leaf5.execute).toHaveBeenCalled();
593
-
594
- queueableFns[4].fn();
595
- expect(queueRunner.calls.count()).toBe(6);
596
- expect(queueRunner.calls.mostRecent().args[0].queueableFns.length).toBe(1);
597
-
598
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
599
- expect(queueRunner.calls.count()).toBe(7);
600
-
601
- queueRunner.calls.mostRecent().args[0].queueableFns[0].fn();
602
- expect(leaf3.execute).toHaveBeenCalled();
603
- });
604
-
605
- it("runs nodes in the order they were declared", function() {
606
- var leaf1 = new Leaf(),
607
- leaf2 = new Leaf(),
608
- leaf3 = new Leaf(),
609
- parent = new Node({ children: [leaf2, leaf3] }),
610
- root = new Node({ children: [leaf1, parent] }),
611
- queueRunner = jasmine.createSpy('queueRunner'),
612
- processor = new jasmineUnderTest.TreeProcessor({
613
- tree: root,
614
- runnableIds: [root.id],
615
- queueRunnerFactory: queueRunner
616
- });
617
-
618
- processor.execute();
619
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
620
- expect(queueableFns.length).toBe(2);
621
-
622
- queueableFns[0].fn();
623
- expect(leaf1.execute).toHaveBeenCalled();
624
-
625
- queueableFns[1].fn();
626
-
627
- var childFns = queueRunner.calls.mostRecent().args[0].queueableFns;
628
- expect(childFns.length).toBe(2);
629
- childFns[0].fn();
630
- expect(leaf2.execute).toHaveBeenCalled();
631
-
632
- childFns[1].fn();
633
- expect(leaf3.execute).toHaveBeenCalled();
634
- });
635
-
636
- it("runs large segments of nodes in the order they were declared", function() {
637
- var leaf1 = new Leaf(),
638
- leaf2 = new Leaf(),
639
- leaf3 = new Leaf(),
640
- leaf4 = new Leaf(),
641
- leaf5 = new Leaf(),
642
- leaf6 = new Leaf(),
643
- leaf7 = new Leaf(),
644
- leaf8 = new Leaf(),
645
- leaf9 = new Leaf(),
646
- leaf10 = new Leaf(),
647
- leaf11 = new Leaf(),
648
- root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
649
- queueRunner = jasmine.createSpy('queueRunner'),
650
- processor = new jasmineUnderTest.TreeProcessor({
651
- tree: root,
652
- runnableIds: [root.id],
653
- queueRunnerFactory: queueRunner
654
- });
655
-
656
- processor.execute();
657
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
658
- expect(queueableFns.length).toBe(11);
659
-
660
- queueableFns[0].fn();
661
- expect(leaf1.execute).toHaveBeenCalled();
662
-
663
- queueableFns[1].fn();
664
- expect(leaf2.execute).toHaveBeenCalled();
665
-
666
- queueableFns[2].fn();
667
- expect(leaf3.execute).toHaveBeenCalled();
668
-
669
- queueableFns[3].fn();
670
- expect(leaf4.execute).toHaveBeenCalled();
671
-
672
- queueableFns[4].fn();
673
- expect(leaf5.execute).toHaveBeenCalled();
674
-
675
- queueableFns[5].fn();
676
- expect(leaf6.execute).toHaveBeenCalled();
677
-
678
- queueableFns[6].fn();
679
- expect(leaf7.execute).toHaveBeenCalled();
680
-
681
- queueableFns[7].fn();
682
- expect(leaf8.execute).toHaveBeenCalled();
683
-
684
- queueableFns[8].fn();
685
- expect(leaf9.execute).toHaveBeenCalled();
686
-
687
- queueableFns[9].fn();
688
- expect(leaf10.execute).toHaveBeenCalled();
689
-
690
- queueableFns[10].fn();
691
- expect(leaf11.execute).toHaveBeenCalled();
692
- });
693
-
694
- it("runs nodes in a custom order when orderChildren is overrided", function() {
695
- var leaf1 = new Leaf(),
696
- leaf2 = new Leaf(),
697
- leaf3 = new Leaf(),
698
- leaf4 = new Leaf(),
699
- leaf5 = new Leaf(),
700
- leaf6 = new Leaf(),
701
- leaf7 = new Leaf(),
702
- leaf8 = new Leaf(),
703
- leaf9 = new Leaf(),
704
- leaf10 = new Leaf(),
705
- leaf11 = new Leaf(),
706
- root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
707
- queueRunner = jasmine.createSpy('queueRunner'),
708
- processor = new jasmineUnderTest.TreeProcessor({
709
- tree: root,
710
- runnableIds: [root.id],
711
- queueRunnerFactory: queueRunner,
712
- orderChildren: function(node) {
713
- var children = node.children.slice();
714
- return children.reverse();
715
- }
716
- });
717
-
718
- processor.execute();
719
- var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
720
- expect(queueableFns.length).toBe(11);
721
-
722
- queueableFns[0].fn();
723
- expect(leaf11.execute).toHaveBeenCalled();
724
-
725
- queueableFns[1].fn();
726
- expect(leaf10.execute).toHaveBeenCalled();
727
-
728
- queueableFns[2].fn();
729
- expect(leaf9.execute).toHaveBeenCalled();
730
-
731
- queueableFns[3].fn();
732
- expect(leaf8.execute).toHaveBeenCalled();
733
-
734
- queueableFns[4].fn();
735
- expect(leaf7.execute).toHaveBeenCalled();
736
-
737
- queueableFns[5].fn();
738
- expect(leaf6.execute).toHaveBeenCalled();
739
-
740
- queueableFns[6].fn();
741
- expect(leaf5.execute).toHaveBeenCalled();
742
-
743
- queueableFns[7].fn();
744
- expect(leaf4.execute).toHaveBeenCalled();
745
-
746
- queueableFns[8].fn();
747
- expect(leaf3.execute).toHaveBeenCalled();
748
-
749
- queueableFns[9].fn();
750
- expect(leaf2.execute).toHaveBeenCalled();
751
-
752
- queueableFns[10].fn();
753
- expect(leaf1.execute).toHaveBeenCalled();
754
-
755
- });
756
- });