angular/packages/platform-server/init/test/shims_spec.ts
Alan Agius 6b112cc621 refactor(platform-server): remove dependency between @angular/platform-server and @angular/platform-server/init (#52342)
Previously, the cross entry-point dependency was created to share the `setDomTypes` function. This however, causes extra transformations "linking" during the application build since other Angular code in `@angular/platform-server` is pulled in.

With this commit we remove the cross dependency and thus remove the need for extra transformations in the server polyfill bundle with the result of having a slightly faster build.

See: https://github.com/angular/angular-cli/pull/26113

PR Close #52342
2023-10-24 09:26:50 -07:00

39 lines
1.1 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.io/license
*/
import domino from '../src/bundled-domino';
import {applyShims} from '../src/shims';
describe('applyShims()', () => {
const globalClone = {...global};
afterEach(() => {
// Un-patch `global`.
const currentProps = Object.keys(global);
for (const prop of currentProps) {
if (globalClone.hasOwnProperty(prop)) {
(global as any)[prop] = (globalClone as any)[prop];
} else {
delete (global as any)[prop];
}
}
});
it('should load `domino.impl` onto `global`', () => {
expect(global).not.toEqual(jasmine.objectContaining(domino.impl));
applyShims();
expect(global).toEqual(jasmine.objectContaining(domino.impl));
});
it('should define `KeyboardEvent` on `global`', () => {
expect((global as any).KeyboardEvent).not.toBe((domino.impl as any).Event);
applyShims();
expect((global as any).KeyboardEvent).toBe((domino.impl as any).Event);
});
});