testing.d.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { InjectionToken } from '@angular/core';
  7. import { Location } from '@angular/common';
  8. import { LocationChangeListener } from '@angular/common';
  9. import { LocationStrategy } from '@angular/common';
  10. import { PlatformLocation } from '@angular/common';
  11. import { SubscriptionLike } from 'rxjs';
  12. /**
  13. * Provider for mock platform location config
  14. *
  15. * @publicApi
  16. */
  17. export declare const MOCK_PLATFORM_LOCATION_CONFIG: InjectionToken<{}>;
  18. /**
  19. * A mock implementation of {@link LocationStrategy} that allows tests to fire simulated
  20. * location events.
  21. *
  22. * @publicApi
  23. */
  24. export declare class MockLocationStrategy extends LocationStrategy {
  25. internalBaseHref: string;
  26. internalPath: string;
  27. internalTitle: string;
  28. urlChanges: string[];
  29. private stateChanges;
  30. constructor();
  31. simulatePopState(url: string): void;
  32. path(includeHash?: boolean): string;
  33. prepareExternalUrl(internal: string): string;
  34. pushState(ctx: any, title: string, path: string, query: string): void;
  35. replaceState(ctx: any, title: string, path: string, query: string): void;
  36. onPopState(fn: (value: any) => void): void;
  37. getBaseHref(): string;
  38. back(): void;
  39. forward(): void;
  40. getState(): unknown;
  41. }
  42. /**
  43. * Mock implementation of URL state.
  44. *
  45. * @publicApi
  46. */
  47. export declare class MockPlatformLocation implements PlatformLocation {
  48. private baseHref;
  49. private hashUpdate;
  50. private urlChanges;
  51. constructor(config?: MockPlatformLocationConfig);
  52. readonly hostname: string;
  53. readonly protocol: string;
  54. readonly port: string;
  55. readonly pathname: string;
  56. readonly search: string;
  57. readonly hash: string;
  58. readonly state: unknown;
  59. getBaseHrefFromDOM(): string;
  60. onPopState(fn: LocationChangeListener): void;
  61. onHashChange(fn: LocationChangeListener): void;
  62. readonly href: string;
  63. readonly url: string;
  64. private parseChanges;
  65. replaceState(state: any, title: string, newUrl: string): void;
  66. pushState(state: any, title: string, newUrl: string): void;
  67. forward(): void;
  68. back(): void;
  69. getState(): unknown;
  70. }
  71. /**
  72. * Mock platform location config
  73. *
  74. * @publicApi
  75. */
  76. export declare interface MockPlatformLocationConfig {
  77. startUrl?: string;
  78. appBaseHref?: string;
  79. }
  80. /**
  81. * A spy for {@link Location} that allows tests to fire simulated location events.
  82. *
  83. * @publicApi
  84. */
  85. export declare class SpyLocation implements Location {
  86. urlChanges: string[];
  87. private _history;
  88. private _historyIndex;
  89. setInitialPath(url: string): void;
  90. setBaseHref(url: string): void;
  91. path(): string;
  92. getState(): unknown;
  93. isCurrentPathEqualTo(path: string, query?: string): boolean;
  94. simulateUrlPop(pathname: string): void;
  95. simulateHashChange(pathname: string): void;
  96. prepareExternalUrl(url: string): string;
  97. go(path: string, query?: string, state?: any): void;
  98. replaceState(path: string, query?: string, state?: any): void;
  99. forward(): void;
  100. back(): void;
  101. onUrlChange(fn: (url: string, state: unknown) => void): void;
  102. subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike;
  103. normalize(url: string): string;
  104. }
  105. export { }