Skip to content

Commit ca289d0

Browse files
committed
revert idom.html changes in tests
1 parent fd09362 commit ca289d0

File tree

1 file changed

+40
-41
lines changed

1 file changed

+40
-41
lines changed

tests/test_app/components.py

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import idom
2-
from idom import html
32
from test_app.models import TodoItem
43

54
import django_idom
@@ -8,18 +7,18 @@
87

98
@idom.component
109
def hello_world():
11-
return html.h1({"id": "hello-world"}, "Hello World!")
10+
return idom.html.h1({"id": "hello-world"}, "Hello World!")
1211

1312

1413
@idom.component
1514
def button():
1615
count, set_count = idom.hooks.use_state(0)
17-
return html.div(
18-
html.button(
16+
return idom.html.div(
17+
idom.html.button(
1918
{"id": "counter-inc", "onClick": lambda event: set_count(count + 1)},
2019
"Click me!",
2120
),
22-
html.p(
21+
idom.html.p(
2322
{"id": "counter-num", "data-count": count},
2423
f"Current count is: {count}",
2524
),
@@ -29,7 +28,7 @@ def button():
2928
@idom.component
3029
def parameterized_component(x, y):
3130
total = x + y
32-
return html.h1({"id": "parametrized-component", "data-value": total}, total)
31+
return idom.html.h1({"id": "parametrized-component", "data-value": total}, total)
3332

3433

3534
victory = idom.web.module_from_template("react", "victory-bar", fallback="...")
@@ -46,90 +45,90 @@ def use_websocket():
4645
ws = django_idom.hooks.use_websocket()
4746
ws.scope = "..."
4847
success = bool(ws.scope and ws.close and ws.disconnect and ws.view_id)
49-
return html.div(
48+
return idom.html.div(
5049
{"id": "use-websocket", "data-success": success},
51-
html.hr(),
50+
idom.html.hr(),
5251
f"use_websocket: {ws}",
53-
html.hr(),
52+
idom.html.hr(),
5453
)
5554

5655

5756
@idom.component
5857
def use_scope():
5958
scope = django_idom.hooks.use_scope()
6059
success = len(scope) >= 10 and scope["type"] == "websocket"
61-
return html.div(
60+
return idom.html.div(
6261
{"id": "use-scope", "data-success": success},
6362
f"use_scope: {scope}",
64-
html.hr(),
63+
idom.html.hr(),
6564
)
6665

6766

6867
@idom.component
6968
def use_location():
7069
location = django_idom.hooks.use_location()
7170
success = bool(location)
72-
return html.div(
71+
return idom.html.div(
7372
{"id": "use-location", "data-success": success},
7473
f"use_location: {location}",
75-
html.hr(),
74+
idom.html.hr(),
7675
)
7776

7877

7978
@idom.component
8079
def django_css():
81-
return html.div(
80+
return idom.html.div(
8281
{"id": "django-css"},
8382
django_idom.components.django_css("django-css-test.css"),
84-
html.div({"style": {"display": "inline"}}, "django_css: "),
85-
html.button("This text should be blue."),
86-
html.hr(),
83+
idom.html.div({"style": {"display": "inline"}}, "django_css: "),
84+
idom.html.button("This text should be blue."),
85+
idom.html.hr(),
8786
)
8887

8988

9089
@idom.component
9190
def django_js():
9291
success = False
93-
return html._(
94-
html.div(
92+
return idom.html._(
93+
idom.html.div(
9594
{"id": "django-js", "data-success": success},
9695
f"django_js: {success}",
9796
django_idom.components.django_js("django-js-test.js"),
9897
),
99-
html.hr(),
98+
idom.html.hr(),
10099
)
101100

102101

103102
@idom.component
104103
@django_idom.decorators.auth_required(
105-
fallback=html.div(
104+
fallback=idom.html.div(
106105
{"id": "unauthorized-user-fallback"},
107106
"unauthorized_user: Success",
108-
html.hr(),
107+
idom.html.hr(),
109108
)
110109
)
111110
def unauthorized_user():
112-
return html.div(
111+
return idom.html.div(
113112
{"id": "unauthorized-user"},
114113
"unauthorized_user: Fail",
115-
html.hr(),
114+
idom.html.hr(),
116115
)
117116

118117

119118
@idom.component
120119
@django_idom.decorators.auth_required(
121120
auth_attribute="is_anonymous",
122-
fallback=html.div(
121+
fallback=idom.html.div(
123122
{"id": "authorized-user-fallback"},
124123
"authorized_user: Fail",
125-
html.hr(),
124+
idom.html.hr(),
126125
),
127126
)
128127
def authorized_user():
129-
return html.div(
128+
return idom.html.div(
130129
{"id": "authorized-user"},
131130
"authorized_user: Success",
132-
html.hr(),
131+
idom.html.hr(),
133132
)
134133

135134

@@ -161,23 +160,23 @@ def todo_list():
161160
toggle_item = use_mutation(toggle_item_mutation, refetch=get_items_query)
162161

163162
if items.error:
164-
rendered_items = html.h2(f"Error when loading - {items.error}")
163+
rendered_items = idom.html.h2(f"Error when loading - {items.error}")
165164
elif items.data is None:
166-
rendered_items = html.h2("Loading...")
165+
rendered_items = idom.html.h2("Loading...")
167166
else:
168-
rendered_items = html._(
169-
html.h3("Not Done"),
167+
rendered_items = idom.html._(
168+
idom.html.h3("Not Done"),
170169
_render_items([i for i in items.data if not i.done], toggle_item),
171-
html.h3("Done"),
170+
idom.html.h3("Done"),
172171
_render_items([i for i in items.data if i.done], toggle_item),
173172
)
174173

175174
add_item = use_mutation(add_item_mutation, refetch=get_items_query)
176175

177176
if add_item.loading:
178-
mutation_status = html.h2("Working...")
177+
mutation_status = idom.html.h2("Working...")
179178
elif add_item.error:
180-
mutation_status = html.h2(f"Error when adding - {add_item.error}")
179+
mutation_status = idom.html.h2(f"Error when adding - {add_item.error}")
181180
else:
182181
mutation_status = ""
183182

@@ -189,9 +188,9 @@ def on_submit(event):
189188
def on_change(event):
190189
set_input_value(event["target"]["value"])
191190

192-
return html.div(
193-
html.label("Add an item:"),
194-
html.input(
191+
return idom.html.div(
192+
idom.html.label("Add an item:"),
193+
idom.html.input(
195194
{
196195
"type": "text",
197196
"id": "todo-input",
@@ -206,12 +205,12 @@ def on_change(event):
206205

207206

208207
def _render_items(items, toggle_item):
209-
return html.ul(
208+
return idom.html.ul(
210209
[
211-
html.li(
210+
idom.html.li(
212211
{"id": f"todo-item-{item.text}"},
213212
item.text,
214-
html.input(
213+
idom.html.input(
215214
{
216215
"id": f"todo-item-{item.text}-checkbox",
217216
"type": "checkbox",

0 commit comments

Comments
 (0)