angular/packages/platform-browser/test/browser/tools/tools_spec.ts
Joey Perrott 9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00

56 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 {disableDebugTools, enableDebugTools} from '@angular/platform-browser';
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 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);
}