@yz-social/webrtc 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,971 @@
1
+ /*
2
+ Copyright (c) 2008-2019 Pivotal Labs
3
+ Copyright (c) 2008-2025 The Jasmine developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+ // eslint-disable-next-line no-var
26
+ var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
27
+
28
+ jasmineRequire.html = function(j$) {
29
+ j$.ResultsNode = jasmineRequire.ResultsNode();
30
+ j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
31
+ j$.QueryString = jasmineRequire.QueryString();
32
+ j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
33
+ };
34
+
35
+ jasmineRequire.HtmlReporter = function(j$) {
36
+ function ResultsStateBuilder() {
37
+ this.topResults = new j$.ResultsNode({}, '', null);
38
+ this.currentParent = this.topResults;
39
+ this.specsExecuted = 0;
40
+ this.failureCount = 0;
41
+ this.pendingSpecCount = 0;
42
+ }
43
+
44
+ ResultsStateBuilder.prototype.suiteStarted = function(result) {
45
+ this.currentParent.addChild(result, 'suite');
46
+ this.currentParent = this.currentParent.last();
47
+ };
48
+
49
+ ResultsStateBuilder.prototype.suiteDone = function(result) {
50
+ this.currentParent.updateResult(result);
51
+ if (this.currentParent !== this.topResults) {
52
+ this.currentParent = this.currentParent.parent;
53
+ }
54
+
55
+ if (result.status === 'failed') {
56
+ this.failureCount++;
57
+ }
58
+ };
59
+
60
+ ResultsStateBuilder.prototype.specStarted = function(result) {};
61
+
62
+ ResultsStateBuilder.prototype.specDone = function(result) {
63
+ this.currentParent.addChild(result, 'spec');
64
+
65
+ if (result.status !== 'excluded') {
66
+ this.specsExecuted++;
67
+ }
68
+
69
+ if (result.status === 'failed') {
70
+ this.failureCount++;
71
+ }
72
+
73
+ if (result.status == 'pending') {
74
+ this.pendingSpecCount++;
75
+ }
76
+ };
77
+
78
+ ResultsStateBuilder.prototype.jasmineDone = function(result) {
79
+ if (result.failedExpectations) {
80
+ this.failureCount += result.failedExpectations.length;
81
+ }
82
+ };
83
+
84
+ function HtmlReporter(options) {
85
+ function config() {
86
+ return (options.env && options.env.configuration()) || {};
87
+ }
88
+
89
+ const getContainer = options.getContainer;
90
+ const createElement = options.createElement;
91
+ const createTextNode = options.createTextNode;
92
+ const navigateWithNewParam = options.navigateWithNewParam || function() {};
93
+ const addToExistingQueryString =
94
+ options.addToExistingQueryString || defaultQueryString;
95
+ const filterSpecs = options.filterSpecs;
96
+ let htmlReporterMain;
97
+ let symbols;
98
+ const deprecationWarnings = [];
99
+ const failures = [];
100
+
101
+ this.initialize = function() {
102
+ clearPrior();
103
+ htmlReporterMain = createDom(
104
+ 'div',
105
+ { className: 'jasmine_html-reporter' },
106
+ createDom(
107
+ 'div',
108
+ { className: 'jasmine-banner' },
109
+ createDom('a', {
110
+ className: 'jasmine-title',
111
+ href: 'http://jasmine.github.io/',
112
+ target: '_blank'
113
+ }),
114
+ createDom('span', { className: 'jasmine-version' }, j$.version)
115
+ ),
116
+ createDom('ul', { className: 'jasmine-symbol-summary' }),
117
+ createDom('div', { className: 'jasmine-alert' }),
118
+ createDom(
119
+ 'div',
120
+ { className: 'jasmine-results' },
121
+ createDom('div', { className: 'jasmine-failures' })
122
+ )
123
+ );
124
+ getContainer().appendChild(htmlReporterMain);
125
+ };
126
+
127
+ let totalSpecsDefined;
128
+ this.jasmineStarted = function(options) {
129
+ totalSpecsDefined = options.totalSpecsDefined || 0;
130
+ };
131
+
132
+ const summary = createDom('div', { className: 'jasmine-summary' });
133
+
134
+ const stateBuilder = new ResultsStateBuilder();
135
+
136
+ this.suiteStarted = function(result) {
137
+ stateBuilder.suiteStarted(result);
138
+ };
139
+
140
+ this.suiteDone = function(result) {
141
+ stateBuilder.suiteDone(result);
142
+
143
+ if (result.status === 'failed') {
144
+ failures.push(failureDom(result));
145
+ }
146
+ addDeprecationWarnings(result, 'suite');
147
+ };
148
+
149
+ this.specStarted = function(result) {
150
+ stateBuilder.specStarted(result);
151
+ };
152
+
153
+ this.specDone = function(result) {
154
+ stateBuilder.specDone(result);
155
+
156
+ if (noExpectations(result)) {
157
+ const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
158
+ if (result.status === 'failed') {
159
+ // eslint-disable-next-line no-console
160
+ console.error(noSpecMsg);
161
+ } else {
162
+ // eslint-disable-next-line no-console
163
+ console.warn(noSpecMsg);
164
+ }
165
+ }
166
+
167
+ if (!symbols) {
168
+ symbols = find('.jasmine-symbol-summary');
169
+ }
170
+
171
+ symbols.appendChild(
172
+ createDom('li', {
173
+ className: this.displaySpecInCorrectFormat(result),
174
+ id: 'spec_' + result.id,
175
+ title: result.fullName
176
+ })
177
+ );
178
+
179
+ if (result.status === 'failed') {
180
+ failures.push(failureDom(result));
181
+ }
182
+
183
+ addDeprecationWarnings(result, 'spec');
184
+ };
185
+
186
+ this.displaySpecInCorrectFormat = function(result) {
187
+ return noExpectations(result) && result.status === 'passed'
188
+ ? 'jasmine-empty'
189
+ : this.resultStatus(result.status);
190
+ };
191
+
192
+ this.resultStatus = function(status) {
193
+ if (status === 'excluded') {
194
+ return config().hideDisabled
195
+ ? 'jasmine-excluded-no-display'
196
+ : 'jasmine-excluded';
197
+ }
198
+ return 'jasmine-' + status;
199
+ };
200
+
201
+ this.jasmineDone = function(doneResult) {
202
+ stateBuilder.jasmineDone(doneResult);
203
+ const banner = find('.jasmine-banner');
204
+ const alert = find('.jasmine-alert');
205
+ const order = doneResult && doneResult.order;
206
+
207
+ alert.appendChild(
208
+ createDom(
209
+ 'span',
210
+ { className: 'jasmine-duration' },
211
+ 'finished in ' + doneResult.totalTime / 1000 + 's'
212
+ )
213
+ );
214
+
215
+ banner.appendChild(optionsMenu(config()));
216
+
217
+ if (stateBuilder.specsExecuted < totalSpecsDefined) {
218
+ const skippedMessage =
219
+ 'Ran ' +
220
+ stateBuilder.specsExecuted +
221
+ ' of ' +
222
+ totalSpecsDefined +
223
+ ' specs - run all';
224
+ // include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
225
+ const skippedLink =
226
+ (window.location.pathname || '') +
227
+ addToExistingQueryString('spec', '');
228
+ alert.appendChild(
229
+ createDom(
230
+ 'span',
231
+ { className: 'jasmine-bar jasmine-skipped' },
232
+ createDom(
233
+ 'a',
234
+ { href: skippedLink, title: 'Run all specs' },
235
+ skippedMessage
236
+ )
237
+ )
238
+ );
239
+ }
240
+ let statusBarMessage = '';
241
+ let statusBarClassName = 'jasmine-overall-result jasmine-bar ';
242
+ const globalFailures =
243
+ (doneResult && doneResult.failedExpectations) || [];
244
+ const failed = stateBuilder.failureCount + globalFailures.length > 0;
245
+
246
+ if (totalSpecsDefined > 0 || failed) {
247
+ statusBarMessage +=
248
+ pluralize('spec', stateBuilder.specsExecuted) +
249
+ ', ' +
250
+ pluralize('failure', stateBuilder.failureCount);
251
+ if (stateBuilder.pendingSpecCount) {
252
+ statusBarMessage +=
253
+ ', ' + pluralize('pending spec', stateBuilder.pendingSpecCount);
254
+ }
255
+ }
256
+
257
+ if (doneResult.overallStatus === 'passed') {
258
+ statusBarClassName += ' jasmine-passed ';
259
+ } else if (doneResult.overallStatus === 'incomplete') {
260
+ statusBarClassName += ' jasmine-incomplete ';
261
+ statusBarMessage =
262
+ 'Incomplete: ' +
263
+ doneResult.incompleteReason +
264
+ ', ' +
265
+ statusBarMessage;
266
+ } else {
267
+ statusBarClassName += ' jasmine-failed ';
268
+ }
269
+
270
+ let seedBar;
271
+ if (order && order.random) {
272
+ seedBar = createDom(
273
+ 'span',
274
+ { className: 'jasmine-seed-bar' },
275
+ ', randomized with seed ',
276
+ createDom(
277
+ 'a',
278
+ {
279
+ title: 'randomized with seed ' + order.seed,
280
+ href: seedHref(order.seed)
281
+ },
282
+ order.seed
283
+ )
284
+ );
285
+ }
286
+
287
+ alert.appendChild(
288
+ createDom(
289
+ 'span',
290
+ { className: statusBarClassName },
291
+ statusBarMessage,
292
+ seedBar
293
+ )
294
+ );
295
+
296
+ const errorBarClassName = 'jasmine-bar jasmine-errored';
297
+ const afterAllMessagePrefix = 'AfterAll ';
298
+
299
+ for (let i = 0; i < globalFailures.length; i++) {
300
+ alert.appendChild(
301
+ createDom(
302
+ 'span',
303
+ { className: errorBarClassName },
304
+ globalFailureMessage(globalFailures[i])
305
+ )
306
+ );
307
+ }
308
+
309
+ function globalFailureMessage(failure) {
310
+ if (failure.globalErrorType === 'load') {
311
+ const prefix = 'Error during loading: ' + failure.message;
312
+
313
+ if (failure.filename) {
314
+ return (
315
+ prefix + ' in ' + failure.filename + ' line ' + failure.lineno
316
+ );
317
+ } else {
318
+ return prefix;
319
+ }
320
+ } else if (failure.globalErrorType === 'afterAll') {
321
+ return afterAllMessagePrefix + failure.message;
322
+ } else {
323
+ return failure.message;
324
+ }
325
+ }
326
+
327
+ addDeprecationWarnings(doneResult);
328
+
329
+ for (let i = 0; i < deprecationWarnings.length; i++) {
330
+ const children = [];
331
+ let context;
332
+
333
+ switch (deprecationWarnings[i].runnableType) {
334
+ case 'spec':
335
+ context = '(in spec: ' + deprecationWarnings[i].runnableName + ')';
336
+ break;
337
+ case 'suite':
338
+ context = '(in suite: ' + deprecationWarnings[i].runnableName + ')';
339
+ break;
340
+ default:
341
+ context = '';
342
+ }
343
+
344
+ deprecationWarnings[i].message.split('\n').forEach(function(line) {
345
+ children.push(line);
346
+ children.push(createDom('br'));
347
+ });
348
+
349
+ children[0] = 'DEPRECATION: ' + children[0];
350
+ children.push(context);
351
+
352
+ if (deprecationWarnings[i].stack) {
353
+ children.push(createExpander(deprecationWarnings[i].stack));
354
+ }
355
+
356
+ alert.appendChild(
357
+ createDom(
358
+ 'span',
359
+ { className: 'jasmine-bar jasmine-warning' },
360
+ children
361
+ )
362
+ );
363
+ }
364
+
365
+ const results = find('.jasmine-results');
366
+ results.appendChild(summary);
367
+
368
+ summaryList(stateBuilder.topResults, summary);
369
+
370
+ if (failures.length) {
371
+ alert.appendChild(
372
+ createDom(
373
+ 'span',
374
+ { className: 'jasmine-menu jasmine-bar jasmine-spec-list' },
375
+ createDom('span', {}, 'Spec List | '),
376
+ createDom(
377
+ 'a',
378
+ { className: 'jasmine-failures-menu', href: '#' },
379
+ 'Failures'
380
+ )
381
+ )
382
+ );
383
+ alert.appendChild(
384
+ createDom(
385
+ 'span',
386
+ { className: 'jasmine-menu jasmine-bar jasmine-failure-list' },
387
+ createDom(
388
+ 'a',
389
+ { className: 'jasmine-spec-list-menu', href: '#' },
390
+ 'Spec List'
391
+ ),
392
+ createDom('span', {}, ' | Failures ')
393
+ )
394
+ );
395
+
396
+ find('.jasmine-failures-menu').onclick = function() {
397
+ setMenuModeTo('jasmine-failure-list');
398
+ return false;
399
+ };
400
+ find('.jasmine-spec-list-menu').onclick = function() {
401
+ setMenuModeTo('jasmine-spec-list');
402
+ return false;
403
+ };
404
+
405
+ setMenuModeTo('jasmine-failure-list');
406
+
407
+ const failureNode = find('.jasmine-failures');
408
+ for (let i = 0; i < failures.length; i++) {
409
+ failureNode.appendChild(failures[i]);
410
+ }
411
+ }
412
+ };
413
+
414
+ return this;
415
+
416
+ function failureDom(result) {
417
+ const failure = createDom(
418
+ 'div',
419
+ { className: 'jasmine-spec-detail jasmine-failed' },
420
+ failureDescription(result, stateBuilder.currentParent),
421
+ createDom('div', { className: 'jasmine-messages' })
422
+ );
423
+ const messages = failure.childNodes[1];
424
+
425
+ for (let i = 0; i < result.failedExpectations.length; i++) {
426
+ const expectation = result.failedExpectations[i];
427
+ messages.appendChild(
428
+ createDom(
429
+ 'div',
430
+ { className: 'jasmine-result-message' },
431
+ expectation.message
432
+ )
433
+ );
434
+ messages.appendChild(
435
+ createDom(
436
+ 'div',
437
+ { className: 'jasmine-stack-trace' },
438
+ expectation.stack
439
+ )
440
+ );
441
+ }
442
+
443
+ if (result.failedExpectations.length === 0) {
444
+ messages.appendChild(
445
+ createDom(
446
+ 'div',
447
+ { className: 'jasmine-result-message' },
448
+ 'Spec has no expectations'
449
+ )
450
+ );
451
+ }
452
+
453
+ if (result.debugLogs) {
454
+ messages.appendChild(debugLogTable(result.debugLogs));
455
+ }
456
+
457
+ return failure;
458
+ }
459
+
460
+ function debugLogTable(debugLogs) {
461
+ const tbody = createDom('tbody');
462
+
463
+ debugLogs.forEach(function(entry) {
464
+ tbody.appendChild(
465
+ createDom(
466
+ 'tr',
467
+ {},
468
+ createDom('td', {}, entry.timestamp.toString()),
469
+ createDom(
470
+ 'td',
471
+ { className: 'jasmine-debug-log-msg' },
472
+ entry.message
473
+ )
474
+ )
475
+ );
476
+ });
477
+
478
+ return createDom(
479
+ 'div',
480
+ { className: 'jasmine-debug-log' },
481
+ createDom(
482
+ 'div',
483
+ { className: 'jasmine-debug-log-header' },
484
+ 'Debug logs'
485
+ ),
486
+ createDom(
487
+ 'table',
488
+ {},
489
+ createDom(
490
+ 'thead',
491
+ {},
492
+ createDom(
493
+ 'tr',
494
+ {},
495
+ createDom('th', {}, 'Time (ms)'),
496
+ createDom('th', {}, 'Message')
497
+ )
498
+ ),
499
+ tbody
500
+ )
501
+ );
502
+ }
503
+
504
+ function summaryList(resultsTree, domParent) {
505
+ let specListNode;
506
+ for (let i = 0; i < resultsTree.children.length; i++) {
507
+ const resultNode = resultsTree.children[i];
508
+ if (filterSpecs && !hasActiveSpec(resultNode)) {
509
+ continue;
510
+ }
511
+ if (resultNode.type === 'suite') {
512
+ const suiteListNode = createDom(
513
+ 'ul',
514
+ { className: 'jasmine-suite', id: 'suite-' + resultNode.result.id },
515
+ createDom(
516
+ 'li',
517
+ {
518
+ className:
519
+ 'jasmine-suite-detail jasmine-' + resultNode.result.status
520
+ },
521
+ createDom(
522
+ 'a',
523
+ { href: specHref(resultNode.result) },
524
+ resultNode.result.description
525
+ )
526
+ )
527
+ );
528
+
529
+ summaryList(resultNode, suiteListNode);
530
+ domParent.appendChild(suiteListNode);
531
+ }
532
+ if (resultNode.type === 'spec') {
533
+ if (domParent.getAttribute('class') !== 'jasmine-specs') {
534
+ specListNode = createDom('ul', { className: 'jasmine-specs' });
535
+ domParent.appendChild(specListNode);
536
+ }
537
+ let specDescription = resultNode.result.description;
538
+ if (noExpectations(resultNode.result)) {
539
+ specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
540
+ }
541
+ if (resultNode.result.status === 'pending') {
542
+ if (resultNode.result.pendingReason !== '') {
543
+ specDescription +=
544
+ ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
545
+ } else {
546
+ specDescription += ' PENDING';
547
+ }
548
+ }
549
+ specListNode.appendChild(
550
+ createDom(
551
+ 'li',
552
+ {
553
+ className: 'jasmine-' + resultNode.result.status,
554
+ id: 'spec-' + resultNode.result.id
555
+ },
556
+ createDom(
557
+ 'a',
558
+ { href: specHref(resultNode.result) },
559
+ specDescription
560
+ )
561
+ )
562
+ );
563
+ }
564
+ }
565
+ }
566
+
567
+ function optionsMenu(config) {
568
+ const optionsMenuDom = createDom(
569
+ 'div',
570
+ { className: 'jasmine-run-options' },
571
+ createDom('span', { className: 'jasmine-trigger' }, 'Options'),
572
+ createDom(
573
+ 'div',
574
+ { className: 'jasmine-payload' },
575
+ createDom(
576
+ 'div',
577
+ { className: 'jasmine-stop-on-failure' },
578
+ createDom('input', {
579
+ className: 'jasmine-fail-fast',
580
+ id: 'jasmine-fail-fast',
581
+ type: 'checkbox'
582
+ }),
583
+ createDom(
584
+ 'label',
585
+ { className: 'jasmine-label', for: 'jasmine-fail-fast' },
586
+ 'stop execution on spec failure'
587
+ )
588
+ ),
589
+ createDom(
590
+ 'div',
591
+ { className: 'jasmine-throw-failures' },
592
+ createDom('input', {
593
+ className: 'jasmine-throw',
594
+ id: 'jasmine-throw-failures',
595
+ type: 'checkbox'
596
+ }),
597
+ createDom(
598
+ 'label',
599
+ { className: 'jasmine-label', for: 'jasmine-throw-failures' },
600
+ 'stop spec on expectation failure'
601
+ )
602
+ ),
603
+ createDom(
604
+ 'div',
605
+ { className: 'jasmine-random-order' },
606
+ createDom('input', {
607
+ className: 'jasmine-random',
608
+ id: 'jasmine-random-order',
609
+ type: 'checkbox'
610
+ }),
611
+ createDom(
612
+ 'label',
613
+ { className: 'jasmine-label', for: 'jasmine-random-order' },
614
+ 'run tests in random order'
615
+ )
616
+ ),
617
+ createDom(
618
+ 'div',
619
+ { className: 'jasmine-hide-disabled' },
620
+ createDom('input', {
621
+ className: 'jasmine-disabled',
622
+ id: 'jasmine-hide-disabled',
623
+ type: 'checkbox'
624
+ }),
625
+ createDom(
626
+ 'label',
627
+ { className: 'jasmine-label', for: 'jasmine-hide-disabled' },
628
+ 'hide disabled tests'
629
+ )
630
+ )
631
+ )
632
+ );
633
+
634
+ const failFastCheckbox = optionsMenuDom.querySelector(
635
+ '#jasmine-fail-fast'
636
+ );
637
+ failFastCheckbox.checked = config.stopOnSpecFailure;
638
+ failFastCheckbox.onclick = function() {
639
+ navigateWithNewParam('stopOnSpecFailure', !config.stopOnSpecFailure);
640
+ };
641
+
642
+ const throwCheckbox = optionsMenuDom.querySelector(
643
+ '#jasmine-throw-failures'
644
+ );
645
+ throwCheckbox.checked = config.stopSpecOnExpectationFailure;
646
+ throwCheckbox.onclick = function() {
647
+ navigateWithNewParam(
648
+ 'stopSpecOnExpectationFailure',
649
+ !config.stopSpecOnExpectationFailure
650
+ );
651
+ };
652
+
653
+ const randomCheckbox = optionsMenuDom.querySelector(
654
+ '#jasmine-random-order'
655
+ );
656
+ randomCheckbox.checked = config.random;
657
+ randomCheckbox.onclick = function() {
658
+ navigateWithNewParam('random', !config.random);
659
+ };
660
+
661
+ const hideDisabled = optionsMenuDom.querySelector(
662
+ '#jasmine-hide-disabled'
663
+ );
664
+ hideDisabled.checked = config.hideDisabled;
665
+ hideDisabled.onclick = function() {
666
+ navigateWithNewParam('hideDisabled', !config.hideDisabled);
667
+ };
668
+
669
+ const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
670
+ optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
671
+ isOpen = /\bjasmine-open\b/;
672
+
673
+ optionsTrigger.onclick = function() {
674
+ if (isOpen.test(optionsPayload.className)) {
675
+ optionsPayload.className = optionsPayload.className.replace(
676
+ isOpen,
677
+ ''
678
+ );
679
+ } else {
680
+ optionsPayload.className += ' jasmine-open';
681
+ }
682
+ };
683
+
684
+ return optionsMenuDom;
685
+ }
686
+
687
+ function failureDescription(result, suite) {
688
+ const wrapper = createDom(
689
+ 'div',
690
+ { className: 'jasmine-description' },
691
+ createDom(
692
+ 'a',
693
+ { title: result.description, href: specHref(result) },
694
+ result.description
695
+ )
696
+ );
697
+ let suiteLink;
698
+
699
+ while (suite && suite.parent) {
700
+ wrapper.insertBefore(createTextNode(' > '), wrapper.firstChild);
701
+ suiteLink = createDom(
702
+ 'a',
703
+ { href: suiteHref(suite) },
704
+ suite.result.description
705
+ );
706
+ wrapper.insertBefore(suiteLink, wrapper.firstChild);
707
+
708
+ suite = suite.parent;
709
+ }
710
+
711
+ return wrapper;
712
+ }
713
+
714
+ function suiteHref(suite) {
715
+ const els = [];
716
+
717
+ while (suite && suite.parent) {
718
+ els.unshift(suite.result.description);
719
+ suite = suite.parent;
720
+ }
721
+
722
+ // include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
723
+ return (
724
+ (window.location.pathname || '') +
725
+ addToExistingQueryString('spec', els.join(' '))
726
+ );
727
+ }
728
+
729
+ function addDeprecationWarnings(result, runnableType) {
730
+ if (result && result.deprecationWarnings) {
731
+ for (let i = 0; i < result.deprecationWarnings.length; i++) {
732
+ const warning = result.deprecationWarnings[i].message;
733
+ deprecationWarnings.push({
734
+ message: warning,
735
+ stack: result.deprecationWarnings[i].stack,
736
+ runnableName: result.fullName,
737
+ runnableType: runnableType
738
+ });
739
+ }
740
+ }
741
+ }
742
+
743
+ function createExpander(stackTrace) {
744
+ const expandLink = createDom('a', { href: '#' }, 'Show stack trace');
745
+ const root = createDom(
746
+ 'div',
747
+ { className: 'jasmine-expander' },
748
+ expandLink,
749
+ createDom(
750
+ 'div',
751
+ { className: 'jasmine-expander-contents jasmine-stack-trace' },
752
+ stackTrace
753
+ )
754
+ );
755
+
756
+ expandLink.addEventListener('click', function(e) {
757
+ e.preventDefault();
758
+
759
+ if (root.classList.contains('jasmine-expanded')) {
760
+ root.classList.remove('jasmine-expanded');
761
+ expandLink.textContent = 'Show stack trace';
762
+ } else {
763
+ root.classList.add('jasmine-expanded');
764
+ expandLink.textContent = 'Hide stack trace';
765
+ }
766
+ });
767
+
768
+ return root;
769
+ }
770
+
771
+ function find(selector) {
772
+ return getContainer().querySelector('.jasmine_html-reporter ' + selector);
773
+ }
774
+
775
+ function clearPrior() {
776
+ const oldReporter = find('');
777
+
778
+ if (oldReporter) {
779
+ getContainer().removeChild(oldReporter);
780
+ }
781
+ }
782
+
783
+ function createDom(type, attrs, childrenArrayOrVarArgs) {
784
+ const el = createElement(type);
785
+ let children;
786
+
787
+ if (j$.isArray_(childrenArrayOrVarArgs)) {
788
+ children = childrenArrayOrVarArgs;
789
+ } else {
790
+ children = [];
791
+
792
+ for (let i = 2; i < arguments.length; i++) {
793
+ children.push(arguments[i]);
794
+ }
795
+ }
796
+
797
+ for (let i = 0; i < children.length; i++) {
798
+ const child = children[i];
799
+
800
+ if (typeof child === 'string') {
801
+ el.appendChild(createTextNode(child));
802
+ } else {
803
+ if (child) {
804
+ el.appendChild(child);
805
+ }
806
+ }
807
+ }
808
+
809
+ for (const attr in attrs) {
810
+ if (attr == 'className') {
811
+ el[attr] = attrs[attr];
812
+ } else {
813
+ el.setAttribute(attr, attrs[attr]);
814
+ }
815
+ }
816
+
817
+ return el;
818
+ }
819
+
820
+ function pluralize(singular, count) {
821
+ const word = count == 1 ? singular : singular + 's';
822
+
823
+ return '' + count + ' ' + word;
824
+ }
825
+
826
+ function specHref(result) {
827
+ // include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
828
+ return (
829
+ (window.location.pathname || '') +
830
+ addToExistingQueryString('spec', result.fullName)
831
+ );
832
+ }
833
+
834
+ function seedHref(seed) {
835
+ // include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
836
+ return (
837
+ (window.location.pathname || '') +
838
+ addToExistingQueryString('seed', seed)
839
+ );
840
+ }
841
+
842
+ function defaultQueryString(key, value) {
843
+ return '?' + key + '=' + value;
844
+ }
845
+
846
+ function setMenuModeTo(mode) {
847
+ htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
848
+ }
849
+
850
+ function noExpectations(result) {
851
+ const allExpectations =
852
+ result.failedExpectations.length + result.passedExpectations.length;
853
+
854
+ return (
855
+ allExpectations === 0 &&
856
+ (result.status === 'passed' || result.status === 'failed')
857
+ );
858
+ }
859
+
860
+ function hasActiveSpec(resultNode) {
861
+ if (resultNode.type == 'spec' && resultNode.result.status != 'excluded') {
862
+ return true;
863
+ }
864
+
865
+ if (resultNode.type == 'suite') {
866
+ for (let i = 0, j = resultNode.children.length; i < j; i++) {
867
+ if (hasActiveSpec(resultNode.children[i])) {
868
+ return true;
869
+ }
870
+ }
871
+ }
872
+ }
873
+ }
874
+
875
+ return HtmlReporter;
876
+ };
877
+
878
+ jasmineRequire.HtmlSpecFilter = function() {
879
+ function HtmlSpecFilter(options) {
880
+ const filterString =
881
+ options &&
882
+ options.filterString() &&
883
+ options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
884
+ const filterPattern = new RegExp(filterString);
885
+
886
+ this.matches = function(specName) {
887
+ return filterPattern.test(specName);
888
+ };
889
+ }
890
+
891
+ return HtmlSpecFilter;
892
+ };
893
+
894
+ jasmineRequire.ResultsNode = function() {
895
+ function ResultsNode(result, type, parent) {
896
+ this.result = result;
897
+ this.type = type;
898
+ this.parent = parent;
899
+
900
+ this.children = [];
901
+
902
+ this.addChild = function(result, type) {
903
+ this.children.push(new ResultsNode(result, type, this));
904
+ };
905
+
906
+ this.last = function() {
907
+ return this.children[this.children.length - 1];
908
+ };
909
+
910
+ this.updateResult = function(result) {
911
+ this.result = result;
912
+ };
913
+ }
914
+
915
+ return ResultsNode;
916
+ };
917
+
918
+ jasmineRequire.QueryString = function() {
919
+ function QueryString(options) {
920
+ this.navigateWithNewParam = function(key, value) {
921
+ options.getWindowLocation().search = this.fullStringWithNewParam(
922
+ key,
923
+ value
924
+ );
925
+ };
926
+
927
+ this.fullStringWithNewParam = function(key, value) {
928
+ const paramMap = queryStringToParamMap();
929
+ paramMap[key] = value;
930
+ return toQueryString(paramMap);
931
+ };
932
+
933
+ this.getParam = function(key) {
934
+ return queryStringToParamMap()[key];
935
+ };
936
+
937
+ return this;
938
+
939
+ function toQueryString(paramMap) {
940
+ const qStrPairs = [];
941
+ for (const prop in paramMap) {
942
+ qStrPairs.push(
943
+ encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop])
944
+ );
945
+ }
946
+ return '?' + qStrPairs.join('&');
947
+ }
948
+
949
+ function queryStringToParamMap() {
950
+ const paramStr = options.getWindowLocation().search.substring(1);
951
+ let params = [];
952
+ const paramMap = {};
953
+
954
+ if (paramStr.length > 0) {
955
+ params = paramStr.split('&');
956
+ for (let i = 0; i < params.length; i++) {
957
+ const p = params[i].split('=');
958
+ let value = decodeURIComponent(p[1]);
959
+ if (value === 'true' || value === 'false') {
960
+ value = JSON.parse(value);
961
+ }
962
+ paramMap[decodeURIComponent(p[0])] = value;
963
+ }
964
+ }
965
+
966
+ return paramMap;
967
+ }
968
+ }
969
+
970
+ return QueryString;
971
+ };