forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_check_brand_ui.py
More file actions
36 lines (24 loc) · 1.35 KB
/
Copy pathtest_check_brand_ui.py
File metadata and controls
36 lines (24 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
"""Unit tests for check_brand_ui.py count_purple helper."""
from __future__ import annotations
import unittest
from check_brand_ui import count_purple, is_ui_source
class BrandUiTests(unittest.TestCase):
def test_counts_color_purple_and_hex(self) -> None:
text = "Color.purple\nlet x = Color(hex: 0x8B5CF6)\n#8B5CF6\npurplePrimary\n"
# Color.purple + #8B5CF6 + purplePrimary = 3 (0x8B5CF6 not matched — hex with # only)
self.assertGreaterEqual(count_purple(text), 3)
def test_is_ui_source(self) -> None:
self.assertTrue(is_ui_source("desktop/macos/Desktop/Sources/Foo.swift"))
self.assertFalse(is_ui_source("backend/main.py"))
self.assertFalse(is_ui_source("desktop/macos/Desktop/Sources/Theme/OmiColors.swift"))
def test_counts_swiftui_dot_purple(self) -> None:
self.assertGreaterEqual(count_purple(".foregroundStyle(.purple)"), 1)
def test_counts_flutter_colors_purple(self) -> None:
self.assertGreaterEqual(count_purple("color: Colors.purple"), 1)
def test_counts_tailwind_bg_purple_500(self) -> None:
self.assertGreaterEqual(count_purple('className="bg-purple-500 text-purple-700"'), 2)
def test_counts_css_color_purple(self) -> None:
self.assertGreaterEqual(count_purple("color: purple;"), 1)
if __name__ == "__main__":
unittest.main()