@angular/core 19.2.0-rc.0 → 20.0.0-next.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.
Files changed (40) hide show
  1. package/fesm2022/core.mjs +474 -290
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/event-dispatch.mjs +1 -1
  4. package/fesm2022/primitives/signals.mjs +1 -1
  5. package/fesm2022/rxjs-interop.mjs +1 -1
  6. package/fesm2022/testing.mjs +707 -5
  7. package/fesm2022/testing.mjs.map +1 -1
  8. package/index.d.ts +197 -22
  9. package/package.json +1 -1
  10. package/primitives/event-dispatch/index.d.ts +1 -1
  11. package/primitives/signals/index.d.ts +1 -1
  12. package/rxjs-interop/index.d.ts +1 -1
  13. package/schematics/bundles/{apply_import_manager-a930fcf1.js → apply_import_manager-0959b78c.js} +3 -3
  14. package/schematics/bundles/{checker-2eecc677.js → checker-cf6f7980.js} +121 -16
  15. package/schematics/bundles/cleanup-unused-imports.js +7 -7
  16. package/schematics/bundles/{compiler_host-c280a924.js → compiler_host-cc1379e9.js} +2 -2
  17. package/schematics/bundles/control-flow-migration.js +3 -3
  18. package/schematics/bundles/explicit-standalone-flag.js +5 -5
  19. package/schematics/bundles/{imports-abe29092.js → imports-31a38653.js} +1 -1
  20. package/schematics/bundles/{index-24a2ad1e.js → index-42d84d69.js} +4 -4
  21. package/schematics/bundles/{index-3891dd55.js → index-6675d6bc.js} +4 -4
  22. package/schematics/bundles/inject-migration.js +7 -7
  23. package/schematics/bundles/{leading_space-d190b83b.js → leading_space-6e7a8ec6.js} +1 -1
  24. package/schematics/bundles/{migrate_ts_type_references-71b3a951.js → migrate_ts_type_references-5089e4ef.js} +10 -6
  25. package/schematics/bundles/{ng_decorators-e699c081.js → ng_decorators-6878e227.js} +2 -2
  26. package/schematics/bundles/{nodes-a535b2be.js → nodes-ffdce442.js} +1 -1
  27. package/schematics/bundles/output-migration.js +7 -7
  28. package/schematics/bundles/pending-tasks.js +5 -5
  29. package/schematics/bundles/{program-24da9092.js → program-362689f0.js} +148 -148
  30. package/schematics/bundles/{project_paths-b073c4d6.js → project_paths-7d2daa1e.js} +3 -3
  31. package/schematics/bundles/{project_tsconfig_paths-e9ccccbf.js → project_tsconfig_paths-6c9cde78.js} +1 -1
  32. package/schematics/bundles/{property_name-7c8433f5.js → property_name-42030525.js} +1 -1
  33. package/schematics/bundles/provide-initializer.js +5 -5
  34. package/schematics/bundles/route-lazy-loading.js +5 -5
  35. package/schematics/bundles/self-closing-tags-migration.js +8 -8
  36. package/schematics/bundles/signal-input-migration.js +9 -9
  37. package/schematics/bundles/signal-queries-migration.js +9 -9
  38. package/schematics/bundles/signals.js +9 -9
  39. package/schematics/bundles/standalone-migration.js +9 -9
  40. package/testing/index.d.ts +297 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.2.0-rc.0
2
+ * @license Angular v20.0.0-next.0
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -175,10 +175,10 @@ class TestBedApplicationErrorHandler {
175
175
  throw e;
176
176
  }
177
177
  }
178
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
179
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: TestBedApplicationErrorHandler });
178
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
179
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: TestBedApplicationErrorHandler });
180
180
  }
181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
182
182
  type: Injectable
183
183
  }] });
184
184
 
