angular/packages/platform-server/init/test/shims_spec.ts
Joey Perrott 349133374f build: update repository to use node 22.21.1 in bazel
The repository was updated to use node 22.21.1 via nvm, but bazel had not been updated to match
2025-12-09 09:19:13 -08:00

43 lines
1.2 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 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 (['navigator', 'crypto'].includes(prop)) {
// These props are just a getter and cannot be changed
continue;
}
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);
});
});