testing.mjs 21 KB

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