mirror of
https://github.com/django-components/django-components.git
synced 2025-08-31 03:07:19 +00:00
feat: add decorator for writing component tests (#1008)
* feat: add decorator for writing component tests * refactor: udpate changelog + update deps pins * refactor: fix deps * refactor: make cached_ref into generic and fix linter errors * refactor: fix coverage testing * refactor: use global var instead of env var for is_testing state
This commit is contained in:
parent
81ac59f7fb
commit
7dfcb447c4
62 changed files with 4428 additions and 3661 deletions
|
@ -1,12 +1,13 @@
|
|||
from django_components.util.component_highlight import apply_component_highlight, COLORS
|
||||
|
||||
from .django_test_setup import setup_test_config
|
||||
from .testutils import BaseTestCase
|
||||
from django_components.testing import djc_test
|
||||
from .testutils import setup_test_config
|
||||
|
||||
setup_test_config({"autodiscover": False})
|
||||
|
||||
|
||||
class ComponentHighlightTests(BaseTestCase):
|
||||
@djc_test
|
||||
class TestComponentHighlight:
|
||||
def test_component_highlight(self):
|
||||
# Test component highlighting
|
||||
test_html = "<div>Test content</div>"
|
||||
|
@ -14,12 +15,12 @@ class ComponentHighlightTests(BaseTestCase):
|
|||
result = apply_component_highlight("component", test_html, component_name)
|
||||
|
||||
# Check that the output contains the component name
|
||||
self.assertIn(component_name, result)
|
||||
assert component_name in result
|
||||
# Check that the output contains the original HTML
|
||||
self.assertIn(test_html, result)
|
||||
assert test_html in result
|
||||
# Check that the component colors are used
|
||||
self.assertIn(COLORS["component"].text_color, result)
|
||||
self.assertIn(COLORS["component"].border_color, result)
|
||||
assert COLORS["component"].text_color in result
|
||||
assert COLORS["component"].border_color in result
|
||||
|
||||
def test_slot_highlight(self):
|
||||
# Test slot highlighting
|
||||
|
@ -28,9 +29,9 @@ class ComponentHighlightTests(BaseTestCase):
|
|||
result = apply_component_highlight("slot", test_html, slot_name)
|
||||
|
||||
# Check that the output contains the slot name
|
||||
self.assertIn(slot_name, result)
|
||||
assert slot_name in result
|
||||
# Check that the output contains the original HTML
|
||||
self.assertIn(test_html, result)
|
||||
assert test_html in result
|
||||
# Check that the slot colors are used
|
||||
self.assertIn(COLORS["slot"].text_color, result)
|
||||
self.assertIn(COLORS["slot"].border_color, result)
|
||||
assert COLORS["slot"].text_color in result
|
||||
assert COLORS["slot"].border_color in result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue