Skip to content

Commit

Permalink
Add and refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed May 18, 2021
1 parent 75e634b commit d459d46
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
15 changes: 14 additions & 1 deletion tests/test_base.py
@@ -1,10 +1,12 @@
from django.test import TestCase
from django.utils import translation
from django.utils.translation import gettext_lazy as _

from .test_template_tags import render_template


class BaseTest(TestCase):
"""Test the Font Awesome Renderer."""
"""Test the BaseRenderer."""

def test_version(self):
from django_icons import __version__
Expand All @@ -21,3 +23,14 @@ def test_icons(self):
render_template('{% icon "fas fa-user fa-2x" size="lg" renderer="BaseRenderer" %}'),
'<i class="fas fa-user fa-2x"></i>',
)

def test_laziness(self):
self.assertEqual(
render_template('{% icon "user" title=title renderer="BaseRenderer" %}', title=_("user")),
'<i class="user" title="user"></i>',
)
with translation.override("nl"):
self.assertEqual(
render_template('{% icon "user" title=title renderer="BaseRenderer" %}', title=_("user")),
'<i class="user" title="gebruiker"></i>',
)
2 changes: 1 addition & 1 deletion tests/test_bootstrap3.py
Expand Up @@ -4,7 +4,7 @@


class Bootstrap3Test(TestCase):
"""Test the Font Awesome Renderer."""
"""Test Bootstrap 3 Renderer."""

def test_icons(self):
self.assertEqual(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fontawesome.py → tests/test_fontawesome4.py
Expand Up @@ -3,8 +3,8 @@
from .test_template_tags import render_template


class FontAwesomeTest(TestCase):
"""Test the Font Awesome Renderer."""
class FontAwesome4Test(TestCase):
"""Test the FontAwesome 4 Renderer."""

def test_icons(self):
self.assertEqual(
Expand Down
21 changes: 21 additions & 0 deletions tests/test_icon.py
@@ -0,0 +1,21 @@
from django.test import TestCase
from django.utils import translation
from django.utils.translation import gettext_lazy as _

from django_icons import icon
from django_icons.renderers import BaseRenderer


class IconTest(TestCase):
"""Test the icon function."""

def test_laziness(self):
self.assertEqual(
icon("user", title=_("user"), renderer=BaseRenderer),
'<i class="user" title="user"></i>',
)
with translation.override("nl"):
self.assertEqual(
icon("user", title=_("user"), renderer=BaseRenderer),
'<i class="user" title="gebruiker"></i>',
)
2 changes: 1 addition & 1 deletion tests/test_utils.py
Expand Up @@ -5,7 +5,7 @@


class UtilsTest(TestCase):
"""Test the Font Awesome Renderer."""
"""Test the utility functions."""

def test_get_setting(self):
with self.settings(DJANGO_ICONS=None):
Expand Down

0 comments on commit d459d46

Please sign in to comment.