8000 refactor(platform-browser): prepare the code to use `MockPlatformLoca… · angular/angular@579cbb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 579cbb2

Browse files
AndrewKushniralxhub
authored andcommitted
refactor(platform-browser): prepare the code to use MockPlatformLocation by default (#48651)
This commit prepares the code of the `BrowserTestingModule` to include the `MockPlatformLocation` by deafult in the future. With this change, the set of providers to add the `MockPlatformLocation` would be disabled by a flag, which will be switched in v16. PR Close #48651
1 parent 0510f4e commit 579cbb2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

packages/platform-browser/testing/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ng_module(
88
name = "testing",
99
srcs = glob(["**/*.ts"]),
1010
deps = [
11+
"//packages/common/testing",
1112
"//packages/core",
1213
"//packages/core/testing",
1314
"//packages/platform-browser",

packages/platform-browser/testing/src/browser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
import {PlatformLocation} from '@angular/common';
9+
import {MockPlatformLocation} from '@angular/common/testing';
810
import {APP_ID, createPlatformFactory, NgModule, NgZone, PLATFORM_INITIALIZER, platformCore, StaticProvider} from '@angular/core';
911
import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter} from '@angular/platform-browser';
1012

1113
import {BrowserDetection, createNgZone} from './browser_util';
14+
import {ENABLE_MOCK_PLATFORM_LOCATION} from './mock_platform_location_flag';
1215

1316
function initBrowserTests() {
1417
BrowserDomAdapter.makeCurrent();
@@ -36,6 +39,8 @@ export const platformBrowserTesting =
3639
providers: [
3740
{provide: APP_ID, useValue: 'a'},
3841
{provide: NgZone, useFactory: createNgZone},
42+
(ENABLE_MOCK_PLATFORM_LOCATION ? [{provide: PlatformLocation, useClass: MockPlatformLocation}] :
43+
[]),
3944
]
4045
})
4146
export class BrowserTestingModule {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
/**
10+
* Controls whether the `MockPlatformLocation` class should be used
11+
* as the `PlatformLocation` implementation when the `BrowserTestingModule`
12+
* is imported.
13+
*
14+
* In v16, the value of this flag will be switched to `true` to enable
15+
* the `MockPlatformLocation` by default.
16+
*/
17+
export const ENABLE_MOCK_PLATFORM_LOCATION = false;

0 commit comments

Comments
 (0)
0