From 80e2bd66f54bca88a749d40784828d29bae8995f Mon Sep 17 00:00:00 2001 From: Jacob Scearcy Date: Mon, 6 May 2024 06:42:35 -0700 Subject: =?UTF-8?q?=F0=9F=94=80=20Use=20vitest=20for=20runtime/vdom=20test?= =?UTF-8?q?ing.=20(#124)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🧪 move tests into test directory, bump birdie to ignore non-gleam files * implement feedback * add comments, update doc --- test/utils.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/utils.js (limited to 'test/utils.js') 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(` + + + + + + + 🚧 {app_name} + + + + +
+ +`); + + 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 -- cgit v1.2.3