testing.mjs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /**
  2. * @license Angular v20.1.0
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { ɵnormalizeQueryParams as _normalizeQueryParams, LocationStrategy } from '@angular/common';
  7. import * as i0 from '@angular/core';
  8. import { InjectionToken, Injectable, Inject, Optional, inject, DOCUMENT } from '@angular/core';
  9. import { Subject } from 'rxjs';
  10. import { PlatformNavigation } from './platform_navigation.mjs';
  11. import { ɵFakeNavigation as _FakeNavigation } from '@angular/core/testing';
  12. export { ɵFakeNavigation } from '@angular/core/testing';
  13. import { PlatformLocation, Location, LocationStrategy as LocationStrategy$1 } from './location.mjs';
  14. /**
  15. * Parser from https://tools.ietf.org/html/rfc3986#appendix-B
  16. * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
  17. * 12 3 4 5 6 7 8 9
  18. *
  19. * Example: http://www.ics.uci.edu/pub/ietf/uri/#Related
  20. *
  21. * Results in:
  22. *
  23. * $1 = http:
  24. * $2 = http
  25. * $3 = //www.ics.uci.edu
  26. * $4 = www.ics.uci.edu
  27. * $5 = /pub/ietf/uri/
  28. * $6 = <undefined>
  29. * $7 = <undefined>
  30. * $8 = #Related
  31. * $9 = Related
  32. */
  33. const urlParse = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
  34. function parseUrl(urlStr, baseHref) {
  35. const verifyProtocol = /^((http[s]?|ftp):\/\/)/;
  36. let serverBase;
  37. // URL class requires full URL. If the URL string doesn't start with protocol, we need to add
  38. // an arbitrary base URL which can be removed afterward.
  39. if (!verifyProtocol.test(urlStr)) {
  40. serverBase = 'http://empty.com/';
  41. }
  42. let parsedUrl;
  43. try {
  44. parsedUrl = new URL(urlStr, serverBase);
  45. }
  46. catch (e) {
  47. const result = urlParse.exec(serverBase || '' + urlStr);
  48. if (!result) {
  49. throw new Error(`Invalid URL: ${urlStr} with base: ${baseHref}`);
  50. }
  51. const hostSplit = result[4].split(':');
  52. parsedUrl = {
  53. protocol: result[1],
  54. hostname: hostSplit[0],
  55. port: hostSplit[1] || '',
  56. pathname: result[5],
  57. search: result[6],
  58. hash: result[8],
  59. };
  60. }
  61. if (parsedUrl.pathname && parsedUrl.pathname.indexOf(baseHref) === 0) {
  62. parsedUrl.pathname = parsedUrl.pathname.substring(baseHref.length);
  63. }
  64. return {
  65. hostname: (!serverBase && parsedUrl.hostname) || '',
  66. protocol: (!serverBase && parsedUrl.protocol) || '',
  67. port: (!serverBase && parsedUrl.port) || '',
  68. pathname: parsedUrl.pathname || '/',
  69. search: parsedUrl.search || '',
  70. hash: parsedUrl.hash || '',
  71. };
  72. }
  73. /**
  74. * Provider for mock platform location config
  75. *
  76. * @publicApi
  77. */
  78. const MOCK_PLATFORM_LOCATION_CONFIG = new InjectionToken('MOCK_PLATFORM_LOCATION_CONFIG');
  79. /**
  80. * Mock implementation of URL state.
  81. *
  82. * @publicApi
  83. */
  84. class MockPlatformLocation {
  85. baseHref = '';
  86. hashUpdate = new Subject();
  87. popStateSubject = new Subject();
  88. urlChangeIndex = 0;
  89. urlChanges = [{ hostname: '', protocol: '', port: '', pathname: '/', search: '', hash: '', state: null }];
  90. constructor(config) {
  91. if (config) {
  92. this.baseHref = config.appBaseHref || '';
  93. const parsedChanges = this.parseChanges(null, config.startUrl || 'http://_empty_/', this.baseHref);
  94. this.urlChanges[0] = { ...parsedChanges };
  95. }
  96. }
  97. get hostname() {
  98. return this.urlChanges[this.urlChangeIndex].hostname;
  99. }
  100. get protocol() {
  101. return this.urlChanges[this.urlChangeIndex].protocol;
  102. }
  103. get port() {
  104. return this.urlChanges[this.urlChangeIndex].port;
  105. }
  106. get pathname() {
  107. return this.urlChanges[this.urlChangeIndex].pathname;
  108. }
  109. get search() {
  110. return this.urlChanges[this.urlChangeIndex].search;
  111. }
  112. get hash() {
  113. return this.urlChanges[this.urlChangeIndex].hash;
  114. }
  115. get state() {
  116. return this.urlChanges[this.urlChangeIndex].state;
  117. }
  118. getBaseHrefFromDOM() {
  119. return this.baseHref;
  120. }
  121. onPopState(fn) {
  122. const subscription = this.popStateSubject.subscribe(fn);
  123. return () => subscription.unsubscribe();
  124. }
  125. onHashChange(fn) {
  126. const subscription = this.hashUpdate.subscribe(fn);
  127. return () => subscription.unsubscribe();
  128. }
  129. get href() {
  130. let url = `${this.protocol}//${this.hostname}${this.port ? ':' + this.port : ''}`;
  131. url += `${this.pathname === '/' ? '' : this.pathname}${this.search}${this.hash}`;
  132. return url;
  133. }
  134. get url() {
  135. return `${this.pathname}${this.search}${this.hash}`;
  136. }
  137. parseChanges(state, url, baseHref = '') {
  138. // When the `history.state` value is stored, it is always copied.
  139. state = JSON.parse(JSON.stringify(state));
  140. return { ...parseUrl(url, baseHref), state };
  141. }
  142. replaceState(state, title, newUrl) {
  143. const { pathname, search, state: parsedState, hash } = this.parseChanges(state, newUrl);
  144. this.urlChanges[this.urlChangeIndex] = {
  145. ...this.urlChanges[this.urlChangeIndex],
  146. pathname,
  147. search,
  148. hash,
  149. state: parsedState,
  150. };
  151. }
  152. pushState(state, title, newUrl) {
  153. const { pathname, search, state: parsedState, hash } = this.parseChanges(state, newUrl);
  154. if (this.urlChangeIndex > 0) {
  155. this.urlChanges.splice(this.urlChangeIndex + 1);
  156. }
  157. this.urlChanges.push({
  158. ...this.urlChanges[this.urlChangeIndex],
  159. pathname,
  160. search,
  161. hash,
  162. state: parsedState,
  163. });
  164. this.urlChangeIndex = this.urlChanges.length - 1;
  165. }
  166. forward() {
  167. const oldUrl = this.url;
  168. const oldHash = this.hash;
  169. if (this.urlChangeIndex < this.urlChanges.length) {
  170. this.urlChangeIndex++;
  171. }
  172. this.emitEvents(oldHash, oldUrl);
  173. }
  174. back() {
  175. const oldUrl = this.url;
  176. const oldHash = this.hash;
  177. if (this.urlChangeIndex > 0) {
  178. this.urlChangeIndex--;
  179. }
  180. this.emitEvents(oldHash, oldUrl);
  181. }
  182. historyGo(relativePosition = 0) {
  183. const oldUrl = this.url;
  184. const oldHash = this.hash;
  185. const nextPageIndex = this.urlChangeIndex + relativePosition;
  186. if (nextPageIndex >= 0 && nextPageIndex < this.urlChanges.length) {
  187. this.urlChangeIndex = nextPageIndex;
  188. }
  189. this.emitEvents(oldHash, oldUrl);
  190. }
  191. getState() {
  192. return this.state;
  193. }
  194. /**
  195. * Browsers are inconsistent in when they fire events and perform the state updates
  196. * The most easiest thing to do in our mock is synchronous and that happens to match
  197. * Firefox and Chrome, at least somewhat closely
  198. *
  199. * https://github.com/WICG/navigation-api#watching-for-navigations
  200. * https://docs.google.com/document/d/1Pdve-DJ1JCGilj9Yqf5HxRJyBKSel5owgOvUJqTauwU/edit#heading=h.3ye4v71wsz94
  201. * popstate is always sent before hashchange:
  202. * https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent
  203. */
  204. emitEvents(oldHash, oldUrl) {
  205. this.popStateSubject.next({
  206. type: 'popstate',
  207. state: this.getState(),
  208. oldUrl,
  209. newUrl: this.url,
  210. });
  211. if (oldHash !== this.hash) {
  212. this.hashUpdate.next({
  213. type: 'hashchange',
  214. state: null,
  215. oldUrl,
  216. newUrl: this.url,
  217. });
  218. }
  219. }
  220. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: MockPlatformLocation, deps: [{ token: MOCK_PLATFORM_LOCATION_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
  221. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: MockPlatformLocation });
  222. }
  223. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: MockPlatformLocation, decorators: [{
  224. type: Injectable
  225. }], ctorParameters: () => [{ type: undefined, decorators: [{
  226. type: Inject,
  227. args: [MOCK_PLATFORM_LOCATION_CONFIG]
  228. }, {
  229. type: Optional
  230. }] }] });
  231. /**
  232. * Mock implementation of URL state.
  233. */
  234. class FakeNavigationPlatformLocation {
  235. _platformNavigation;
  236. constructor() {
  237. const platformNavigation = inject(PlatformNavigation);
  238. if (!(platformNavigation instanceof _FakeNavigation)) {
  239. throw new Error('FakePlatformNavigation cannot be used without FakeNavigation. Use ' +
  240. '`provideFakeNavigation` to have all these services provided together.');
  241. }
  242. this._platformNavigation = platformNavigation;
  243. }
  244. config = inject(MOCK_PLATFORM_LOCATION_CONFIG, { optional: true });
  245. getBaseHrefFromDOM() {
  246. return this.config?.appBaseHref ?? '';
  247. }
  248. onPopState(fn) {
  249. this._platformNavigation.window.addEventListener('popstate', fn);
  250. return () => this._platformNavigation.window.removeEventListener('popstate', fn);
  251. }
  252. onHashChange(fn) {
  253. this._platformNavigation.window.addEventListener('hashchange', fn);
  254. return () => this._platformNavigation.window.removeEventListener('hashchange', fn);
  255. }
  256. get href() {
  257. return this._platformNavigation.currentEntry.url;
  258. }
  259. get protocol() {
  260. return new URL(this._platformNavigation.currentEntry.url).protocol;
  261. }
  262. get hostname() {
  263. return new URL(this._platformNavigation.currentEntry.url).hostname;
  264. }
  265. get port() {
  266. return new URL(this._platformNavigation.currentEntry.url).port;
  267. }
  268. get pathname() {
  269. return new URL(this._platformNavigation.currentEntry.url).pathname;
  270. }
  271. get search() {
  272. return new URL(this._platformNavigation.currentEntry.url).search;
  273. }
  274. get hash() {
  275. return new URL(this._platformNavigation.currentEntry.url).hash;
  276. }
  277. pushState(state, title, url) {
  278. this._platformNavigation.pushState(state, title, url);
  279. }
  280. replaceState(state, title, url) {
  281. this._platformNavigation.replaceState(state, title, url);
  282. }
  283. forward() {
  284. this._platformNavigation.forward();
  285. }
  286. back() {
  287. this._platformNavigation.back();
  288. }
  289. historyGo(relativePosition = 0) {
  290. this._platformNavigation.go(relativePosition);
  291. }
  292. getState() {
  293. return this._platformNavigation.currentEntry.getHistoryState();
  294. }
  295. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FakeNavigationPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
  296. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FakeNavigationPlatformLocation });
  297. }
  298. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FakeNavigationPlatformLocation, decorators: [{
  299. type: Injectable
  300. }], ctorParameters: () => [] });
  301. const FAKE_NAVIGATION = new InjectionToken('fakeNavigation', {
  302. providedIn: 'root',
  303. factory: () => {
  304. const config = inject(MOCK_PLATFORM_LOCATION_CONFIG, { optional: true });
  305. const baseFallback = 'http://_empty_/';
  306. const startUrl = new URL(config?.startUrl || baseFallback, baseFallback);
  307. const fakeNavigation = new _FakeNavigation(inject(DOCUMENT), startUrl.href);
  308. fakeNavigation.setSynchronousTraversalsForTesting(true);
  309. return fakeNavigation;
  310. },
  311. });
  312. /**
  313. * Return a provider for the `FakeNavigation` in place of the real Navigation API.
  314. */
  315. function provideFakePlatformNavigation() {
  316. return [
  317. {
  318. provide: PlatformNavigation,
  319. useFactory: () => inject(FAKE_NAVIGATION),
  320. },
  321. { provide: PlatformLocation, useClass: FakeNavigationPlatformLocation },
  322. ];
  323. }
  324. /**
  325. * A spy for {@link Location} that allows tests to fire simulated location events.
  326. *
  327. * @publicApi
  328. */
  329. class SpyLocation {
  330. urlChanges = [];
  331. _history = [new LocationState('', '', null)];
  332. _historyIndex = 0;
  333. /** @internal */
  334. _subject = new Subject();
  335. /** @internal */
  336. _basePath = '';
  337. /** @internal */
  338. _locationStrategy = null;
  339. /** @internal */
  340. _urlChangeListeners = [];
  341. /** @internal */
  342. _urlChangeSubscription = null;
  343. /** @docs-private */
  344. ngOnDestroy() {
  345. this._urlChangeSubscription?.unsubscribe();
  346. this._urlChangeListeners = [];
  347. }
  348. setInitialPath(url) {
  349. this._history[this._historyIndex].path = url;
  350. }
  351. setBaseHref(url) {
  352. this._basePath = url;
  353. }
  354. path() {
  355. return this._history[this._historyIndex].path;
  356. }
  357. getState() {
  358. return this._history[this._historyIndex].state;
  359. }
  360. isCurrentPathEqualTo(path, query = '') {
  361. const givenPath = path.endsWith('/') ? path.substring(0, path.length - 1) : path;
  362. const currPath = this.path().endsWith('/')
  363. ? this.path().substring(0, this.path().length - 1)
  364. : this.path();
  365. return currPath == givenPath + (query.length > 0 ? '?' + query : '');
  366. }
  367. simulateUrlPop(pathname) {
  368. this._subject.next({ 'url': pathname, 'pop': true, 'type': 'popstate' });
  369. }
  370. simulateHashChange(pathname) {
  371. const path = this.prepareExternalUrl(pathname);
  372. this.pushHistory(path, '', null);
  373. this.urlChanges.push('hash: ' + pathname);
  374. // the browser will automatically fire popstate event before each `hashchange` event, so we need
  375. // to simulate it.
  376. this._subject.next({ 'url': pathname, 'pop': true, 'type': 'popstate' });
  377. this._subject.next({ 'url': pathname, 'pop': true, 'type': 'hashchange' });
  378. }
  379. prepareExternalUrl(url) {
  380. if (url.length > 0 && !url.startsWith('/')) {
  381. url = '/' + url;
  382. }
  383. return this._basePath + url;
  384. }
  385. go(path, query = '', state = null) {
  386. path = this.prepareExternalUrl(path);
  387. this.pushHistory(path, query, state);
  388. const locationState = this._history[this._historyIndex - 1];
  389. if (locationState.path == path && locationState.query == query) {
  390. return;
  391. }
  392. const url = path + (query.length > 0 ? '?' + query : '');
  393. this.urlChanges.push(url);
  394. this._notifyUrlChangeListeners(path + _normalizeQueryParams(query), state);
  395. }
  396. replaceState(path, query = '', state = null) {
  397. path = this.prepareExternalUrl(path);
  398. const history = this._history[this._historyIndex];
  399. history.state = state;
  400. if (history.path == path && history.query == query) {
  401. return;
  402. }
  403. history.path = path;
  404. history.query = query;
  405. const url = path + (query.length > 0 ? '?' + query : '');
  406. this.urlChanges.push('replace: ' + url);
  407. this._notifyUrlChangeListeners(path + _normalizeQueryParams(query), state);
  408. }
  409. forward() {
  410. if (this._historyIndex < this._history.length - 1) {
  411. this._historyIndex++;
  412. this._subject.next({
  413. 'url': this.path(),
  414. 'state': this.getState(),
  415. 'pop': true,
  416. 'type': 'popstate',
  417. });
  418. }
  419. }
  420. back() {
  421. if (this._historyIndex > 0) {
  422. this._historyIndex--;
  423. this._subject.next({
  424. 'url': this.path(),
  425. 'state': this.getState(),
  426. 'pop': true,
  427. 'type': 'popstate',
  428. });
  429. }
  430. }
  431. historyGo(relativePosition = 0) {
  432. const nextPageIndex = this._historyIndex + relativePosition;
  433. if (nextPageIndex >= 0 && nextPageIndex < this._history.length) {
  434. this._historyIndex = nextPageIndex;
  435. this._subject.next({
  436. 'url': this.path(),
  437. 'state': this.getState(),
  438. 'pop': true,
  439. 'type': 'popstate',
  440. });
  441. }
  442. }
  443. onUrlChange(fn) {
  444. this._urlChangeListeners.push(fn);
  445. this._urlChangeSubscription ??= this.subscribe((v) => {
  446. this._notifyUrlChangeListeners(v.url, v.state);
  447. });
  448. return () => {
  449. const fnIndex = this._urlChangeListeners.indexOf(fn);
  450. this._urlChangeListeners.splice(fnIndex, 1);
  451. if (this._urlChangeListeners.length === 0) {
  452. this._urlChangeSubscription?.unsubscribe();
  453. this._urlChangeSubscription = null;
  454. }
  455. };
  456. }
  457. /** @internal */
  458. _notifyUrlChangeListeners(url = '', state) {
  459. this._urlChangeListeners.forEach((fn) => fn(url, state));
  460. }
  461. subscribe(onNext, onThrow, onReturn) {
  462. return this._subject.subscribe({
  463. next: onNext,
  464. error: onThrow ?? undefined,
  465. complete: onReturn ?? undefined,
  466. });
  467. }
  468. normalize(url) {
  469. return null;
  470. }
  471. pushHistory(path, query, state) {
  472. if (this._historyIndex > 0) {
  473. this._history.splice(this._historyIndex + 1);
  474. }
  475. this._history.push(new LocationState(path, query, state));
  476. this._historyIndex = this._history.length - 1;
  477. }
  478. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SpyLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
  479. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SpyLocation });
  480. }
  481. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SpyLocation, decorators: [{
  482. type: Injectable
  483. }] });
  484. class LocationState {
  485. path;
  486. query;
  487. state;
  488. constructor(path, query, state) {
  489. this.path = path;
  490. this.query = query;
  491. this.state = state;
  492. }
  493. }
  494. /**
  495. * A mock implementation of {@link LocationStrategy} that allows tests to fire simulated
  496. * location events.
  497. *
  498. * @publicApi
  499. */
  500. class MockLocationStrategy extends LocationStrategy {
  501. internalBaseHref = '/';
  502. internalPath = '/';
  503. internalTitle = '';
  504. urlChanges = [];
  505. /** @internal */
  506. _subject = new Subject();
  507. stateChanges = [];
  508. constructor() {
  509. super();
  510. }
  511. simulatePopState(url) {
  512. this.internalPath = url;
  513. this._subject.next(new _MockPopStateEvent(this.path()));
  514. }
  515. path(includeHash = false) {
  516. return this.internalPath;
  517. }
  518. prepareExternalUrl(internal) {
  519. if (internal.startsWith('/') && this.internalBaseHref.endsWith('/')) {
  520. return this.internalBaseHref + internal.substring(1);
  521. }
  522. return this.internalBaseHref + internal;
  523. }
  524. pushState(ctx, title, path, query) {
  525. // Add state change to changes array
  526. this.stateChanges.push(ctx);
  527. this.internalTitle = title;
  528. const url = path + (query.length > 0 ? '?' + query : '');
  529. this.internalPath = url;
  530. const externalUrl = this.prepareExternalUrl(url);
  531. this.urlChanges.push(externalUrl);
  532. }
  533. replaceState(ctx, title, path, query) {
  534. // Reset the last index of stateChanges to the ctx (state) object
  535. this.stateChanges[(this.stateChanges.length || 1) - 1] = ctx;
  536. this.internalTitle = title;
  537. const url = path + (query.length > 0 ? '?' + query : '');
  538. this.internalPath = url;
  539. const externalUrl = this.prepareExternalUrl(url);
  540. this.urlChanges.push('replace: ' + externalUrl);
  541. }
  542. onPopState(fn) {
  543. this._subject.subscribe({ next: fn });
  544. }
  545. getBaseHref() {
  546. return this.internalBaseHref;
  547. }
  548. back() {
  549. if (this.urlChanges.length > 0) {
  550. this.urlChanges.pop();
  551. this.stateChanges.pop();
  552. const nextUrl = this.urlChanges.length > 0 ? this.urlChanges[this.urlChanges.length - 1] : '';
  553. this.simulatePopState(nextUrl);
  554. }
  555. }
  556. forward() {
  557. throw 'not implemented';
  558. }
  559. getState() {
  560. return this.stateChanges[(this.stateChanges.length || 1) - 1];
  561. }
  562. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: MockLocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
  563. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: MockLocationStrategy });
  564. }
  565. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: MockLocationStrategy, decorators: [{
  566. type: Injectable
  567. }], ctorParameters: () => [] });
  568. class _MockPopStateEvent {
  569. newUrl;
  570. pop = true;
  571. type = 'popstate';
  572. constructor(newUrl) {
  573. this.newUrl = newUrl;
  574. }
  575. }
  576. /**
  577. * Returns mock providers for the `Location` and `LocationStrategy` classes.
  578. * The mocks are helpful in tests to fire simulated location events.
  579. *
  580. * @publicApi
  581. */
  582. function provideLocationMocks() {
  583. return [
  584. { provide: Location, useClass: SpyLocation },
  585. { provide: LocationStrategy$1, useClass: MockLocationStrategy },
  586. ];
  587. }
  588. export { MOCK_PLATFORM_LOCATION_CONFIG, MockLocationStrategy, MockPlatformLocation, SpyLocation, provideLocationMocks, provideFakePlatformNavigation as ɵprovideFakePlatformNavigation };
  589. //# sourceMappingURL=testing.mjs.map