<commit_before><commit_msg>Add tests suite for spoiler tag.<commit_after>"""
SkCode spoiler tag test code.
"""

import unittest

from skcode.etree import TreeNode
from skcode.tags import (SpoilerTagOptions,
                         DEFAULT_RECOGNIZED_TAGS)


class HorizontalLineTagTestCase(unittest.TestCase):
    """ Tests suite for the spoiler tag module. """

    def test_tag_and_aliases_in_default_recognized_tags_dict(self):
        """ Test the presence of the tag and aliases in the dictionary of default recognized tags. """
        self.assertIn('spoiler', DEFAULT_RECOGNIZED_TAGS)
        self.assertIsInstance(DEFAULT_RECOGNIZED_TAGS['spoiler'], SpoilerTagOptions)

    def test_tag_constant_values(self):
        """ Test tag constants. """
        opts = SpoilerTagOptions()
        self.assertFalse(opts.newline_closes)
        self.assertFalse(opts.same_tag_closes)
        self.assertFalse(opts.standalone)
        self.assertTrue(opts.parse_embedded)
        self.assertFalse(opts.swallow_trailing_newline)
        self.assertFalse(opts.inline)
        self.assertTrue(opts.close_inlines)
        self.assertTrue(opts.make_paragraphs_here)

    def test_render_html(self):
        """ Test the ``render_html`` method. """
        opts = SpoilerTagOptions()
        self.assertEqual('<div class="spoiler">test</div>\n', opts.render_html(None, 'test'))

    def test_render_text(self):
        """ Test the ``render_text`` method. """
        opts = SpoilerTagOptions()
        self.assertEqual('!!! SPOILER !!!\n! test\n!!!\n', opts.render_text(None, 'test'))

    def test_render_skcode(self):
        """ Test the ``render_skcode`` method. """
        opts = SpoilerTagOptions()
        tree_node = TreeNode(None, 'spoiler', opts)
        self.assertEqual('[spoiler]test[/spoiler]', opts.render_skcode(tree_node, 'test'))
{'fraction_non_alphanumeric': 0.11950027159152635, 'fraction_numerical': 0.0, 'mean_word_length': 3.5036674816625917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6119784', 'n_tokens_mistral': 571, 'n_tokens_neox': 565, 'n_words': 108}