Code review cleanup - mostly in the unittests

This commit is contained in:
Erik Tierney committed 2013-05-09 14:54:40 -04:00
1 parent c162a75dc8
commit 678ae5aed0
2 files changed
+63 -61

No files matched your search

@@ -39,9 +39,7 @@ define(function (require, exports, module) {
testPath = extensionPath + "/test/file1.js",
testHtmlPath = extensionPath + "/test/index.html",
testDoc = null,
testHtmlDoc = null,
testEditor,
testHtmlEditor;
testEditor;
/**
* Returns an Editor suitable for use in isolation, given a Document. (Unlike
@@ -320,19 +318,6 @@ define(function (require, exports, module) {
}
/**
* Should be called at the beginning of any tests for hints in an html file.
* Start a test int he index.html test file, instead
* of the file1.js file.
* This switches the document and editor to point to the html file
* and re-inits the hinting session with the html editor
*/
function startHtmlTest() {
testEditor = testHtmlEditor;
testDoc = testHtmlDoc;
JSCodeHints.initializeSession(testEditor, false);
}
describe("JavaScript Code Hinting", function () {
beforeEach(function () {
@@ -340,18 +325,13 @@ define(function (require, exports, module) {
DocumentManager.getDocumentForPath(testPath).done(function (doc) {
testDoc = doc;
});
DocumentManager.getDocumentForPath(testHtmlPath).done(function (doc) {
testHtmlDoc = doc;
});
waitsFor(function () {
return testDoc !== null && testHtmlDoc !== null;
return testDoc !== null;
}, "Unable to open test document", 10000);
// create Editor instance (containing a CodeMirror instance)
runs(function () {
testEditor = createMockEditor(testDoc);
testHtmlEditor = createMockEditor(testHtmlDoc);
JSCodeHints.initializeSession(testEditor, false);
});
});
@@ -751,43 +731,6 @@ define(function (require, exports, module) {
});
});
it("basic codehints in html file", function () {
var start = { line: 30, ch: 9 },
end = { line: 30, ch: 11 };
startHtmlTest();
testDoc.replaceRange("x.", start, start);
testEditor.setCursorPos(end);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
runs(function () {
hintsPresentOrdered(hintObj, ["charAt", "charCodeAt", "concat", "indexOf"]);
});
});
it("function type hint in html file", function () {
var start = { line: 29, ch: 12 };
startHtmlTest();
testEditor.setCursorPos(start);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
runs(function () {
hintsPresentExact(hintObj, ["foo(a: number) -> string"]);
});
});
it("jump-to-def in html file", function () {
var start = { line: 29, ch: 10 };
startHtmlTest();
testEditor.setCursorPos(start);
runs(function () {
editorJumped({line: 18, ch: 20});
});
});
it("should insert hint as [\"my-key\"] since 'my-key' is not a valid property name", function () {
var start = { line: 49, ch: 0 },
middle = { line: 49, ch: 5 },
@@ -836,6 +779,66 @@ define(function (require, exports, module) {
});
});
});
describe("JavaScript Code Hinting in a HTML file", function () {
beforeEach(function () {
DocumentManager.getDocumentForPath(testHtmlPath).done(function (doc) {
testDoc = doc;
});
waitsFor(function () {
return testDoc !== null;
}, "Unable to open test document", 10000);
// create Editor instance (containing a CodeMirror instance)
runs(function () {
testEditor = createMockEditor(testDoc);
JSCodeHints.initializeSession(testEditor, false);
});
});
afterEach(function () {
// The following call ensures that the document is reloaded
// from disk before each test
DocumentManager.closeAll();
SpecRunnerUtils.destroyMockEditor(testDoc);
testEditor = null;
testDoc = null;
});
it("basic codehints in html file", function () {
var start = { line: 30, ch: 9 },
end = { line: 30, ch: 11 };
testDoc.replaceRange("x.", start, start);
testEditor.setCursorPos(end);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
runs(function () {
hintsPresentOrdered(hintObj, ["charAt", "charCodeAt", "concat", "indexOf"]);
});
});
it("function type hint in html file", function () {
var start = { line: 29, ch: 12 };
testEditor.setCursorPos(start);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
runs(function () {
hintsPresentExact(hintObj, ["foo(a: number) -> string"]);
});
});
it("jump-to-def in html file", function () {
var start = { line: 29, ch: 10 };
testEditor.setCursorPos(start);
runs(function () {
editorJumped({line: 18, ch: 20});
});
});
});
});
});