-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5a65c5
commit 3eef60a
Showing
7 changed files
with
70 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 |
---|---|---|
@@ -1 +1,35 @@ | ||
await import("@mizu/internal/testing").then(({ test }) => test(import.meta)) | ||
import { expect, fn, test, type testing } from "@libs/testing" | ||
import { Window } from "@mizu/internal/vdom" | ||
import { type Directive, Phase, Renderer } from "@mizu/internal/engine" | ||
import directive from "./mod.ts" | ||
|
||
test()("[@event] supports `_event` internal api", async () => { | ||
await using window = new Window() | ||
const tested = { | ||
name: "~tested", | ||
phase: Phase.TESTING, | ||
init: directive.init, | ||
execute: (renderer, element, options) => directive.execute(renderer, element, { ...options, _event: "testing" } as testing), | ||
} as Directive | ||
const renderer = await new Renderer(window, { directives: [tested] }).ready | ||
const element = Object.assign(renderer.createElement("div", { attributes: { [`${tested.name}`]: "" } }), { addEventListener: fn() }) | ||
await renderer.render(element) | ||
expect(element.addEventListener).toHaveBeenCalledWith("testing", expect.any(Function), expect.any(Object)) | ||
}) | ||
|
||
test()("[@event] supports `_callback` internal api", async () => { | ||
await using window = new Window() | ||
const callback = fn() | ||
const tested = { | ||
name: "~tested", | ||
phase: Phase.TESTING, | ||
init: directive.init, | ||
execute: (renderer, element, options) => directive.execute(renderer, element, { ...options, _event: "testing", _callback: callback } as testing), | ||
} as Directive | ||
const renderer = await new Renderer(window, { directives: [tested] }).ready | ||
const element = renderer.createElement("div", { attributes: { [`${tested.name}`]: "" } }) | ||
await renderer.render(element) | ||
element.dispatchEvent(new renderer.window.Event("testing")) | ||
expect(callback).toHaveBeenCalled() | ||
}) |
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 |
---|---|---|
@@ -1 +1,14 @@ | ||
import "./mod.ts" | ||
import { expect, test, type testing } from "@libs/testing" | ||
import { Window } from "@mizu/internal/vdom" | ||
|
||
test()("`Client.render()` is automatically called in iife mode", async () => { | ||
try { | ||
await using window = new Window(`<body *mizu><p *text="'foo'"></p></body>`) | ||
Object.assign(globalThis, { MIZU_IIFE: true, window }) | ||
await import("./mod.ts") | ||
expect(window.document.querySelector("p")?.textContent).toBe("foo") | ||
} finally { | ||
delete (globalThis as testing).MIZU_IIFE | ||
delete (globalThis as testing).window | ||
} | ||
}) |
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