aboutsummaryrefslogtreecommitdiff
path: root/test/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils.js')
-rw-r--r--test/utils.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/utils.js b/test/utils.js
new file mode 100644
index 0000000..c3abaee
--- /dev/null
+++ b/test/utils.js
@@ -0,0 +1,29 @@
+import { parseHTML } from 'linkedom';
+import { vi } from 'vitest';
+
+// Parse the starting state of the basic starting template
+export function setupDOM() {
+ const result = parseHTML(`
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+
+ <title>🚧 {app_name}</title>
+
+ </head>
+
+ <body>
+ <div id="app"></div>
+ </body>
+</html>`);
+
+ global.HTMLElement = result.HTMLElement;
+ global.Node = result.Node;
+ global.document = result.document;
+ global.window = result.window;
+ global.window.requestAnimationFrame = vi.fn().mockImplementation((cb) => cb());
+
+ return result;
+} \ No newline at end of file