def GetCompletions_ChangeStartColumn_test(app): StartJavaScriptCompleterServerInDirectory(app, PathToTestFile('node')) RunTest( app, { 'description': 'the completion_start_column is updated by tern', 'request': { 'filetype': 'javascript', 'filepath': PathToTestFile('node', 'node_test.js'), 'line_num': 1, 'column_num': 17, 'force_semantic': True, }, 'expect': { 'response': requests.codes.ok, 'data': has_entries({ 'completions': contains(CompletionEntryMatcher('"path"', 'path')), 'completion_start_column': 14, 'errors': empty(), }) }, })
def Subcommands_StopServer_Timeout_test(app): StartJavaScriptCompleterServerInDirectory(app, PathToTestFile()) app.post_json( '/run_completer_command', BuildRequest(filetype='javascript', command_arguments=['StopServer'])) request_data = BuildRequest(filetype='javascript') assert_that( app.post_json('/debug_info', request_data).json, has_entry( 'completer', has_entry('servers', contains(has_entry('is_running', False)))))
def Subcommands_GoTo_RelativePath_test( app ): StartJavaScriptCompleterServerInDirectory( app, PathToTestFile() ) RunTest( app, { 'description': 'GoTo works when the buffer differs from the file on disk', 'request': { 'command': 'GoTo', 'line_num': 43, 'column_num': 25, 'filepath': PathToTestFile( 'simple_test.js' ), }, 'expect': { 'response': requests.codes.ok, 'data': has_entries( { 'filepath': PathToTestFile( 'simple_test.js' ), 'line_num': 31, 'column_num': 5, } ) } }, contents = ReadFile( PathToTestFile( 'simple_test.modified.js' ) ) )
def Subcommands_RefactorRename_MultipleFiles_OnFileReadyToParse_test(app): StartJavaScriptCompleterServerInDirectory(app, PathToTestFile()) file1 = PathToTestFile('file1.js') file2 = PathToTestFile('file2.js') file3 = PathToTestFile('file3.js') # This test is roughly the same as the previous one, except here file4.js is # pushed into the Tern engine via 'opening it in the editor' (i.e. # FileReadyToParse event). The first 3 are loaded into the tern server # because they are listed in the .tern-project file's loadEagerly option. file4 = PathToTestFile('file4.js') app.post_json('/event_notification', BuildRequest( **{ 'filetype': 'javascript', 'event_name': 'FileReadyToParse', 'contents': ReadFile(file4), 'filepath': file4, }), expect_errors=False) RunTest( app, { 'description': 'FileReadyToParse loads files into tern server', 'request': { 'command': 'RefactorRename', 'arguments': ['a-quite-long-string'], 'filepath': file1, 'line_num': 3, 'column_num': 14, }, 'expect': { 'response': requests.codes.ok, 'data': has_entries({ 'fixits': contains( has_entries({ 'chunks': contains( ChunkMatcher('a-quite-long-string', LocationMatcher(file1, 1, 5), LocationMatcher(file1, 1, 11)), ChunkMatcher('a-quite-long-string', LocationMatcher(file1, 3, 14), LocationMatcher(file1, 3, 20)), ChunkMatcher('a-quite-long-string', LocationMatcher(file2, 2, 14), LocationMatcher(file2, 2, 20)), ChunkMatcher('a-quite-long-string', LocationMatcher(file3, 3, 12), LocationMatcher(file3, 3, 18)), ChunkMatcher('a-quite-long-string', LocationMatcher(file4, 4, 22), LocationMatcher(file4, 4, 28))), 'location': LocationMatcher(file1, 3, 14) })) }) } })