mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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
57 lines
1.5 KiB
TypeScript
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);
|
|
}
|