@@ -257,6 +257,17 @@ class ComponentFixture {
257
257
  this._ngZone.runOutsideAngular(() => {
258
258
  this.subscriptions.add(this._ngZone.onError.subscribe({
259
259
  next: (error) => {
260
+ // The rethrow here is to ensure that errors don't go unreported. Since `NgZone.onHandleError` returns `false`,
261
+ // ZoneJS will not throw the error coming out of a task. Instead, the handling is defined by
262
+ // the chain of parent delegates and whether they indicate the error is handled in some way (by returning `false`).
263
+ // Unfortunately, 'onError' does not forward the information about whether the error was handled by a parent zone
264
+ // so cannot know here whether throwing is appropriate. As a half-solution, we can check to see if we're inside
265
+ // a fakeAsync context, which we know has its own error handling.
266
+ // https://github.com/angular/angular/blob/db2f2d99c82aae52d8a0ae46616c6411d070b35e/packages/zone.js/lib/zone-spec/fake-async-test.ts#L783-L784
267
+ // https://github.com/angular/angular/blob/db2f2d99c82aae52d8a0ae46616c6411d070b35e/packages/zone.js/lib/zone-spec/fake-async-test.ts#L473-L478
268
+ if (typeof Zone === 'undefined' || Zone.current.get('FakeAsyncTestZoneSpec')) {
269
+ return;
270
+ }
260
271
  throw error;
261
272
  },
262
273
  }));
@@ -2308,6 +2319,697 @@ const __core_private_testing_placeholder__ = '';
2308
2319
  * Entry point for all public APIs of the core/testing package.
2309
2320
  */
2310
2321
 
2322
+ /**
2323
+ * Fake implementation of user agent history and navigation behavior. This is a
2324
+ * high-fidelity implementation of browser behavior that attempts to emulate
2325
+ * things like traversal delay.
2326
+ */
2327
+ class FakeNavigation {
2328
+ window;
2329
+ /**
2330
+ * The fake implementation of an entries array. Only same-document entries
2331
+ * allowed.
2332
+ */
2333
+ entriesArr = [];
2334
+ /**
2335
+ * The current active entry index into `entriesArr`.
2336
+ */
2337
+ currentEntryIndex = 0;
2338
+ /**
2339
+ * The current navigate event.
2340
+ */
2341
+ navigateEvent = undefined;
2342
+ /**
2343
+ * A Map of pending traversals, so that traversals to the same entry can be
2344
+ * re-used.
2345
+ */
2346
+ traversalQueue = new Map();
2347
+ /**
2348
+ * A Promise that resolves when the previous traversals have finished. Used to
2349
+ * simulate the cross-process communication necessary for traversals.
2350
+ */
2351
+ nextTraversal = Promise.resolve();
2352
+ /**
2353
+ * A prospective current active entry index, which includes unresolved
2354
+ * traversals. Used by `go` to determine where navigations are intended to go.
2355
+ */
2356
+ prospectiveEntryIndex = 0;
2357
+ /**
2358
+ * A test-only option to make traversals synchronous, rather than emulate
2359
+ * cross-process communication.
2360
+ */
2361
+ synchronousTraversals = false;
2362
+ /** Whether to allow a call to setInitialEntryForTesting. */
2363
+ canSetInitialEntry = true;
2364
+ /** `EventTarget` to dispatch events. */
2365
+ eventTarget;
2366
+ /** The next unique id for created entries. Replace recreates this id. */
2367
+ nextId = 0;
2368
+ /** The next unique key for created entries. Replace inherits this id. */
2369
+ nextKey = 0;
2370
+ /** Whether this fake is disposed. */
2371
+ disposed = false;
2372
+ /** Equivalent to `navigation.currentEntry`. */
2373
+ get currentEntry() {
2374
+ return this.entriesArr[this.currentEntryIndex];
2375
+ }
2376
+ get canGoBack() {
2377
+ return this.currentEntryIndex > 0;
2378
+ }
2379
+ get canGoForward() {
2380
+ return this.currentEntryIndex < this.entriesArr.length - 1;
2381
+ }
2382
+ constructor(window, startURL) {
2383
+ this.window = window;
2384
+ this.eventTarget = this.window.document.createElement('div');
2385
+ // First entry.
2386
+ this.setInitialEntryForTesting(startURL);
2387
+ }
2388
+ /**
2389
+ * Sets the initial entry.
2390
+ */
2391
+ setInitialEntryForTesting(url, options = { historyState: null }) {
2392
+ if (!this.canSetInitialEntry) {
2393
+ throw new Error('setInitialEntryForTesting can only be called before any ' + 'navigation has occurred');
2394
+ }
2395
+ const currentInitialEntry = this.entriesArr[0];
2396
+ this.entriesArr[0] = new FakeNavigationHistoryEntry(new URL(url).toString(), {
2397
+ index: 0,
2398
+ key: currentInitialEntry?.key ?? String(this.nextKey++),
2399
+ id: currentInitialEntry?.id ?? String(this.nextId++),
2400
+ sameDocument: true,
2401
+ historyState: options?.historyState,
2402
+ state: options.state,
2403
+ });
2404
+ }
2405
+ /** Returns whether the initial entry is still eligible to be set. */
2406
+ canSetInitialEntryForTesting() {
2407
+ return this.canSetInitialEntry;
2408
+ }
2409
+ /**
2410
+ * Sets whether to emulate traversals as synchronous rather than
2411
+ * asynchronous.
2412
+ */
2413
+ setSynchronousTraversalsForTesting(synchronousTraversals) {
2414
+ this.synchronousTraversals = synchronousTraversals;
2415
+ }
2416
+ /** Equivalent to `navigation.entries()`. */
2417
+ entries() {
2418
+ return this.entriesArr.slice();
2419
+ }
2420
+ /** Equivalent to `navigation.navigate()`. */
2421
+ navigate(url, options) {
2422
+ const fromUrl = new URL(this.currentEntry.url);
2423
+ const toUrl = new URL(url, this.currentEntry.url);
2424
+ let navigationType;
2425
+ if (!options?.history || options.history === 'auto') {
2426
+ // Auto defaults to push, but if the URLs are the same, is a replace.
2427
+ if (fromUrl.toString() === toUrl.toString()) {
2428
+ navigationType = 'replace';
2429
+ }
2430
+ else {
2431
+ navigationType = 'push';
2432
+ }
2433
+ }
2434
+ else {
2435
+ navigationType = options.history;
2436
+ }
2437
+ const hashChange = isHashChange(fromUrl, toUrl);
2438
+ const destination = new FakeNavigationDestination({
2439
+ url: toUrl.toString(),
2440
+ state: options?.state,
2441
+ sameDocument: hashChange,
2442
+ historyState: null,
2443
+ });
2444
+ const result = new InternalNavigationResult();
2445
+ this.userAgentNavigate(destination, result, {
2446
+ navigationType,
2447
+ cancelable: true,
2448
+ canIntercept: true,
2449
+ // Always false for navigate().
2450
+ userInitiated: false,
2451
+ hashChange,
2452
+ info: options?.info,
2453
+ });
2454
+ return {
2455
+ committed: result.committed,
2456
+ finished: result.finished,
2457
+ };
2458
+ }
2459
+ /** Equivalent to `history.pushState()`. */
2460
+ pushState(data, title, url) {
2461
+ this.pushOrReplaceState('push', data, title, url);
2462
+ }
2463
+ /** Equivalent to `history.replaceState()`. */
2464
+ replaceState(data, title, url) {
2465
+ this.pushOrReplaceState('replace', data, title, url);
2466
+ }
2467
+ pushOrReplaceState(navigationType, data, _title, url) {
2468
+ const fromUrl = new URL(this.currentEntry.url);
2469
+ const toUrl = url ? new URL(url, this.currentEntry.url) : fromUrl;
2470
+ const hashChange = isHashChange(fromUrl, toUrl);
2471
+ const destination = new FakeNavigationDestination({
2472
+ url: toUrl.toString(),
2473
+ sameDocument: true,
2474
+ historyState: data,
2475
+ });
2476
+ const result = new InternalNavigationResult();
2477
+ this.userAgentNavigate(destination, result, {
2478
+ navigationType,
2479
+ cancelable: true,
2480
+ canIntercept: true,
2481
+ // Always false for pushState() or replaceState().
2482
+ userInitiated: false,
2483
+ hashChange,
2484
+ skipPopState: true,
2485
+ });
2486
+ }
2487
+ /** Equivalent to `navigation.traverseTo()`. */
2488
+ traverseTo(key, options) {
2489
+ const fromUrl = new URL(this.currentEntry.url);
2490
+ const entry = this.findEntry(key);
2491
+ if (!entry) {
2492
+ const domException = new DOMException('Invalid key', 'InvalidStateError');
2493
+ const committed = Promise.reject(domException);
2494
+ const finished = Promise.reject(domException);
2495
+ committed.catch(() => { });
2496
+ finished.catch(() => { });
2497
+ return {
2498
+ committed,
2499
+ finished,
2500
+ };
2501
+ }
2502
+ if (entry === this.currentEntry) {
2503
+ return {
2504
+ committed: Promise.resolve(this.currentEntry),
2505
+ finished: Promise.resolve(this.currentEntry),
2506
+ };
2507
+ }
2508
+ if (this.traversalQueue.has(entry.key)) {
2509
+ const existingResult = this.traversalQueue.get(entry.key);
2510
+ return {
2511
+ committed: existingResult.committed,
2512
+ finished: existingResult.finished,
2513
+ };
2514
+ }
2515
+ const hashChange = isHashChange(fromUrl, new URL(entry.url, this.currentEntry.url));
2516
+ const destination = new FakeNavigationDestination({
2517
+ url: entry.url,
2518
+ state: entry.getState(),
2519
+ historyState: entry.getHistoryState(),
2520
+ key: entry.key,
2521
+ id: entry.id,
2522
+ index: entry.index,
2523
+ sameDocument: entry.sameDocument,
2524
+ });
2525
+ this.prospectiveEntryIndex = entry.index;
2526
+ const result = new InternalNavigationResult();
2527
+ this.traversalQueue.set(entry.key, result);
2528
+ this.runTraversal(() => {
2529
+ this.traversalQueue.delete(entry.key);
2530
+ this.userAgentNavigate(destination, result, {
2531
+ navigationType: 'traverse',
2532
+ cancelable: true,
2533
+ canIntercept: true,
2534
+ // Always false for traverseTo().
2535
+ userInitiated: false,
2536
+ hashChange,
2537
+ info: options?.info,
2538
+ });
2539
+ });
2540
+ return {
2541
+ committed: result.committed,
2542
+ finished: result.finished,
2543
+ };
2544
+ }
2545
+ /** Equivalent to `navigation.back()`. */
2546
+ back(options) {
2547
+ if (this.currentEntryIndex === 0) {
2548
+ const domException = new DOMException('Cannot go back', 'InvalidStateError');
2549
+ const committed = Promise.reject(domException);
2550
+ const finished = Promise.reject(domException);
2551
+ committed.catch(() => { });
2552
+ finished.catch(() => { });
2553
+ return {
2554
+ committed,
2555
+ finished,
2556
+ };
2557
+ }
2558
+ const entry = this.entriesArr[this.currentEntryIndex - 1];
2559
+ return this.traverseTo(entry.key, options);
2560
+ }
2561
+ /** Equivalent to `navigation.forward()`. */
2562
+ forward(options) {
2563
+ if (this.currentEntryIndex === this.entriesArr.length - 1) {
2564
+ const domException = new DOMException('Cannot go forward', 'InvalidStateError');
2565
+ const committed = Promise.reject(domException);
2566
+ const finished = Promise.reject(domException);
2567
+ committed.catch(() => { });
2568
+ finished.catch(() => { });
2569
+ return {
2570
+ committed,
2571
+ finished,
2572
+ };
2573
+ }
2574
+ const entry = this.entriesArr[this.currentEntryIndex + 1];
2575
+ return this.traverseTo(entry.key, options);
2576
+ }
2577
+ /**
2578
+ * Equivalent to `history.go()`.
2579
+ * Note that this method does not actually work precisely to how Chrome
2580
+ * does, instead choosing a simpler model with less unexpected behavior.
2581
+ * Chrome has a few edge case optimizations, for instance with repeated
2582
+ * `back(); forward()` chains it collapses certain traversals.
2583
+ */
2584
+ go(direction) {
2585
+ const targetIndex = this.prospectiveEntryIndex + direction;
2586
+ if (targetIndex >= this.entriesArr.length || targetIndex < 0) {
2587
+ return;
2588
+ }
2589
+ this.prospectiveEntryIndex = targetIndex;
2590
+ this.runTraversal(() => {
2591
+ // Check again that destination is in the entries array.
2592
+ if (targetIndex >= this.entriesArr.length || targetIndex < 0) {
2593
+ return;
2594
+ }
2595
+ const fromUrl = new URL(this.currentEntry.url);
2596
+ const entry = this.entriesArr[targetIndex];
2597
+ const hashChange = isHashChange(fromUrl, new URL(entry.url, this.currentEntry.url));
2598
+ const destination = new FakeNavigationDestination({
2599
+ url: entry.url,
2600
+ state: entry.getState(),
2601
+ historyState: entry.getHistoryState(),
2602
+ key: entry.key,
2603
+ id: entry.id,
2604
+ index: entry.index,
2605
+ sameDocument: entry.sameDocument,
2606
+ });
2607
+ const result = new InternalNavigationResult();
2608
+ this.userAgentNavigate(destination, result, {
2609
+ navigationType: 'traverse',
2610
+ cancelable: true,
2611
+ canIntercept: true,
2612
+ // Always false for go().
2613
+ userInitiated: false,
2614
+ hashChange,
2615
+ });
2616
+ });
2617
+ }
2618
+ /** Runs a traversal synchronously or asynchronously */
2619
+ runTraversal(traversal) {
2620
+ if (this.synchronousTraversals) {
2621
+ traversal();
2622
+ return;
2623
+ }
2624
+ // Each traversal occupies a single timeout resolution.
2625
+ // This means that Promises added to commit and finish should resolve
2626
+ // before the next traversal.
2627
+ this.nextTraversal = this.nextTraversal.then(() => {
2628
+ return new Promise((resolve) => {
2629
+ setTimeout(() => {
2630
+ resolve();
2631
+ traversal();
2632
+ });
2633
+ });
2634
+ });
2635
+ }
2636
+ /** Equivalent to `navigation.addEventListener()`. */
2637
+ addEventListener(type, callback, options) {
2638
+ this.eventTarget.addEventListener(type, callback, options);
2639
+ }
2640
+ /** Equivalent to `navigation.removeEventListener()`. */
2641
+ removeEventListener(type, callback, options) {
2642
+ this.eventTarget.removeEventListener(type, callback, options);
2643
+ }
2644
+ /** Equivalent to `navigation.dispatchEvent()` */
2645
+ dispatchEvent(event) {
2646
+ return this.eventTarget.dispatchEvent(event);
2647
+ }
2648
+ /** Cleans up resources. */
2649
+ dispose() {
2650
+ // Recreate eventTarget to release current listeners.
2651
+ // `document.createElement` because NodeJS `EventTarget` is incompatible with Domino's `Event`.
2652
+ this.eventTarget = this.window.document.createElement('div');
2653
+ this.disposed = true;
2654
+ }
2655
+ /** Returns whether this fake is disposed. */
2656
+ isDisposed() {
2657
+ return this.disposed;
2658
+ }
2659
+ /** Implementation for all navigations and traversals. */
2660
+ userAgentNavigate(destination, result, options) {
2661
+ // The first navigation should disallow any future calls to set the initial
2662
+ // entry.
2663
+ this.canSetInitialEntry = false;
2664
+ if (this.navigateEvent) {
2665
+ this.navigateEvent.cancel(new DOMException('Navigation was aborted', 'AbortError'));
2666
+ this.navigateEvent = undefined;
2667
+ }
2668
+ const navigateEvent = createFakeNavigateEvent({
2669
+ navigationType: options.navigationType,
2670
+ cancelable: options.cancelable,
2671
+ canIntercept: options.canIntercept,
2672
+ userInitiated: options.userInitiated,
2673
+ hashChange: options.hashChange,
2674
+ signal: result.signal,
2675
+ destination,
2676
+ info: options.info,
2677
+ sameDocument: destination.sameDocument,
2678
+ skipPopState: options.skipPopState,
2679
+ result,
2680
+ userAgentCommit: () => {
2681
+ this.userAgentCommit();
2682
+ },
2683
+ });
2684
+ this.navigateEvent = navigateEvent;
2685
+ this.eventTarget.dispatchEvent(navigateEvent);
2686
+ navigateEvent.dispatchedNavigateEvent();
2687
+ if (navigateEvent.commitOption === 'immediate') {
2688
+ navigateEvent.commit(/* internal= */ true);
2689
+ }
2690
+ }
2691
+ /** Implementation to commit a navigation. */
2692
+ userAgentCommit() {
2693
+ if (!this.navigateEvent) {
2694
+ return;
2695
+ }
2696
+ const from = this.currentEntry;
2697
+ if (!this.navigateEvent.sameDocument) {
2698
+ const error = new Error('Cannot navigate to a non-same-document URL.');
2699
+ this.navigateEvent.cancel(error);
2700
+ throw error;
2701
+ }
2702
+ if (this.navigateEvent.navigationType === 'push' ||
2703
+ this.navigateEvent.navigationType === 'replace') {
2704
+ this.userAgentPushOrReplace(this.navigateEvent.destination, {
2705
+ navigationType: this.navigateEvent.navigationType,
2706
+ });
2707
+ }
2708
+ else if (this.navigateEvent.navigationType === 'traverse') {
2709
+ this.userAgentTraverse(this.navigateEvent.destination);
2710
+ }
2711
+ this.navigateEvent.userAgentNavigated(this.currentEntry);
2712
+ const currentEntryChangeEvent = createFakeNavigationCurrentEntryChangeEvent({
2713
+ from,
2714
+ navigationType: this.navigateEvent.navigationType,
2715
+ });
2716
+ this.eventTarget.dispatchEvent(currentEntryChangeEvent);
2717
+ if (!this.navigateEvent.skipPopState) {
2718
+ const popStateEvent = createPopStateEvent({
2719
+ state: this.navigateEvent.destination.getHistoryState(),
2720
+ });
2721
+ this.window.dispatchEvent(popStateEvent);
2722
+ }
2723
+ }
2724
+ /** Implementation for a push or replace navigation. */
2725
+ userAgentPushOrReplace(destination, { navigationType }) {
2726
+ if (navigationType === 'push') {
2727
+ this.currentEntryIndex++;
2728
+ this.prospectiveEntryIndex = this.currentEntryIndex;
2729
+ }
2730
+ const index = this.currentEntryIndex;
2731
+ const key = navigationType === 'push' ? String(this.nextKey++) : this.currentEntry.key;
2732
+ const entry = new FakeNavigationHistoryEntry(destination.url, {
2733
+ id: String(this.nextId++),
2734
+ key,
2735
+ index,
2736
+ sameDocument: true,
2737
+ state: destination.getState(),
2738
+ historyState: destination.getHistoryState(),
2739
+ });
2740
+ if (navigationType === 'push') {
2741
+ this.entriesArr.splice(index, Infinity, entry);
2742
+ }
2743
+ else {
2744
+ this.entriesArr[index] = entry;
2745
+ }
2746
+ }
2747
+ /** Implementation for a traverse navigation. */
2748
+ userAgentTraverse(destination) {
2749
+ this.currentEntryIndex = destination.index;
2750
+ }
2751
+ /** Utility method for finding entries with the given `key`. */
2752
+ findEntry(key) {
2753
+ for (const entry of this.entriesArr) {
2754
+ if (entry.key === key)
2755
+ return entry;
2756
+ }
2757
+ return undefined;
2758
+ }
2759
+ set onnavigate(
2760
+ // tslint:disable-next-line:no-any
2761
+ _handler) {
2762
+ throw new Error('unimplemented');
2763
+ }
2764
+ // tslint:disable-next-line:no-any
2765
+ get onnavigate() {
2766
+ throw new Error('unimplemented');
2767
+ }
2768
+ set oncurrententrychange(_handler) {
2769
+ throw new Error('unimplemented');
2770
+ }
2771
+ get oncurrententrychange() {
2772
+ throw new Error('unimplemented');
2773
+ }
2774
+ set onnavigatesuccess(
2775
+ // tslint:disable-next-line:no-any
2776
+ _handler) {
2777
+ throw new Error('unimplemented');
2778
+ }
2779
+ // tslint:disable-next-line:no-any
2780
+ get onnavigatesuccess() {
2781
+ throw new Error('unimplemented');
2782
+ }
2783
+ set onnavigateerror(
2784
+ // tslint:disable-next-line:no-any
2785
+ _handler) {
2786
+ throw new Error('unimplemented');
2787
+ }
2788
+ // tslint:disable-next-line:no-any
2789
+ get onnavigateerror() {
2790
+ throw new Error('unimplemented');
2791
+ }
2792
+ get transition() {
2793
+ throw new Error('unimplemented');
2794
+ }
2795
+ updateCurrentEntry(_options) {
2796
+ throw new Error('unimplemented');
2797
+ }
2798
+ reload(_options) {
2799
+ throw new Error('unimplemented');
2800
+ }
2801
+ }
2802
+ /**
2803
+ * Fake equivalent of `NavigationHistoryEntry`.
2804
+ */
2805
+ class FakeNavigationHistoryEntry {
2806
+ url;
2807
+ sameDocument;
2808
+ id;
2809
+ key;
2810
+ index;
2811
+ state;
2812
+ historyState;
2813
+ // tslint:disable-next-line:no-any
2814
+ ondispose = null;
2815
+ constructor(url, { id, key, index, sameDocument, state, historyState, }) {
2816
+ this.url = url;
2817
+ this.id = id;
2818
+ this.key = key;
2819
+ this.index = index;
2820
+ this.sameDocument = sameDocument;
2821
+ this.state = state;
2822
+ this.historyState = historyState;
2823
+ }
2824
+ getState() {
2825
+ // Budget copy.
2826
+ return this.state ? JSON.parse(JSON.stringify(this.state)) : this.state;
2827
+ }
2828
+ getHistoryState() {
2829
+ // Budget copy.
2830
+ return this.historyState
2831
+ ? JSON.parse(JSON.stringify(this.historyState))
2832
+ : this.historyState;
2833
+ }
2834
+ addEventListener(type, callback, options) {
2835
+ throw new Error('unimplemented');
2836
+ }
2837
+ removeEventListener(type, callback, options) {
2838
+ throw new Error('unimplemented');
2839
+ }
2840
+ dispatchEvent(event) {
2841
+ throw new Error('unimplemented');
2842
+ }
2843
+ }
2844
+ /**
2845
+ * Create a fake equivalent of `NavigateEvent`. This is not a class because ES5
2846
+ * transpiled JavaScript cannot extend native Event.
2847
+ */
2848
+ function createFakeNavigateEvent({ cancelable, canIntercept, userInitiated, hashChange, navigationType, signal, destination, info, sameDocument, skipPopState, result, userAgentCommit, }) {
2849
+ const event = new Event('navigate', { bubbles: false, cancelable });
2850
+ event.canIntercept = canIntercept;
2851
+ event.userInitiated = userInitiated;
2852
+ event.hashChange = hashChange;
2853
+ event.navigationType = navigationType;
2854
+ event.signal = signal;
2855
+ event.destination = destination;
2856
+ event.info = info;
2857
+ event.downloadRequest = null;
2858
+ event.formData = null;
2859
+ event.sameDocument = sameDocument;
2860
+ event.skipPopState = skipPopState;
2861
+ event.commitOption = 'immediate';
2862
+ let handlerFinished = undefined;
2863
+ let interceptCalled = false;
2864
+ let dispatchedNavigateEvent = false;
2865
+ let commitCalled = false;
2866
+ event.intercept = function (options) {
2867
+ interceptCalled = true;
2868
+ event.sameDocument = true;
2869
+ const handler = options?.handler;
2870
+ if (handler) {
2871
+ handlerFinished = handler();
2872
+ }
2873
+ if (options?.commit) {
2874
+ event.commitOption = options.commit;
2875
+ }
2876
+ // TODO: handle focus reset and scroll?
2877
+ };
2878
+ event.scroll = function () {
2879
+ // TODO: handle scroll?
2880
+ };
2881
+ event.commit = function (internal = false) {
2882
+ if (!internal && !interceptCalled) {
2883
+ throw new DOMException(`Failed to execute 'commit' on 'NavigateEvent': intercept() must be ` +
2884
+ `called before commit().`, 'InvalidStateError');
2885
+ }
2886
+ if (!dispatchedNavigateEvent) {
2887
+ throw new DOMException(`Failed to execute 'commit' on 'NavigateEvent': commit() may not be ` +
2888
+ `called during event dispatch.`, 'InvalidStateError');
2889
+ }
2890
+ if (commitCalled) {
2891
+ throw new DOMException(`Failed to execute 'commit' on 'NavigateEvent': commit() already ` + `called.`, 'InvalidStateError');
2892
+ }
2893
+ commitCalled = true;
2894
+ userAgentCommit();
2895
+ };
2896
+ // Internal only.
2897
+ event.cancel = function (reason) {
2898
+ result.committedReject(reason);
2899
+ result.finishedReject(reason);
2900
+ };
2901
+ // Internal only.
2902
+ event.dispatchedNavigateEvent = function () {
2903
+ dispatchedNavigateEvent = true;
2904
+ if (event.commitOption === 'after-transition') {
2905
+ // If handler finishes before commit, call commit.
2906
+ handlerFinished?.then(() => {
2907
+ if (!commitCalled) {
2908
+ event.commit(/* internal */ true);
2909
+ }
2910
+ }, () => { });
2911
+ }
2912
+ Promise.all([result.committed, handlerFinished]).then(([entry]) => {
2913
+ result.finishedResolve(entry);
2914
+ }, (reason) => {
2915
+ result.finishedReject(reason);
2916
+ });
2917
+ };
2918
+ // Internal only.
2919
+ event.userAgentNavigated = function (entry) {
2920
+ result.committedResolve(entry);
2921
+ };
2922
+ return event;
2923
+ }
2924
+ /**
2925
+ * Create a fake equivalent of `NavigationCurrentEntryChange`. This does not use
2926
+ * a class because ES5 transpiled JavaScript cannot extend native Event.
2927
+ */
2928
+ function createFakeNavigationCurrentEntryChangeEvent({ from, navigationType, }) {
2929
+ const event = new Event('currententrychange', {
2930
+ bubbles: false,
2931
+ cancelable: false,
2932
+ });
2933
+ event.from = from;
2934
+ event.navigationType = navigationType;
2935
+ return event;
2936
+ }
2937
+ /**
2938
+ * Create a fake equivalent of `PopStateEvent`. This does not use a class
2939
+ * because ES5 transpiled JavaScript cannot extend native Event.
2940
+ */
2941
+ function createPopStateEvent({ state }) {
2942
+ const event = new Event('popstate', {
2943
+ bubbles: false,
2944
+ cancelable: false,
2945
+ });
2946
+ event.state = state;
2947
+ return event;
2948
+ }
2949
+ /**
2950
+ * Fake equivalent of `NavigationDestination`.
2951
+ */
2952
+ class FakeNavigationDestination {
2953
+ url;
2954
+ sameDocument;
2955
+ key;
2956
+ id;
2957
+ index;
2958
+ state;
2959
+ historyState;
2960
+ constructor({ url, sameDocument, historyState, state, key = null, id = null, index = -1, }) {
2961
+ this.url = url;
2962
+ this.sameDocument = sameDocument;
2963
+ this.state = state;
2964
+ this.historyState = historyState;
2965
+ this.key = key;
2966
+ this.id = id;
2967
+ this.index = index;
2968
+ }
2969
+ getState() {
2970
+ return this.state;
2971
+ }
2972
+ getHistoryState() {
2973
+ return this.historyState;
2974
+ }
2975
+ }
2976
+ /** Utility function to determine whether two UrlLike have the same hash. */
2977
+ function isHashChange(from, to) {
2978
+ return (to.hash !== from.hash &&
2979
+ to.hostname === from.hostname &&
2980
+ to.pathname === from.pathname &&
2981
+ to.search === from.search);
2982
+ }
2983
+ /** Internal utility class for representing the result of a navigation. */
2984
+ class InternalNavigationResult {
2985
+ committedResolve;
2986
+ committedReject;
2987
+ finishedResolve;
2988
+ finishedReject;
2989
+ committed;
2990
+ finished;
2991
+ get signal() {
2992
+ return this.abortController.signal;
2993
+ }
2994
+ abortController = new AbortController();
2995
+ constructor() {
2996
+ this.committed = new Promise((resolve, reject) => {
2997
+ this.committedResolve = resolve;
2998
+ this.committedReject = reject;
2999
+ });
3000
+ this.finished = new Promise(async (resolve, reject) => {
3001
+ this.finishedResolve = resolve;
3002
+ this.finishedReject = (reason) => {
3003
+ reject(reason);
3004
+ this.abortController.abort(reason);
3005
+ };
3006
+ });
3007
+ // All rejections are handled.
3008
+ this.committed.catch(() => { });
3009
+ this.finished.catch(() => { });
3010
+ }
3011
+ }
3012
+
2311
3013
  /// <reference types="jasmine" />
2312
3014
  // This file only reexports content of the `src` folder. Keep it that way.
2313
3015
 
@@ -2317,5 +3019,5 @@ const __core_private_testing_placeholder__ = '';
2317
3019
  * Generated bundle index. Do not edit.
2318
3020
  */
2319
3021
 
2320
- export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, DeferBlockFixture, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
3022
+ export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, DeferBlockFixture, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, FakeNavigation as ɵFakeNavigation, MetadataOverrider as ɵMetadataOverrider };
2321
3023
  //# sourceMappingURL=testing.mjs.map