index.d.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /**
  2. * @license Angular v19.2.13
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as _angular_core from '@angular/core';
  7. import { ɵDeferBlockDetails as _DeferBlockDetails, ɵDeferBlockState as _DeferBlockState, ComponentRef, DebugElement, ElementRef, ChangeDetectorRef, NgZone, SchemaMetadata, ɵDeferBlockBehavior as _DeferBlockBehavior, InjectionToken, PlatformRef, Type, ProviderToken, InjectOptions, InjectFlags, NgModule, Component, Directive, Pipe } from '@angular/core';
  8. export { ɵDeferBlockBehavior as DeferBlockBehavior, ɵDeferBlockState as DeferBlockState } from '@angular/core';
  9. import { Navigation, NavigationHistoryEntry, NavigationNavigateOptions, NavigationResult, NavigationOptions, NavigateEvent, NavigationCurrentEntryChangeEvent, NavigationTransition, NavigationUpdateCurrentEntryOptions, NavigationReloadOptions } from '../navigation_types.d-fAxd92YV.js';
  10. /**
  11. * Wraps a test function in an asynchronous test zone. The test will automatically
  12. * complete when all asynchronous calls within this zone are done. Can be used
  13. * to wrap an {@link inject} call.
  14. *
  15. * Example:
  16. *
  17. * ```ts
  18. * it('...', waitForAsync(inject([AClass], (object) => {
  19. * object.doSomething.then(() => {
  20. * expect(...);
  21. * })
  22. * })));
  23. * ```
  24. *
  25. * @publicApi
  26. */
  27. declare function waitForAsync(fn: Function): (done: any) => any;
  28. /**
  29. * Represents an individual defer block for testing purposes.
  30. *
  31. * @publicApi
  32. */
  33. declare class DeferBlockFixture {
  34. private block;
  35. private componentFixture;
  36. /** @docs-private */
  37. constructor(block: _DeferBlockDetails, componentFixture: ComponentFixture<unknown>);
  38. /**
  39. * Renders the specified state of the defer fixture.
  40. * @param state the defer state to render
  41. */
  42. render(state: _DeferBlockState): Promise<void>;
  43. /**
  44. * Retrieves all nested child defer block fixtures
  45. * in a given defer block.
  46. */
  47. getDeferBlocks(): Promise<DeferBlockFixture[]>;
  48. }
  49. /**
  50. * Fixture for debugging and testing a component.
  51. *
  52. * @publicApi
  53. */
  54. declare class ComponentFixture<T> {
  55. componentRef: ComponentRef<T>;
  56. /**
  57. * The DebugElement associated with the root element of this component.
  58. */
  59. debugElement: DebugElement;
  60. /**
  61. * The instance of the root component class.
  62. */
  63. componentInstance: T;
  64. /**
  65. * The native element at the root of the component.
  66. */
  67. nativeElement: any;
  68. /**
  69. * The ElementRef for the element at the root of the component.
  70. */
  71. elementRef: ElementRef;
  72. /**
  73. * The ChangeDetectorRef for the component
  74. */
  75. changeDetectorRef: ChangeDetectorRef;
  76. private _renderer;
  77. private _isDestroyed;
  78. private readonly _testAppRef;
  79. private readonly pendingTasks;
  80. private readonly appErrorHandler;
  81. private readonly zonelessEnabled;
  82. private readonly scheduler;
  83. private readonly rootEffectScheduler;
  84. private readonly microtaskEffectScheduler;
  85. private readonly autoDetectDefault;
  86. private autoDetect;
  87. private subscriptions;
  88. ngZone: NgZone | null;
  89. /** @docs-private */
  90. constructor(componentRef: ComponentRef<T>);
  91. /**
  92. * Trigger a change detection cycle for the component.
  93. */
  94. detectChanges(checkNoChanges?: boolean): void;
  95. /**
  96. * Do a change detection run to make sure there were no changes.
  97. */
  98. checkNoChanges(): void;
  99. /**
  100. * Set whether the fixture should autodetect changes.
  101. *
  102. * Also runs detectChanges once so that any existing change is detected.
  103. *
  104. * @param autoDetect Whether to autodetect changes. By default, `true`.
  105. */
  106. autoDetectChanges(autoDetect?: boolean): void;
  107. /**
  108. * Return whether the fixture is currently stable or has async tasks that have not been completed
  109. * yet.
  110. */
  111. isStable(): boolean;
  112. /**
  113. * Get a promise that resolves when the fixture is stable.
  114. *
  115. * This can be used to resume testing after events have triggered asynchronous activity or
  116. * asynchronous change detection.
  117. */
  118. whenStable(): Promise<any>;
  119. /**
  120. * Retrieves all defer block fixtures in the component fixture.
  121. */
  122. getDeferBlocks(): Promise<DeferBlockFixture[]>;
  123. private _getRenderer;
  124. /**
  125. * Get a promise that resolves when the ui state is stable following animations.
  126. */
  127. whenRenderingDone(): Promise<any>;
  128. /**
  129. * Trigger component destruction.
  130. */
  131. destroy(): void;
  132. }
  133. /**
  134. * Clears out the shared fake async zone for a test.
  135. * To be called in a global `beforeEach`.
  136. *
  137. * @publicApi
  138. */
  139. declare function resetFakeAsyncZone(): void;
  140. /**
  141. * Wraps a function to be executed in the `fakeAsync` zone:
  142. * - Microtasks are manually executed by calling `flushMicrotasks()`.
  143. * - Timers are synchronous; `tick()` simulates the asynchronous passage of time.
  144. *
  145. * Can be used to wrap `inject()` calls.
  146. *
  147. * @param fn The function that you want to wrap in the `fakeAsync` zone.
  148. * @param options
  149. * - flush: When true, will drain the macrotask queue after the test function completes.
  150. * When false, will throw an exception at the end of the function if there are pending timers.
  151. *
  152. * @usageNotes
  153. * ### Example
  154. *
  155. * {@example core/testing/ts/fake_async.ts region='basic'}
  156. *
  157. *
  158. * @returns The function wrapped to be executed in the `fakeAsync` zone.
  159. * Any arguments passed when calling this returned function will be passed through to the `fn`
  160. * function in the parameters when it is called.
  161. *
  162. * @publicApi
  163. */
  164. declare function fakeAsync(fn: Function, options?: {
  165. flush?: boolean;
  166. }): (...args: any[]) => any;
  167. /**
  168. * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
  169. *
  170. * The microtasks queue is drained at the very start of this function and after any timer callback
  171. * has been executed.
  172. *
  173. * @param millis The number of milliseconds to advance the virtual timer.
  174. * @param tickOptions The options to pass to the `tick()` function.
  175. *
  176. * @usageNotes
  177. *
  178. * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
  179. * which determines whether or not to invoke new macroTasks.
  180. *
  181. * If you provide a `tickOptions` object, but do not specify a
  182. * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
  183. * then `processNewMacroTasksSynchronously` defaults to true.
  184. *
  185. * If you omit the `tickOptions` parameter (`tick(100))`), then
  186. * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
  187. *
  188. * ### Example
  189. *
  190. * {@example core/testing/ts/fake_async.ts region='basic'}
  191. *
  192. * The following example includes a nested timeout (new macroTask), and
  193. * the `tickOptions` parameter is allowed to default. In this case,
  194. * `processNewMacroTasksSynchronously` defaults to true, and the nested
  195. * function is executed on each tick.
  196. *
  197. * ```ts
  198. * it ('test with nested setTimeout', fakeAsync(() => {
  199. * let nestedTimeoutInvoked = false;
  200. * function funcWithNestedTimeout() {
  201. * setTimeout(() => {
  202. * nestedTimeoutInvoked = true;
  203. * });
  204. * };
  205. * setTimeout(funcWithNestedTimeout);
  206. * tick();
  207. * expect(nestedTimeoutInvoked).toBe(true);
  208. * }));
  209. * ```
  210. *
  211. * In the following case, `processNewMacroTasksSynchronously` is explicitly
  212. * set to false, so the nested timeout function is not invoked.
  213. *
  214. * ```ts
  215. * it ('test with nested setTimeout', fakeAsync(() => {
  216. * let nestedTimeoutInvoked = false;
  217. * function funcWithNestedTimeout() {
  218. * setTimeout(() => {
  219. * nestedTimeoutInvoked = true;
  220. * });
  221. * };
  222. * setTimeout(funcWithNestedTimeout);
  223. * tick(0, {processNewMacroTasksSynchronously: false});
  224. * expect(nestedTimeoutInvoked).toBe(false);
  225. * }));
  226. * ```
  227. *
  228. *
  229. * @publicApi
  230. */
  231. declare function tick(millis?: number, tickOptions?: {
  232. processNewMacroTasksSynchronously: boolean;
  233. }): void;
  234. /**
  235. * Flushes any pending microtasks and simulates the asynchronous passage of time for the timers in
  236. * the `fakeAsync` zone by
  237. * draining the macrotask queue until it is empty.
  238. *
  239. * @param maxTurns The maximum number of times the scheduler attempts to clear its queue before
  240. * throwing an error.
  241. * @returns The simulated time elapsed, in milliseconds.
  242. *
  243. * @publicApi
  244. */
  245. declare function flush(maxTurns?: number): number;
  246. /**
  247. * Discard all remaining periodic tasks.
  248. *
  249. * @publicApi
  250. */
  251. declare function discardPeriodicTasks(): void;
  252. /**
  253. * Flush any pending microtasks.
  254. *
  255. * @publicApi
  256. */
  257. declare function flushMicrotasks(): void;
  258. /**
  259. * Type used for modifications to metadata
  260. *
  261. * @publicApi
  262. */
  263. type MetadataOverride<T> = {
  264. add?: Partial<T>;
  265. remove?: Partial<T>;
  266. set?: Partial<T>;
  267. };
  268. /**
  269. * An abstract class for inserting the root test component element in a platform independent way.
  270. *
  271. * @publicApi
  272. */
  273. declare class TestComponentRenderer {
  274. insertRootElement(rootElementId: string): void;
  275. removeAllRootElements?(): void;
  276. }
  277. /**
  278. * @publicApi
  279. */
  280. declare const ComponentFixtureAutoDetect: InjectionToken<boolean>;
  281. /**
  282. * @publicApi
  283. */
  284. declare const ComponentFixtureNoNgZone: InjectionToken<boolean>;
  285. /**
  286. * @publicApi
  287. */
  288. interface TestModuleMetadata {
  289. providers?: any[];
  290. declarations?: any[];
  291. imports?: any[];
  292. schemas?: Array<SchemaMetadata | any[]>;
  293. teardown?: ModuleTeardownOptions;
  294. /**
  295. * Whether NG0304 runtime errors should be thrown when unknown elements are present in component's
  296. * template. Defaults to `false`, where the error is simply logged. If set to `true`, the error is
  297. * thrown.
  298. * @see [NG8001](/errors/NG8001) for the description of the problem and how to fix it
  299. */
  300. errorOnUnknownElements?: boolean;
  301. /**
  302. * Whether errors should be thrown when unknown properties are present in component's template.
  303. * Defaults to `false`, where the error is simply logged.
  304. * If set to `true`, the error is thrown.
  305. * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
  306. */
  307. errorOnUnknownProperties?: boolean;
  308. /**
  309. * Whether errors that happen during application change detection should be rethrown.
  310. *
  311. * When `true`, errors that are caught during application change detection will
  312. * be reported to the `ErrorHandler` and rethrown to prevent them from going
  313. * unnoticed in tests.
  314. *
  315. * When `false`, errors are only forwarded to the `ErrorHandler`, which by default
  316. * simply logs them to the console.
  317. *
  318. * Defaults to `true`.
  319. */
  320. rethrowApplicationErrors?: boolean;
  321. /**
  322. * Whether defer blocks should behave with manual triggering or play through normally.
  323. * Defaults to `manual`.
  324. */
  325. deferBlockBehavior?: _DeferBlockBehavior;
  326. }
  327. /**
  328. * @publicApi
  329. */
  330. interface TestEnvironmentOptions {
  331. /**
  332. * Configures the test module teardown behavior in `TestBed`.
  333. */
  334. teardown?: ModuleTeardownOptions;
  335. /**
  336. * Whether errors should be thrown when unknown elements are present in component's template.
  337. * Defaults to `false`, where the error is simply logged.
  338. * If set to `true`, the error is thrown.
  339. * @see [NG8001](/errors/NG8001) for the description of the error and how to fix it
  340. */
  341. errorOnUnknownElements?: boolean;
  342. /**
  343. * Whether errors should be thrown when unknown properties are present in component's template.
  344. * Defaults to `false`, where the error is simply logged.
  345. * If set to `true`, the error is thrown.
  346. * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
  347. */
  348. errorOnUnknownProperties?: boolean;
  349. }
  350. /**
  351. * Configures the test module teardown behavior in `TestBed`.
  352. * @publicApi
  353. */
  354. interface ModuleTeardownOptions {
  355. /** Whether the test module should be destroyed after every test. Defaults to `true`. */
  356. destroyAfterEach: boolean;
  357. /** Whether errors during test module destruction should be re-thrown. Defaults to `true`. */
  358. rethrowErrors?: boolean;
  359. }
  360. /**
  361. * Static methods implemented by the `TestBed`.
  362. *
  363. * @publicApi
  364. */
  365. interface TestBedStatic extends TestBed {
  366. new (...args: any[]): TestBed;
  367. }
  368. /**
  369. * Returns a singleton of the `TestBed` class.
  370. *
  371. * @publicApi
  372. */
  373. declare function getTestBed(): TestBed;
  374. /**
  375. * @publicApi
  376. */
  377. interface TestBed {
  378. get platform(): PlatformRef;
  379. get ngModule(): Type<any> | Type<any>[];
  380. /**
  381. * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
  382. * angular module. These are common to every test in the suite.
  383. *
  384. * This may only be called once, to set up the common providers for the current test
  385. * suite on the current platform. If you absolutely need to change the providers,
  386. * first use `resetTestEnvironment`.
  387. *
  388. * Test modules and platforms for individual platforms are available from
  389. * '@angular/<platform_name>/testing'.
  390. */
  391. initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, options?: TestEnvironmentOptions): void;
  392. /**
  393. * Reset the providers for the test injector.
  394. */
  395. resetTestEnvironment(): void;
  396. resetTestingModule(): TestBed;
  397. configureCompiler(config: {
  398. providers?: any[];
  399. useJit?: boolean;
  400. }): void;
  401. configureTestingModule(moduleDef: TestModuleMetadata): TestBed;
  402. compileComponents(): Promise<any>;
  403. inject<T>(token: ProviderToken<T>, notFoundValue: undefined, options: InjectOptions & {
  404. optional?: false;
  405. }): T;
  406. inject<T>(token: ProviderToken<T>, notFoundValue: null | undefined, options: InjectOptions): T | null;
  407. inject<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T;
  408. /** @deprecated use object-based flags (`InjectOptions`) instead. */
  409. inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
  410. /** @deprecated use object-based flags (`InjectOptions`) instead. */
  411. inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
  412. /** @deprecated from v9.0.0 use TestBed.inject */
  413. get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
  414. /** @deprecated from v9.0.0 use TestBed.inject */
  415. get(token: any, notFoundValue?: any): any;
  416. /**
  417. * Runs the given function in the `EnvironmentInjector` context of `TestBed`.
  418. *
  419. * @see {@link EnvironmentInjector#runInContext}
  420. */
  421. runInInjectionContext<T>(fn: () => T): T;
  422. execute(tokens: any[], fn: Function, context?: any): any;
  423. overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBed;
  424. overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBed;
  425. overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBed;
  426. overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBed;
  427. overrideTemplate(component: Type<any>, template: string): TestBed;
  428. /**
  429. * Overwrites all providers for the given token with the given provider definition.
  430. */
  431. overrideProvider(token: any, provider: {
  432. useFactory: Function;
  433. deps: any[];
  434. multi?: boolean;
  435. }): TestBed;
  436. overrideProvider(token: any, provider: {
  437. useValue: any;
  438. multi?: boolean;
  439. }): TestBed;
  440. overrideProvider(token: any, provider: {
  441. useFactory?: Function;
  442. useValue?: any;
  443. deps?: any[];
  444. multi?: boolean;
  445. }): TestBed;
  446. overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBed;
  447. createComponent<T>(component: Type<T>): ComponentFixture<T>;
  448. /**
  449. * Execute any pending effects.
  450. *
  451. * @developerPreview
  452. */
  453. flushEffects(): void;
  454. }
  455. /**
  456. * @description
  457. * Configures and initializes environment for unit testing and provides methods for
  458. * creating components and services in unit tests.
  459. *
  460. * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
  461. *
  462. * @publicApi
  463. */
  464. declare const TestBed: TestBedStatic;
  465. /**
  466. * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
  467. * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
  468. * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
  469. * function from the `@angular/core` package instead.
  470. *
  471. * Example:
  472. *
  473. * ```ts
  474. * beforeEach(inject([Dependency, AClass], (dep, object) => {
  475. * // some code that uses `dep` and `object`
  476. * // ...
  477. * }));
  478. *
  479. * it('...', inject([AClass], (object) => {
  480. * object.doSomething();
  481. * expect(...);
  482. * })
  483. * ```
  484. *
  485. * @publicApi
  486. */
  487. declare function inject(tokens: any[], fn: Function): () => any;
  488. /**
  489. * @publicApi
  490. */
  491. declare class InjectSetupWrapper {
  492. private _moduleDef;
  493. constructor(_moduleDef: () => TestModuleMetadata);
  494. private _addModule;
  495. inject(tokens: any[], fn: Function): () => any;
  496. }
  497. /**
  498. * @publicApi
  499. */
  500. declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
  501. declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
  502. /**
  503. * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
  504. * investigation.
  505. *
  506. * A work around is to mark it as `@codeGenApi` for now and investigate later.
  507. *
  508. * @codeGenApi
  509. */
  510. declare const __core_private_testing_placeholder__ = "";
  511. declare class MetadataOverrider {
  512. private _references;
  513. /**
  514. * Creates a new instance for the given metadata class
  515. * based on an old instance and overrides.
  516. */
  517. overrideMetadata<C extends T, T>(metadataClass: {
  518. new (options: T): C;
  519. }, oldMetadata: C, override: MetadataOverride<T>): C;
  520. }
  521. /**
  522. * Fake implementation of user agent history and navigation behavior. This is a
  523. * high-fidelity implementation of browser behavior that attempts to emulate
  524. * things like traversal delay.
  525. */
  526. declare class FakeNavigation implements Navigation {
  527. /**
  528. * The fake implementation of an entries array. Only same-document entries
  529. * allowed.
  530. */
  531. private readonly entriesArr;
  532. /**
  533. * The current active entry index into `entriesArr`.
  534. */
  535. private currentEntryIndex;
  536. /**
  537. * A Map of pending traversals, so that traversals to the same entry can be
  538. * re-used.
  539. */
  540. private readonly traversalQueue;
  541. /**
  542. * A Promise that resolves when the previous traversals have finished. Used to
  543. * simulate the cross-process communication necessary for traversals.
  544. */
  545. private nextTraversal;
  546. /**
  547. * A prospective current active entry index, which includes unresolved
  548. * traversals. Used by `go` to determine where navigations are intended to go.
  549. */
  550. private prospectiveEntryIndex;
  551. /**
  552. * A test-only option to make traversals synchronous, rather than emulate
  553. * cross-process communication.
  554. */
  555. private synchronousTraversals;
  556. /** Whether to allow a call to setInitialEntryForTesting. */
  557. private canSetInitialEntry;
  558. /** The next unique id for created entries. Replace recreates this id. */
  559. private nextId;
  560. /** The next unique key for created entries. Replace inherits this id. */
  561. private nextKey;
  562. /** Whether this fake is disposed. */
  563. private disposed;
  564. /** Equivalent to `navigation.currentEntry`. */
  565. get currentEntry(): FakeNavigationHistoryEntry;
  566. get canGoBack(): boolean;
  567. get canGoForward(): boolean;
  568. private readonly createEventTarget;
  569. private readonly _window;
  570. get window(): Pick<Window, 'addEventListener' | 'removeEventListener'>;
  571. constructor(doc: Document, startURL: `http${string}`);
  572. /**
  573. * Sets the initial entry.
  574. */
  575. setInitialEntryForTesting(url: `http${string}`, options?: {
  576. historyState: unknown;
  577. state?: unknown;
  578. }): void;
  579. /** Returns whether the initial entry is still eligible to be set. */
  580. canSetInitialEntryForTesting(): boolean;
  581. /**
  582. * Sets whether to emulate traversals as synchronous rather than
  583. * asynchronous.
  584. */
  585. setSynchronousTraversalsForTesting(synchronousTraversals: boolean): void;
  586. /** Equivalent to `navigation.entries()`. */
  587. entries(): FakeNavigationHistoryEntry[];
  588. /** Equivalent to `navigation.navigate()`. */
  589. navigate(url: string, options?: NavigationNavigateOptions): FakeNavigationResult;
  590. /** Equivalent to `history.pushState()`. */
  591. pushState(data: unknown, title: string, url?: string): void;
  592. /** Equivalent to `history.replaceState()`. */
  593. replaceState(data: unknown, title: string, url?: string): void;
  594. private pushOrReplaceState;
  595. /** Equivalent to `navigation.traverseTo()`. */
  596. traverseTo(key: string, options?: NavigationOptions): FakeNavigationResult;
  597. /** Equivalent to `navigation.back()`. */
  598. back(options?: NavigationOptions): FakeNavigationResult;
  599. /** Equivalent to `navigation.forward()`. */
  600. forward(options?: NavigationOptions): FakeNavigationResult;
  601. /**
  602. * Equivalent to `history.go()`.
  603. * Note that this method does not actually work precisely to how Chrome
  604. * does, instead choosing a simpler model with less unexpected behavior.
  605. * Chrome has a few edge case optimizations, for instance with repeated
  606. * `back(); forward()` chains it collapses certain traversals.
  607. */
  608. go(direction: number): void;
  609. /** Runs a traversal synchronously or asynchronously */
  610. private runTraversal;
  611. /** Equivalent to `navigation.addEventListener()`. */
  612. addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
  613. /** Equivalent to `navigation.removeEventListener()`. */
  614. removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
  615. /** Equivalent to `navigation.dispatchEvent()` */
  616. dispatchEvent(event: Event): boolean;
  617. /** Cleans up resources. */
  618. dispose(): void;
  619. /** Returns whether this fake is disposed. */
  620. isDisposed(): boolean;
  621. /**
  622. * Implementation for all navigations and traversals.
  623. * @returns true if the event was intercepted, otherwise false
  624. */
  625. private userAgentNavigate;
  626. /** Utility method for finding entries with the given `key`. */
  627. private findEntry;
  628. set onnavigate(_handler: ((this: Navigation, ev: NavigateEvent) => any) | null);
  629. get onnavigate(): ((this: Navigation, ev: NavigateEvent) => any) | null;
  630. set oncurrententrychange(_handler: // tslint:disable-next-line:no-any
  631. ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null);
  632. get oncurrententrychange(): // tslint:disable-next-line:no-any
  633. ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null;
  634. set onnavigatesuccess(_handler: ((this: Navigation, ev: Event) => any) | null);
  635. get onnavigatesuccess(): ((this: Navigation, ev: Event) => any) | null;
  636. set onnavigateerror(_handler: ((this: Navigation, ev: ErrorEvent) => any) | null);
  637. get onnavigateerror(): ((this: Navigation, ev: ErrorEvent) => any) | null;
  638. private _transition;
  639. get transition(): NavigationTransition | null;
  640. updateCurrentEntry(_options: NavigationUpdateCurrentEntryOptions): void;
  641. reload(_options?: NavigationReloadOptions): NavigationResult;
  642. }
  643. /**
  644. * Fake equivalent of the `NavigationResult` interface with
  645. * `FakeNavigationHistoryEntry`.
  646. */
  647. interface FakeNavigationResult extends NavigationResult {
  648. readonly committed: Promise<FakeNavigationHistoryEntry>;
  649. readonly finished: Promise<FakeNavigationHistoryEntry>;
  650. }
  651. /**
  652. * Fake equivalent of `NavigationHistoryEntry`.
  653. */
  654. declare class FakeNavigationHistoryEntry implements NavigationHistoryEntry {
  655. private eventTarget;
  656. readonly url: string | null;
  657. readonly sameDocument: boolean;
  658. readonly id: string;
  659. readonly key: string;
  660. readonly index: number;
  661. private readonly state;
  662. private readonly historyState;
  663. ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
  664. constructor(eventTarget: EventTarget, url: string | null, { id, key, index, sameDocument, state, historyState, }: {
  665. id: string;
  666. key: string;
  667. index: number;
  668. sameDocument: boolean;
  669. historyState: unknown;
  670. state?: unknown;
  671. });
  672. getState(): unknown;
  673. getHistoryState(): unknown;
  674. addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
  675. removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
  676. dispatchEvent(event: Event): boolean;
  677. /** internal */
  678. dispose(): void;
  679. }
  680. declare class Log<T = string> {
  681. logItems: T[];
  682. constructor();
  683. add(value: T): void;
  684. fn(value: T): () => void;
  685. clear(): void;
  686. result(): string;
  687. static ɵfac: _angular_core.ɵɵFactoryDeclaration<Log<any>, never>;
  688. static ɵprov: _angular_core.ɵɵInjectableDeclaration<Log<any>>;
  689. }
  690. 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, Log as ɵLog, MetadataOverrider as ɵMetadataOverrider };
  691. export type { MetadataOverride, ModuleTeardownOptions, TestBedStatic, TestEnvironmentOptions, TestModuleMetadata };