mirror of
https://github.com/django-components/django-components.git
synced 2025-10-18 09:47:12 +00:00
Make test slightly more interesting.
This commit is contained in:
parent
31261ece08
commit
972f99af05
1 changed files with 16 additions and 7 deletions
|
@ -1,14 +1,23 @@
|
||||||
import unittest
|
import unittest
|
||||||
from django_components import component
|
from django_components import component
|
||||||
|
|
||||||
|
class SimpleComponent(component.Component):
|
||||||
|
def context(self, variable):
|
||||||
|
return {
|
||||||
|
"variable": variable,
|
||||||
|
}
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
template = "template.html"
|
||||||
|
css = {"all": "style.css"}
|
||||||
|
js = ("script.js",)
|
||||||
|
|
||||||
class ComponentRegistryTest(unittest.TestCase):
|
class ComponentRegistryTest(unittest.TestCase):
|
||||||
def test_simple_component(self):
|
def test_simple_component(self):
|
||||||
class MyComponent(component.Component):
|
|
||||||
pass
|
|
||||||
|
|
||||||
comp = MyComponent()
|
comp = SimpleComponent()
|
||||||
|
|
||||||
self.assertEqual(comp.context(), {})
|
self.assertEqual(comp.context("test"), {"variable": "test"})
|
||||||
self.assertEqual(comp._media.template, None)
|
self.assertEqual(comp._media.template, "template.html")
|
||||||
self.assertEqual(comp._media.css, {})
|
self.assertEqual(comp._media.css, {"all": "style.css"})
|
||||||
self.assertEqual(comp._media.js, ())
|
self.assertEqual(comp._media.js, ("script.js",))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue