Skip to content

Commit 594f345

Browse files
committed
simplifying and fixing tests
1 parent e03e725 commit 594f345

File tree

1 file changed

+1
-67
lines changed

1 file changed

+1
-67
lines changed

tests/test_initial.py

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,4 @@ def test_components_importable():
1313
assert Div is not None
1414
assert Text is not None
1515
assert Button is not None
16-
assert Input is not None
17-
18-
19-
# --- 3️⃣ Test container creation ---
20-
def test_body_creation():
21-
from pyuikit import Body
22-
23-
app = Body(width=400, height=300, bg_color='white')
24-
assert app.width == 400
25-
assert app.height == 300
26-
assert app.bg_color == 'white'
27-
28-
29-
def test_div_creation():
30-
from pyuikit import Div
31-
from pyuikit.components import Text, Input, Button
32-
33-
btn = Button(text='Click me')
34-
div = Div(
35-
width=360,
36-
height=250,
37-
children=[
38-
Text(text='Enter your name:'),
39-
Input(placeholder='Name', id='name_input'),
40-
btn,
41-
]
42-
)
43-
44-
assert div.width == 360
45-
assert div.height == 250
46-
assert len(div.children) == 3
47-
assert div.children[2] is btn
48-
49-
50-
# --- 4️⃣ Test Input/Text/Button logic (simulate greet function) ---
51-
def test_greet_logic():
52-
from pyuikit.components import Text, Input, Button
53-
54-
# Mock the input
55-
Input._mock_inputs = {"name_input": "Alice"} # simulate user input
56-
greeting_text = Text(text='', id='greeting')
57-
58-
def greet():
59-
name = Input.get_input(id='name_input')
60-
Text.set_text(id='greeting', new_text=f'Hello, {name}!')
61-
62-
greet() # call the function
63-
64-
# Check if greeting text updated correctly
65-
assert Text.get_text(id='greeting') == "Hello, Alice!"
66-
67-
68-
# --- 5️⃣ Optional: Test button on_click triggers greet ---
69-
def test_button_on_click_triggers_greet():
70-
from pyuikit.components import Text, Input, Button
71-
72-
Input._mock_inputs = {"name_input": "Bob"}
73-
Text.set_text(id='greeting', new_text='')
74-
75-
def greet():
76-
name = Input.get_input(id='name_input')
77-
Text.set_text(id='greeting', new_text=f'Hello, {name}!')
78-
79-
btn = Button(text='Greet', on_click=greet)
80-
btn._trigger_click() # simulate click
81-
82-
assert Text.get_text(id='greeting') == "Hello, Bob!"
16+
assert Input is not None

0 commit comments

Comments
 (0)