-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsupports.test.ts
32 lines (27 loc) · 954 Bytes
/
supports.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { afterEach } from 'node:test';
import { supportsHistory } from '../../src/utils-hoist/supports';
import { describe, it, expect } from 'vitest';
describe('supportsHistory', () => {
const originalHistory = globalThis.history;
afterEach(() => {
globalThis.history = originalHistory;
});
it('returns true if history is available', () => {
// @ts-expect-error - not setting all history properties
globalThis.history = {
pushState: () => {},
replaceState: () => {},
};
expect(supportsHistory()).toBe(true);
});
it('returns false if history is not available', () => {
// @ts-expect-error - deletion is okay in this case
delete globalThis.history;
expect(supportsHistory()).toBe(false);
});
it('returns false if history is undefined', () => {
// @ts-expect-error - undefined is okay in this case
globalThis.history = undefined;
expect(supportsHistory()).toBe(false);
});
});