Skip to content

Commit

Permalink
fixup! refactor(core): Add fake navigation to primitives for code sha…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
atscott committed Feb 14, 2025
1 parent e97ed03 commit 5ce8c36
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 25 deletions.
25 changes: 12 additions & 13 deletions packages/common/src/navigation/platform_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {Injectable} from '@angular/core';

import {
NavigateEvent,
Navigation,
NavigationCurrentEntryChangeEvent,
NavigationHistoryEntry,
NavigationNavigateOptions,
NavigationOptions,
NavigationReloadOptions,
NavigationResult,
NavigationTransition,
NavigationUpdateCurrentEntryOptions,
} from '@angular/core/primitives/dom-navigation';
Injectable,
ɵNavigateEvent as NavigateEvent,
ɵNavigation as Navigation,
ɵNavigationCurrentEntryChangeEvent as NavigationCurrentEntryChangeEvent,
ɵNavigationHistoryEntry as NavigationHistoryEntry,
ɵNavigationNavigateOptions as NavigationNavigateOptions,
ɵNavigationOptions as NavigationOptions,
ɵNavigationReloadOptions as NavigationReloadOptions,
ɵNavigationResult as NavigationResult,
ɵNavigationTransition as NavigationTransition,
ɵNavigationUpdateCurrentEntryOptions as NavigationUpdateCurrentEntryOptions,
} from '@angular/core';

/**
* This class wraps the platform Navigation API which allows server-specific and test
Expand Down
2 changes: 1 addition & 1 deletion packages/common/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ng_module(
deps = [
"//packages/common",
"//packages/core",
"//packages/core/primitives/dom-navigation/testing",
"//packages/core/testing",
"@npm//rxjs",
],
)
Expand Down
2 changes: 1 addition & 1 deletion packages/common/testing/src/mock_platform_location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import {Inject, inject, Injectable, InjectionToken, Optional} from '@angular/core';
import {Subject} from 'rxjs';

import {FakeNavigation} from '@angular/core/primitives/dom-navigation/testing';
import {FakeNavigation} from './navigation/fake_navigation';

/**
* Parser from https://tools.ietf.org/html/rfc3986#appendix-B
Expand Down
9 changes: 9 additions & 0 deletions packages/common/testing/src/navigation/fake_navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/

export {ɵFakeNavigation as FakeNavigation} from '@angular/core/testing';
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
MOCK_PLATFORM_LOCATION_CONFIG,
} from '../mock_platform_location';

import {FakeNavigation} from '@angular/core/primitives/dom-navigation/testing';
import {FakeNavigation} from './fake_navigation';

/**
* Return a provider for the `FakeNavigation` in place of the real Navigation API.
Expand Down
2 changes: 1 addition & 1 deletion packages/common/testing/src/private_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/

export {provideFakePlatformNavigation as ɵprovideFakePlatformNavigation} from './navigation/provide_fake_platform_navigation';
export {FakeNavigation as ɵFakeNavigation} from '@angular/core/primitives/dom-navigation/testing';
export {FakeNavigation as ɵFakeNavigation} from './navigation/fake_navigation';
1 change: 1 addition & 0 deletions packages/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ng_module(
),
deps = [
"//packages:types",
"//packages/core/primitives/dom-navigation",
"//packages/core/primitives/event-dispatch",
"//packages/core/primitives/signals",
"//packages/core/src/compiler",
Expand Down
7 changes: 3 additions & 4 deletions packages/core/primitives/dom-navigation/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
load("//tools:defaults.bzl", "ng_module", "tsec_test")
load("//tools:defaults.bzl", "ts_library", "tsec_test")

package(default_visibility = [
"//packages:__pkg__",
"//packages/common:__subpackages__",
"//packages/core/primitives/dom-navigation:__subpackages__",
"//packages/core:__subpackages__",
"//tools/public_api_guard:__pkg__",
])

ng_module(
ts_library(
name = "dom-navigation",
package_name = "@angular/core/primitives/dom-navigation",
srcs = glob(
[
"*.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/primitives/dom-navigation/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
load("//tools:defaults.bzl", "ng_module", "tsec_test")
load("//tools:defaults.bzl", "ts_library", "tsec_test")

package(default_visibility = [
"//packages:__pkg__",
"//packages/common:__subpackages__",
"//packages/core/primitives/dom-navigation/testing:__subpackages__",
"//packages/core/testing:__subpackages__",
"//tools/public_api_guard:__pkg__",
])

ng_module(
ts_library(
name = "testing",
package_name = "@angular/core/primitives/dom-navigation/testing",
srcs = glob(
[
"**/*.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
NavigationInterceptOptions,
NavigationDestination,
Navigation,
} from '@angular/core/primitives/dom-navigation';
} from '../src/navigation_types';

/**
* Fake implementation of user agent history and navigation behavior. This is a
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/core_private_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
* found in the LICENSE file at https://angular.dev/license
*/

export {
type NavigateEvent as ɵNavigateEvent,
type Navigation as ɵNavigation,
type NavigationCurrentEntryChangeEvent as ɵNavigationCurrentEntryChangeEvent,
type NavigationHistoryEntry as ɵNavigationHistoryEntry,
type NavigationNavigateOptions as ɵNavigationNavigateOptions,
type NavigationOptions as ɵNavigationOptions,
type NavigationReloadOptions as ɵNavigationReloadOptions,
type NavigationResult as ɵNavigationResult,
type NavigationTransition as ɵNavigationTransition,
type NavigationUpdateCurrentEntryOptions as ɵNavigationUpdateCurrentEntryOptions,
type NavigationTypeString as ɵNavigationTypeString,
type NavigationInterceptOptions as ɵNavigationInterceptOptions,
type NavigationDestination as ɵNavigationDestination,
} from '../primitives/dom-navigation';
export {setAlternateWeakRefImpl as ɵsetAlternateWeakRefImpl} from '../primitives/signals';
export {detectChangesInViewIfRequired as ɵdetectChangesInViewIfRequired} from './application/application_ref';
export {INTERNAL_APPLICATION_ERROR_HANDLER as ɵINTERNAL_APPLICATION_ERROR_HANDLER} from './error_handler';
Expand Down
1 change: 1 addition & 0 deletions packages/core/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ng_module(
"//packages:types",
"//packages/compiler",
"//packages/core",
"//packages/core/primitives/dom-navigation/testing",
"//packages/localize",
"//packages/zone.js/lib:zone_d_ts",
"@npm//@types/jasmine",
Expand Down
1 change: 1 addition & 0 deletions packages/core/testing/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
* Entry point for all public APIs of this package.
*/
export * from './src/testing';
export * from './src/testing_private_export';

// This file only reexports content of the `src` folder. Keep it that way.
9 changes: 9 additions & 0 deletions packages/core/testing/src/testing_private_export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/

export {FakeNavigation as ɵFakeNavigation} from '../../primitives/dom-navigation/testing';

0 comments on commit 5ce8c36

Please sign in to comment.