Merge pull request #3292 from Microsoft/jsDocTests1

Add a couple of tests for jsdoccomments.
This commit is contained in:
CyrusNajmabadi 2015-05-28 14:46:11 -07:00
commit 1ecb896b87
4 changed files with 39 additions and 0 deletions

View File

@ -798,8 +798,17 @@ module FourSlash {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
public getSyntacticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
public getSemanticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) {
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
var actual = JSON.stringify(realized, null, " ");
assert.equal(actual, expected);

View File

@ -448,6 +448,10 @@ module FourSlashInterface {
FourSlash.currentTestState.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation);
}
public getSyntacticDiagnostics(expected: string) {
FourSlash.currentTestState.getSyntacticDiagnostics(expected);
}
public getSemanticDiagnostics(expected: string) {
FourSlash.currentTestState.getSemanticDiagnostics(expected);
}

View File

@ -0,0 +1,7 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// function foo(...a) {}
verify.getSemanticDiagnostics(`[]`);

View File

@ -0,0 +1,19 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: a.js
//// /**
//// * @type {number}
//// * @type {string}
//// */
//// var v;
verify.getSyntacticDiagnostics(`[
{
"message": "\'type\' tag already specified.",
"start": 26,
"length": 4,
"category": "error",
"code": 1219
}
]`);