'Test _check_mako_file_is_safe in JavaScript require context provides
appropriate violations'

@data({'expression': '${x}', 'rule': Rules.mako_invalid_js_filter}, {'expression': '"${x    |    n,    js_escaped_string}"', 'rule': None})
def test_check_mako_expressions_in_require_module(self, data):

    linter = MakoTemplateLinter()
    results = FileResults('')
    mako_template = textwrap.dedent('\n                                                <%page    expression_filter="h"/>\n                                                ##    switch    to    JavaScript    context    (after    next    line)\n                                                <%static:require_module    module_name="${{x}}"    class_name="TestFactory">\n                                                                {expression}\n                                                </%static:require_module>\n                                                ##    switch    back    to    HTML    context\n                                                ${{x}}\n                                '.format(expression=data['expression']))
    linter._check_mako_file_is_safe(mako_template, results)
    self._validate_data_rules(data, results)
