mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
fourslash diagnostics tests: use objects instead of strings (#22193)
This commit is contained in:
@@ -1236,20 +1236,18 @@ Actual: ${stringify(fullActual)}`);
|
||||
return this.languageService.findReferences(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(expected: string) {
|
||||
public getSyntacticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
|
||||
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
|
||||
this.testDiagnostics(expected, diagnostics);
|
||||
}
|
||||
|
||||
public getSemanticDiagnostics(expected: string) {
|
||||
public getSemanticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
|
||||
const diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
|
||||
this.testDiagnostics(expected, diagnostics);
|
||||
}
|
||||
|
||||
private testDiagnostics(expected: string, diagnostics: ReadonlyArray<ts.Diagnostic>) {
|
||||
const realized = ts.realizeDiagnostics(diagnostics, "\r\n");
|
||||
const actual = stringify(realized);
|
||||
assert.equal(actual, expected);
|
||||
private testDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>, diagnostics: ReadonlyArray<ts.Diagnostic>) {
|
||||
assert.deepEqual(ts.realizeDiagnostics(diagnostics, ts.newLineCharacter), expected);
|
||||
}
|
||||
|
||||
public verifyQuickInfoAt(markerName: string, expectedText: string, expectedDocumentation?: string) {
|
||||
@@ -4321,11 +4319,11 @@ namespace FourSlashInterface {
|
||||
this.state.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation, tags);
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(expected: string) {
|
||||
public getSyntacticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
|
||||
this.state.getSyntacticDiagnostics(expected);
|
||||
}
|
||||
|
||||
public getSemanticDiagnostics(expected: string) {
|
||||
public getSemanticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
|
||||
this.state.getSemanticDiagnostics(expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -581,7 +581,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
interface RealizedDiagnostic {
|
||||
export interface RealizedDiagnostic {
|
||||
message: string;
|
||||
start: number;
|
||||
length: number;
|
||||
|
||||
Reference in New Issue
Block a user