Skip to content

Commit 98d86b1

Browse files
committed
fix web module tests
1 parent 3085db7 commit 98d86b1

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

tests/test_web/js_fixtures/exports-two-components.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import htm from "https://unpkg.com/htm?module";
33

44
const html = htm.bind(h);
55

6-
export { h as createElement, render as renderElement };
7-
8-
export function unmountElement(container) {
9-
render(null, container);
6+
export function bind(node, config) {
7+
return {
8+
render: (component, props, children) =>
9+
render(h(component, props), node),
10+
unmount: () => render(null, node),
11+
}
1012
}
1113

1214
export function Header1(props) {

tests/test_web/js_fixtures/set-flag-when-unmount-is-called.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
export function createElement(component, props) {
2-
return component(props);
1+
export function bind(node, config) {
2+
return {
3+
render: (component, props, children) =>
4+
renderElement(component(props), node),
5+
unmount: () => unmountElement(node),
6+
}
37
}
48

59
export function renderElement(element, container) {

tests/test_web/js_fixtures/simple-button.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import htm from "https://unpkg.com/htm?module";
33

44
const html = htm.bind(h);
55

6-
export { h as createElement, render as renderElement };
7-
8-
export function unmountElement(container) {
9-
render(null, container);
6+
export function bind(node, config) {
7+
return {
8+
render: (component, props, children) =>
9+
render(h(component, props), node),
10+
unmount: () => render(null, node),
11+
}
1012
}
1113

1214
export function SimpleButton(props) {

tests/test_web/test_module.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_web_module_from_file_symlink(tmp_path):
144144

145145

146146
def test_module_missing_exports():
147-
module = WebModule("test", NAME_SOURCE, None, {"a", "b", "c"}, None)
147+
module = WebModule("test", NAME_SOURCE, None, {"a", "b", "c"}, None, False)
148148

149149
with pytest.raises(ValueError, match="does not export 'x'"):
150150
idom.web.export(module, "x")

0 commit comments

Comments
 (0)