'Test _check_mako_file_is_safe javascript string specific rules.
- mako_js_missing_quotes
- mako_js_html_string'

def test_check_mako_expressions_javascript_strings(self):

    linter = MakoTemplateLinter()
    results = FileResults('')
    mako_template = textwrap.dedent('\n                                                <%page    expression_filter="h"/>\n                                                <script    type="text/javascript">\n                                                                var    valid1    =    \'${x    |    n,    js_escaped_string}    ${y    |    n,    js_escaped_string}\'\n                                                                var    valid2    =    \'${x    |    n,    js_escaped_string}    ${y    |    n,    js_escaped_string}\'\n                                                                var    valid3    =    \'string\'    +    \'    ${x    |    n,    js_escaped_string}    \'\n                                                                var    valid4    =    "${Text(_(\'Some    mixed    text{begin_span}with    html{end_span}\')).format(\n                                                                                begin_span=HTML(\'<span>\'),\n                                                                                end_span=HTML(\'</span>\'),\n                                                                )    |    n,    js_escaped_string}"\n                                                                var    valid5    =    "    "    +    "${Text(_(\'Please    {link_start}send    us    e-mail{link_end}.\')).format(\n                                                                                link_start=HTML(\'<a    href="#"    id="feedback_email">\'),\n                                                                                link_end=HTML(\'</a>\'),\n                                                                )    |    n,    js_escaped_string}";\n                                                                var    invalid1    =    ${x    |    n,    js_escaped_string};\n                                                                var    invalid2    =    \'<strong>${x    |    n,    js_escaped_string}</strong>\'\n                                                                var    invalid3    =    \'<strong>${x    |    n,    dump_js_escaped_json}</strong>\'\n                                                </script>\n                                ')
    linter._check_mako_file_is_safe(mako_template, results)
    self.assertEqual(len(results.violations), 3)
    self.assertEqual(results.violations[0].rule, Rules.mako_js_missing_quotes)
    self.assertEqual(results.violations[1].rule, Rules.mako_js_html_string)
    self.assertEqual(results.violations[2].rule, Rules.mako_js_html_string)
