<commit_before># Copyright (c) 2012 gocept gmbh & co. kg
# See also LICENSE.txt

import zeit.cms.testing


class EvaluateTest(zeit.cms.testing.SeleniumTestCase):

    def setUp(self):
        super(EvaluateTest, self).setUp()
        self.open('/@@/zeit.cms.javascript.base/tests/evaluate/index.html')

    def write_html(self, text):
        text = text.replace('\n', ' ')
        self.eval("window.jQuery('#foo').html('%s')" % text)

    def evaluate_js_and_css(self):
        self.eval(
            'zeit.cms.evaluate_js_and_css(document.getElementById("foo"))')

    def test_loads_external_scripts(self):
        self.write_html(
            '<script type="text/javascript" src="external.js"></script>')
        self.evaluate_js_and_css()
        self.assertEqual('true', self.eval('zeit.cms.test_external_loaded'))

    def test_evaluates_inline_scripts_once(self):
        self.write_html("""
        <script type="text/javascript">
          zeit.cms.test_inline_loaded = (zeit.cms.test_inline_loaded || 0) + 1;
        </script>""")
        self.evaluate_js_and_css()
        self.assertEqual('1', self.eval('zeit.cms.test_inline_loaded'))
        self.evaluate_js_and_css()
        self.assertEqual('1', self.eval('zeit.cms.test_inline_loaded'))

    def test_imports_style_sheets(self):
        s = self.selenium
        s.assertVisible('css=h3')
        self.write_html(
            '<link rel="stylesheet" type="text/css" href="style.css" />')
        self.evaluate_js_and_css()
        s.assertNotVisible('css=h3')

    def test_evaluates_inline_style_sheets(self):
        s = self.selenium<commit_msg>Re #11620: Make test do what we want it to<commit_after># Copyright (c) 2012 gocept gmbh & co. kg
# See also LICENSE.txt

import zeit.cms.testing


class EvaluateTest(zeit.cms.testing.SeleniumTestCase):

    def setUp(self):
        super(EvaluateTest, self).setUp()
        self.open('/@@/zeit.cms.javascript.base/tests/evaluate/index.html')

    def write_html(self, text):
        text = text.replace('\n', ' ')
        self.eval("document.getElementById('foo').innerHTML = '%s'" % text)

    def evaluate_js_and_css(self):
        self.eval(
            'zeit.cms.evaluate_js_and_css(document.getElementById("foo"))')

    def test_loads_external_scripts(self):
        self.write_html(
            '<script type="text/javascript" src="external.js"></script>')
        self.evaluate_js_and_css()
        self.assertEqual('true', self.eval('zeit.cms.test_external_loaded'))

    def test_evaluates_inline_scripts_once(self):
        self.write_html("""
        <script type="text/javascript">
          zeit.cms.test_inline_loaded = (zeit.cms.test_inline_loaded || 0) + 1;
        </script>""")
        self.assertEqual('null', self.eval('zeit.cms.test_inline_loaded'))
        self.evaluate_js_and_css()
        self.assertEqual('1', self.eval('zeit.cms.test_inline_loaded'))
        self.evaluate_js_and_css()
        self.assertEqual('1', self.eval('zeit.cms.test_inline_loaded'))

    def test_imports_style_sheets(self):
        s = self.selenium
        s.assertVisible('css=h3')
        self.write_html(
            '<link rel="stylesheet" type="text/css" href="style.css" />')
        self.evaluate_js_and_css()
        s.assertNotVisible('css=h3')

    def test_evaluates_inline_style_sheets(self):
        s = self.selenium
{'fraction_non_alphanumeric': 0.14524306591112437, 'fraction_numerical': 0.007456009543692216, 'mean_word_length': 3.0902439024390245, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6122601', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1067, 'n_words': 155}