aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/templates/django.html9
-rw-r--r--tests/test_contrib/test_django/test_templatetags/test_pykss.py24
-rw-r--r--tests/test_modifier.py7
-rw-r--r--tests/test_section.py6
4 files changed, 25 insertions, 21 deletions
diff --git a/tests/templates/django.html b/tests/templates/django.html
index 7c52f40..7a5cf38 100644
--- a/tests/templates/django.html
+++ b/tests/templates/django.html
@@ -8,11 +8,10 @@
["{{ modifier.name }}","{{ modifier.description }}"]{% if not forloop.last %},{% endif %}
{% endfor %}
],
- "example_html": "{{ example_html|escapejs }}",
+ "example_html": "{{ section.example|escapejs }}",
"modifier_examples": [
- {% for example in modifier_examples %}
- ["{{ example.modifier.name }}","{{ example.html|escapejs }}"]{% if not forloop.last %},{% endif %}
+ {% for modifier in section.modifiers %}
+ ["{{ modifier.name }}","{{ modifier.example|escapejs }}"]{% if not forloop.last %},{% endif %}
{% endfor %}
- ],
- "escaped_html": "{{ escaped_html|escapejs }}"
+ ]
}
diff --git a/tests/test_contrib/test_django/test_templatetags/test_pykss.py b/tests/test_contrib/test_django/test_templatetags/test_pykss.py
index f066499..d24f1ae 100644
--- a/tests/test_contrib/test_django/test_templatetags/test_pykss.py
+++ b/tests/test_contrib/test_django/test_templatetags/test_pykss.py
@@ -7,7 +7,6 @@ from django.utils import simplejson
from mock import patch, ANY
-from pykss.exceptions import SectionDoesNotExist
from pykss.parser import Parser
@@ -17,25 +16,14 @@ class StyleguideBlockTestCase(TestCase):
css = os.path.join(settings.PROJECT_ROOT, 'tests', 'fixtures', 'css')
self.styleguide = Parser(css)
- def test_when_section_does_not_exist_and_in_debug(self):
+ def test_when_section_does_not_exist(self):
template = Template("""
{% load pykss %}
{% styleguideblock styleguide "99" %}
{% endstyleguideblock %}
""")
context = Context({'styleguide': self.styleguide})
- self.assertRaises(SectionDoesNotExist, template.render, context)
-
- def test_when_section_does_not_exist_and_not_in_debug(self):
- with self.settings(TEMPLATE_DEBUG=False):
- template = Template("""
- {% load pykss %}
- {% styleguideblock styleguide "99" %}
- {% endstyleguideblock %}
- """)
- context = Context({'styleguide': self.styleguide})
- results = template.render(context)
- self.assertEqual(results.strip(), '')
+ self.assertEquals(template.render(context).strip(), '')
@patch('pykss.contrib.django.templatetags.pykss.render_to_string')
def test_uses_default_template(self, mock_render_to_string):
@@ -79,7 +67,7 @@ class StyleguideBlockTestCase(TestCase):
template = Template("""
{% load pykss %}
{% styleguideblock styleguide "2.1.1" using "django.html" %}
- <i class="main{{ modifier_class }}"></i>
+ <i class="main$modifier_class"></i>
{% endstyleguideblock %}
""")
context = Context({'styleguide': self.styleguide})
@@ -90,4 +78,8 @@ class StyleguideBlockTestCase(TestCase):
self.assertEqual(results['modifiers'][0], [':hover', 'Highlights when hovering.'])
self.assertEqual(results['example_html'], '<i class="main"></i>')
self.assertEqual(results['modifier_examples'][0], [':hover', '<i class="main pseudo-class-hover"></i>'])
- self.assertEqual(results['escaped_html'], '&lt;i class=&quot;main&quot;&gt;&lt;/i&gt;')
+
+
+#class RenderStyleguideTestCase(TestCase):
+
+# def test_renders_correctly(self):
diff --git a/tests/test_modifier.py b/tests/test_modifier.py
index 1e109d8..8acb594 100644
--- a/tests/test_modifier.py
+++ b/tests/test_modifier.py
@@ -13,3 +13,10 @@ class ModiferTestCase(unittest.TestCase):
def test_handles_multiple_classes(self):
self.assertTrue('callout extreme' in self.modifier.class_name)
+
+ def test_add_example(self):
+ example = '<i class="icon$modifier_class"></i>'
+ expected = '<i class="icon callout extreme pseudo-class-hover"></i>'
+
+ self.modifier.add_example(example)
+ self.assertEqual(self.modifier.example, expected)
diff --git a/tests/test_section.py b/tests/test_section.py
index 7ba8496..6ece110 100644
--- a/tests/test_section.py
+++ b/tests/test_section.py
@@ -16,6 +16,9 @@ Your standard form button.
.primary - Indicates button is the primary action.
.smaller - A smaller button
+Example:
+ <a href="button$modifier_class">Button</a>
+
Styleguide 2.1.1.
"""
self.section = Section(comment.strip(), 'example.css')
@@ -32,5 +35,8 @@ Styleguide 2.1.1.
def test_parses_modifier_descriptions(self):
self.assertEqual(self.section.modifiers[0].description, 'Highlights when hovering.')
+ def test_parses_the_example(self):
+ self.assertEqual(self.section.example, '<a href="button">Button</a>')
+
def test_parses_the_styleguide_reference(self):
self.assertEqual(self.section.section, '2.1.1')