mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-10-22 19:56:18 +00:00
Globals were only set where Node had none, and Node defines Event and CustomEvent itself. Code running in the browser env therefore built Node events, which a JSDOM node refuses: react-tooltip's window.dispatchEvent(new CustomEvent(...)) threw "parameter 1 is not of type 'Event'". In the browser env these two now come from JSDOM, as they do under jest-environment-jsdom.
32 lines
914 B
TypeScript
32 lines
914 B
TypeScript
// Copyright 2017-2026 @pezkuwi/dev-test authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { browser } from './browser.js';
|
|
|
|
const all = browser();
|
|
|
|
describe('browser', () => {
|
|
it('contains window', () => {
|
|
expect(all.window).toBeDefined();
|
|
});
|
|
|
|
it('contains a crypto implementation', () => {
|
|
expect(all.crypto).toBeTruthy();
|
|
expect(typeof all.crypto.getRandomValues).toBe('function');
|
|
});
|
|
|
|
it('contains the top-level objects', () => {
|
|
expect(all.document).toBeDefined();
|
|
expect(all.navigator).toBeDefined();
|
|
});
|
|
|
|
it('contains HTML*Element', () => {
|
|
expect(typeof all.HTMLElement).toBe('function');
|
|
});
|
|
|
|
it('dispatches the global CustomEvent and Event on window', () => {
|
|
expect(() => window.dispatchEvent(new CustomEvent('custom', { detail: 1 }))).not.toThrow();
|
|
expect(() => window.dispatchEvent(new Event('plain'))).not.toThrow();
|
|
});
|
|
});
|