Icard/angular-clarity-master(work.../node_modules/@angular/common/fesm2022/testing.mjs.map

1 line
38 KiB
Plaintext
Raw Normal View History

2024-07-16 14:55:36 +00:00
{"version":3,"file":"testing.mjs","sources":["../../../../../../packages/common/src/location/util.ts","../../../../../../packages/common/testing/src/location_mock.ts","../../../../../../packages/common/testing/src/mock_location_strategy.ts","../../../../../../packages/common/testing/src/mock_platform_location.ts","../../../../../../packages/common/testing/src/provide_location_mocks.ts","../../../../../../packages/common/testing/src/testing.ts","../../../../../../packages/common/testing/public_api.ts","../../../../../../packages/common/testing/index.ts","../../../../../../packages/common/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n\n/**\n * Joins two parts of a URL with a slash if needed.\n *\n * @param start URL string\n * @param end URL string\n *\n *\n * @returns The joined URL string.\n */\nexport function joinWithSlash(start: string, end: string): string {\n if (start.length == 0) {\n return end;\n }\n if (end.length == 0) {\n return start;\n }\n let slashes = 0;\n if (start.endsWith('/')) {\n slashes++;\n }\n if (end.startsWith('/')) {\n slashes++;\n }\n if (slashes == 2) {\n return start + end.substring(1);\n }\n if (slashes == 1) {\n return start + end;\n }\n return start + '/' + end;\n}\n\n/**\n * Removes a trailing slash from a URL string if needed.\n * Looks for the first occurrence of either `#`, `?`, or the end of the\n * line as `/` characters and removes the trailing slash if one exists.\n *\n * @param url URL string.\n *\n * @returns The URL string, modified if needed.\n */\nexport function stripTrailingSlash(url: string): string {\n const match = url.match(/#|\\?|$/);\n const pathEndIdx = match && match.index || url.length;\n const droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);\n return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);\n}\n\n/**\n * Normalizes URL parameters by prepending with `?` if needed.\n *\n * @param params String of URL parameters.\n *\n * @returns The normalized URL parameters string.\n */\nexport function normalizeQueryParams(params: string): string {\n return params && params[0] !== '?' ? '?' + params : params;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Location, LocationStrategy} from '@angular/common';\nimport {EventEmitter, Injectable} from '@angular/core';\nimport {SubscriptionLike} from 'rxjs';\n\nimport {normalizeQueryParams} from '../../src/location/util';\n\n/**\n * A spy for {@link Location} that allows tests to fire simulated location events.\n *\n * @publicApi\n */\n@Injectable()\nexport class SpyLocation implements Location {\n urlChanges: string[] = [];\n private _history: LocationState[] = [new LocationState('', '', null)];\n private _historyIndex: number = 0;\n /** @internal */\n _subject: EventEmitter<any> = new EventEmitter();\n /** @internal */\n _basePath: string = '';\n /** @internal */\n _locationStrategy: LocationStrategy = null!;\n /** @internal */\n _urlChangeListeners: ((url: string, state: unknown) => void)[] = [];\n /** @internal */\n _urlChangeSubscription: SubscriptionLike|null = null;\n\n /** @nodoc */\n ngOnDestroy(): void {\n this._urlChangeSubscription?.unsubscribe();\n this._urlChangeListeners = [];\n }\n\n setInitialPath(url: string) {\n this._history[this._historyIndex].path = url;\n }\n\n setBaseHref(url: string) {\n this._basePath = url;\n }\n\n path(): string {\n return this._history[this._historyIndex].path;\n }\n\n getState(): unknown {\n return this._history[this._historyIndex].state;\n }\n\n isCurrentPathEqualTo(path: string, query: string = ''): boolean {\n const givenPath = path.endsWith('/') ? path.substring(0, path.length - 1) : path;\