Skip to content

Commit 1d65abe

Browse files
fix js test
1 parent 4ec17cf commit 1d65abe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/js/unicorn/init.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
import test from "ava";
2+
import { JSDOM } from "jsdom";
23
import { init } from "../../../src/django_unicorn/static/unicorn/js/unicorn.js";
4+
import { components } from "../../../src/django_unicorn/static/unicorn/js/store.js";
5+
6+
test.beforeEach(() => {
7+
const dom = new JSDOM("<!doctype html><html><body></body></html>");
8+
global.document = dom.window.document;
9+
global.window = dom.window;
10+
global.MutationObserver = dom.window.MutationObserver;
11+
global.Node = dom.window.Node;
12+
global.NodeFilter = dom.window.NodeFilter;
13+
14+
for (const key in components) {
15+
delete components[key];
16+
}
17+
});
18+
19+
test.afterEach(() => {
20+
delete global.document;
21+
delete global.window;
22+
delete global.MutationObserver;
23+
delete global.Node;
24+
delete global.NodeFilter;
25+
});
326

427
test("init unicorn", (t) => {
528
const actual = init("unicorn/", "X-Unicorn", "unicorn", { NAME: "morphdom" });

0 commit comments

Comments
 (0)