angular/packages/platform-browser/test/browser/tools/tools_spec.ts
Paul Gschwendtner 3a106a35bc build: move private testing helpers outside platform-browser/testing (#61472)
These helpers are often imported by various tests throughout the
repository, but the helpers aren't exported/exposed from the public
entry-point; even though they confusingly reside in there.

This commit fixes this, and moves the helpers into
`packages/private/testing`. This is a preparation for the `ts_project`
migration where we don't want to leverage deep imports between packages.

PR Close #61472
2025-05-20 10:00:43 +00:00

57 lines
1.5 KiB
TypeScript

/**
* @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
*/
import {ApplicationRef, Injector, ɵglobal as global} from '@angular/core';
import {ComponentRef} from '@angular/core/src/render3';
import {isNode} from '@angular/private/testing';
import {disableDebugTools, enableDebugTools} from '../../../index';
import {AngularProfiler} from '../../../src/browser/tools/common_tools';
describe('profiler', () => {
if (isNode) {
// Jasmine will throw if there are no tests.
it('should pass', () => {});
return;
}
beforeEach(() => {
enableDebugTools({
injector: Injector.create({
providers: [
{
provide: ApplicationRef,
useValue: jasmine.createSpyObj('ApplicationRef', [
'bootstrap',
'tick',
'attachView',
'detachView',
]),
deps: [],
},
],
}) as Injector,
} as ComponentRef<any>);
});
afterEach(() => {
disableDebugTools();
});
it('should time change detection', () => {
callNgProfilerTimeChangeDetection();
});
it('should time change detection with recording', () => {
callNgProfilerTimeChangeDetection({'record': true});
});
});
export function callNgProfilerTimeChangeDetection(config?: {record: true}): void {
(global.ng.profiler as AngularProfiler).timeChangeDetection(config);
}