index.d.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * @license Angular v16.2.9
  3. * (c) 2010-2022 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import { InjectionToken } from '@angular/core';
  8. import { Location as Location_2 } from '@angular/common';
  9. import { LocationChangeListener } from '@angular/common';
  10. import { LocationStrategy } from '@angular/common';
  11. import { PlatformLocation } from '@angular/common';
  12. import { Provider } from '@angular/core';
  13. import { SubscriptionLike } from 'rxjs';
  14. /**
  15. * Provider for mock platform location config
  16. *
  17. * @publicApi
  18. */
  19. export declare const MOCK_PLATFORM_LOCATION_CONFIG: InjectionToken<MockPlatformLocationConfig>;
  20. /**
  21. * A mock implementation of {@link LocationStrategy} that allows tests to fire simulated
  22. * location events.
  23. *
  24. * @publicApi
  25. */
  26. export declare class MockLocationStrategy extends LocationStrategy {
  27. internalBaseHref: string;
  28. internalPath: string;
  29. internalTitle: string;
  30. urlChanges: string[];
  31. private stateChanges;
  32. constructor();
  33. simulatePopState(url: string): void;
  34. path(includeHash?: boolean): string;
  35. prepareExternalUrl(internal: string): string;
  36. pushState(ctx: any, title: string, path: string, query: string): void;
  37. replaceState(ctx: any, title: string, path: string, query: string): void;
  38. onPopState(fn: (value: any) => void): void;
  39. getBaseHref(): string;
  40. back(): void;
  41. forward(): void;
  42. getState(): unknown;
  43. static ɵfac: i0.ɵɵFactoryDeclaration<MockLocationStrategy, never>;
  44. static ɵprov: i0.ɵɵInjectableDeclaration<MockLocationStrategy>;
  45. }
  46. /**
  47. * Mock implementation of URL state.
  48. *
  49. * @publicApi
  50. */
  51. export declare class MockPlatformLocation implements PlatformLocation {
  52. private baseHref;
  53. private hashUpdate;
  54. private popStateSubject;
  55. private urlChangeIndex;
  56. private urlChanges;
  57. constructor(config?: MockPlatformLocationConfig);
  58. get hostname(): string;
  59. get protocol(): string;
  60. get port(): string;
  61. get pathname(): string;
  62. get search(): string;
  63. get hash(): string;
  64. get state(): unknown;
  65. getBaseHrefFromDOM(): string;
  66. onPopState(fn: LocationChangeListener): VoidFunction;
  67. onHashChange(fn: LocationChangeListener): VoidFunction;
  68. get href(): string;
  69. get url(): string;
  70. private parseChanges;
  71. replaceState(state: any, title: string, newUrl: string): void;
  72. pushState(state: any, title: string, newUrl: string): void;
  73. forward(): void;
  74. back(): void;
  75. historyGo(relativePosition?: number): void;
  76. getState(): unknown;
  77. /**
  78. * Browsers are inconsistent in when they fire events and perform the state updates
  79. * The most easiest thing to do in our mock is synchronous and that happens to match
  80. * Firefox and Chrome, at least somewhat closely
  81. *
  82. * https://github.com/WICG/navigation-api#watching-for-navigations
  83. * https://docs.google.com/document/d/1Pdve-DJ1JCGilj9Yqf5HxRJyBKSel5owgOvUJqTauwU/edit#heading=h.3ye4v71wsz94
  84. * popstate is always sent before hashchange:
  85. * https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent
  86. */
  87. private emitEvents;
  88. static ɵfac: i0.ɵɵFactoryDeclaration<MockPlatformLocation, [{ optional: true; }]>;
  89. static ɵprov: i0.ɵɵInjectableDeclaration<MockPlatformLocation>;
  90. }
  91. /**
  92. * Mock platform location config
  93. *
  94. * @publicApi
  95. */
  96. export declare interface MockPlatformLocationConfig {
  97. startUrl?: string;
  98. appBaseHref?: string;
  99. }
  100. /**
  101. * Returns mock providers for the `Location` and `LocationStrategy` classes.
  102. * The mocks are helpful in tests to fire simulated location events.
  103. *
  104. * @publicApi
  105. */
  106. export declare function provideLocationMocks(): Provider[];
  107. /**
  108. * A spy for {@link Location} that allows tests to fire simulated location events.
  109. *
  110. * @publicApi
  111. */
  112. export declare class SpyLocation implements Location_2 {
  113. urlChanges: string[];
  114. private _history;
  115. private _historyIndex;
  116. /** @nodoc */
  117. ngOnDestroy(): void;
  118. setInitialPath(url: string): void;
  119. setBaseHref(url: string): void;
  120. path(): string;
  121. getState(): unknown;
  122. isCurrentPathEqualTo(path: string, query?: string): boolean;
  123. simulateUrlPop(pathname: string): void;
  124. simulateHashChange(pathname: string): void;
  125. prepareExternalUrl(url: string): string;
  126. go(path: string, query?: string, state?: any): void;
  127. replaceState(path: string, query?: string, state?: any): void;
  128. forward(): void;
  129. back(): void;
  130. historyGo(relativePosition?: number): void;
  131. onUrlChange(fn: (url: string, state: unknown) => void): VoidFunction;
  132. subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike;
  133. normalize(url: string): string;
  134. private pushHistory;
  135. static ɵfac: i0.ɵɵFactoryDeclaration<SpyLocation, never>;
  136. static ɵprov: i0.ɵɵInjectableDeclaration<SpyLocation>;
  137. }
  138. export { }