mirror of
https://github.com/django-components/django-components.git
synced 2025-08-03 22:08:17 +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
|
@ -335,17 +335,10 @@ class Button(Component):
|
|||
# The code above is used also used when benchmarking.
|
||||
# The section below is NOT included.
|
||||
|
||||
from .testutils import CsrfTokenPatcher, GenIdPatcher # noqa: E402
|
||||
from django_components.testing import djc_test # noqa: E402
|
||||
|
||||
@djc_test
|
||||
def test_render(snapshot):
|
||||
id_patcher = GenIdPatcher()
|
||||
id_patcher.start()
|
||||
csrf_token_patcher = CsrfTokenPatcher()
|
||||
csrf_token_patcher.start()
|
||||
|
||||
data = gen_render_data()
|
||||
rendered = render(data)
|
||||
assert rendered == snapshot
|
||||
|
||||
id_patcher.stop()
|
||||
csrf_token_patcher.stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue