浏览代码

#362 add pytests

Falko Schindler 2 年之前
父节点
当前提交
f533a8bd57
共有 1 个文件被更改,包括 29 次插入0 次删除
  1. 29 0
      tests/test_tailwind.py

+ 29 - 0
tests/test_tailwind.py

@@ -0,0 +1,29 @@
+from nicegui import Tailwind, ui
+
+from .screen import Screen
+
+
+def test_tailwind_builder(screen: Screen):
+    ui.label('A').tailwind('bg-red-500', 'text-white')
+
+    screen.open('/')
+    assert screen.find('A').get_attribute('class') == 'bg-red-500 text-white'
+
+
+def test_tailwind_call(screen: Screen):
+    ui.label('A').tailwind('bg-red-500 text-white')
+
+    screen.open('/')
+    assert screen.find('A').get_attribute('class') == 'bg-red-500 text-white'
+
+
+def test_tailwind_apply(screen: Screen):
+    style = Tailwind().background_color('red-500').text_color('white')
+
+    ui.label('A').tailwind(style)
+    b = ui.label('B')
+    style.apply(b)
+
+    screen.open('/')
+    assert screen.find('A').get_attribute('class') == 'bg-red-500 text-white'
+    assert screen.find('B').get_attribute('class') == 'bg-red-500 text-white'