1namespace ts.projectSystem { 2 describe("unittests:: tsserver:: occurrence highlight on string", () => { 3 it("should be marked if only on string values", () => { 4 const file1: File = { 5 path: "/a/b/file1.ts", 6 content: `let t1 = "div";\nlet t2 = "div";\nlet t3 = { "div": 123 };\nlet t4 = t3["div"];` 7 }; 8 9 const host = createServerHost([file1]); 10 const session = createSession(host); 11 const projectService = session.getProjectService(); 12 13 projectService.openClientFile(file1.path); 14 { 15 const highlightRequest = makeSessionRequest<protocol.FileLocationRequestArgs>( 16 CommandNames.Occurrences, 17 { file: file1.path, line: 1, offset: 11 } 18 ); 19 const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; 20 const firstOccurence = highlightResponse[0]; 21 assert.isTrue(firstOccurence.isInString, "Highlights should be marked with isInString"); 22 } 23 24 { 25 const highlightRequest = makeSessionRequest<protocol.FileLocationRequestArgs>( 26 CommandNames.Occurrences, 27 { file: file1.path, line: 3, offset: 13 } 28 ); 29 const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; 30 assert.isTrue(highlightResponse.length === 2); 31 const firstOccurence = highlightResponse[0]; 32 assert.isUndefined(firstOccurence.isInString, "Highlights should not be marked with isInString if on property name"); 33 } 34 35 { 36 const highlightRequest = makeSessionRequest<protocol.FileLocationRequestArgs>( 37 CommandNames.Occurrences, 38 { file: file1.path, line: 4, offset: 14 } 39 ); 40 const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; 41 assert.isTrue(highlightResponse.length === 2); 42 const firstOccurence = highlightResponse[0]; 43 assert.isUndefined(firstOccurence.isInString, "Highlights should not be marked with isInString if on indexer"); 44 } 45 }); 46 }); 47} 48