mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Code review cleanup - mostly in the unittests
This commit is contained in:
1 parent
c162a75dc8
commit
678ae5aed0
2 files changed
+63
-61
No files matched your search
@@ -311,8 +311,7 @@ define(function (require, exports, module) {
|
||||
// Compute fresh hints if none exist, or if the session
|
||||
// type has changed since the last hint computation
|
||||
if (this.needNewHints(session)) {
|
||||
var offset = session.getOffset(),
|
||||
scopeResponse = ScopeManager.requestHints(session, session.editor.document);
|
||||
var scopeResponse = ScopeManager.requestHints(session, session.editor.document);
|
||||
|
||||
if (scopeResponse.hasOwnProperty("promise")) {
|
||||
var $deferredHints = $.Deferred();
|
||||
|
||||
@@ -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});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user