def test_check_extra_js_file_found(self):

    def mock_readlines(unused_self, unused_filepath):
        return ('var a = 10;\n',)

    def mock_read(unused_self, unused_filepath):
        return 'var a = 10;\n'
    readlines_swap = self.swap(pre_commit_linter.FileCache, 'readlines', mock_readlines)
    read_swap = self.swap(pre_commit_linter.FileCache, 'read', mock_read)
    with readlines_swap, read_swap:
        lint_task_report = js_ts_linter.JsTsLintChecksManager([EXTRA_JS_FILEPATH], [], FILE_CACHE).perform_all_lint_checks()
    shutil.rmtree(js_ts_linter.COMPILED_TYPESCRIPT_TMP_PATH, ignore_errors=True)
    expected_messages = ['Found extra .js file']
    expected_messages.extend(['If you want the above files to be present as js files, add them to the list JS_FILEPATHS_NOT_TO_BUILD in build.py. Otherwise, rename them to .ts'])
    self.validate(lint_task_report, expected_messages, 1)
def test_check_extra_js_file_found(self):

    def mock_readlines(unused_self, unused_filepath):
        return ('var a = 10;\n',)

    def mock_read(unused_self, unused_filepath):
        return 'var a = 10;\n'
    readlines_swap = self.swap(pre_commit_linter.FileCache, 'readlines', mock_readlines)
    read_swap = self.swap(pre_commit_linter.FileCache, 'read', mock_read)
    with readlines_swap, read_swap:
        lint_task_report = js_ts_linter.JsTsLintChecksManager([EXTRA_JS_FILEPATH], [], FILE_CACHE).perform_all_lint_checks()
    shutil.rmtree(js_ts_linter.COMPILED_TYPESCRIPT_TMP_PATH, ignore_errors=True)
    expected_messages = ['Found extra .js file']
    expected_messages.extend(['If you want the above files to be present as js files, add them to the list JS_FILEPATHS_NOT_TO_BUILD in build.py. Otherwise, rename them to .ts'])
    self.validate(lint_task_report, expected_messages, 1)