-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable testing in Deno environment without dom polyfill pre-def…
…ined
- Loading branch information
Showing
6 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2022-2024 Yoshiya Hinosawa. All rights reserved. MIT license. | ||
|
||
import { DOMParser } from "@b-fuze/deno-dom" | ||
import { assertEquals } from "@std/assert" | ||
import { type Context, mount, register } from "./mod.ts" | ||
|
||
function Component({ el }: Context) { | ||
el.textContent = "a" | ||
} | ||
|
||
Deno.test("register doesn't throw without polyfill", () => { | ||
register(Component, "js-component") | ||
}) | ||
|
||
Deno.test("registered compenent can be mounted", () => { | ||
globalThis.document = new DOMParser().parseFromString( | ||
`<body><div class="js-component"></div></body>`, | ||
"text/html", | ||
// deno-lint-ignore no-explicit-any | ||
) as any | ||
mount() | ||
assertEquals(document.body.firstChild?.textContent, "a") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters