forked from tbranyen/diffhtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevtools.js
More file actions
66 lines (51 loc) · 1.76 KB
/
Copy pathdevtools.js
File metadata and controls
66 lines (51 loc) · 1.76 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { createRequire } from 'module';
import { ok } from 'assert';
import globalThis from '../lib/util/global';
import validateMemory from './util/validate-memory';
const require = createRequire(import.meta.url);
describe('DevTools', function() {
afterEach(() => validateMemory());
after(async () => {
// Restore global state.
delete global[Symbol.for('diffHTML')];
await import('../lib/index?' + Date.now());
});
it('will not hook into devtools with primary build if devtools are not present', async () => {
delete global[Symbol.for('diffHTML')];
await import('../lib/index?' + Date.now());
delete global[Symbol.for('diffHTML')];
});
it('will not hook into devtools with lite build if devtools are not present', async () => {
delete global[Symbol.for('diffHTML')];
await import('../lib/lite?' + Date.now());
delete global[Symbol.for('diffHTML')];
});
it('will hook into devtools with primary build', async () => {
let hooked = null;
delete global[Symbol.for('diffHTML')];
const middleware = () => {};
globalThis.devTools = Internals => {
hooked = Internals;
return middleware;
};
await import('../lib/index?' + Date.now());
ok(hooked);
delete globalThis.devTools;
delete global[Symbol.for('diffHTML')];
global.unsubscribeDevTools();
});
it('will hook into devtools with lite build', async () => {
let hooked = null;
delete global[Symbol.for('diffHTML')];
const middleware = () => {};
globalThis.devTools = Internals => {
hooked = Internals;
return middleware;
};
await import('../lib/lite?' + Date.now());
ok(hooked);
delete globalThis.devTools;
delete global[Symbol.for('diffHTML')];
global.unsubscribeDevTools();
});
});