Merge branch 'test3' of https://github.com/jodyzhang/brackets into jody-test3

Conflicts:
	src/extensions/default/JavaScriptCodeHints/unittests.js
This commit is contained in:
dloverin committed 2013-06-10 11:25:44 -04:00
commit 8df8808553
3 files changed
+321 -6

No files matched your search

@@ -38,14 +38,17 @@ define(function (require, exports, module) {
UnitTestReporter = brackets.getModule("test/UnitTestReporter"),
JSCodeHints = require("main"),
Preferences = require("Preferences"),
ScopeManager = require("ScopeManager");
ScopeManager = require("ScopeManager"),
HintUtils = require("HintUtils");
var extensionPath = FileUtils.getNativeModuleDirectoryPath(module),
testPath = extensionPath + "/unittest-files/basic-test-files/file1.js",
testHtmlPath = extensionPath + "/unittest-files/basic-test-files/index.html",
testDoc = null,
testEditor,
preTestText;
preTestText,
testWindow,
self = this;
CommandManager.register("test-file-open", Commands.FILE_OPEN, function (fileInfo) {
// Register a command for FILE_OPEN, which the jump to def code will call
@@ -352,12 +355,36 @@ define(function (require, exports, module) {
// The following call ensures that the document is reloaded
// from disk before each test
DocumentManager.closeAll();
SpecRunnerUtils.destroyMockEditor(testDoc);
if (testDoc !== null) {
SpecRunnerUtils.destroyMockEditor(testDoc);
}
testEditor = null;
testDoc = null;
}
function setupWithTestWindow(testFile) {
runs(function () {
SpecRunnerUtils.createTestWindowAndRun(self, function (w) {
testWindow = w;
// Load module instances from brackets.test
CommandManager = testWindow.brackets.test.CommandManager;
Commands = testWindow.brackets.test.Commands;
EditorManager = testWindow.brackets.test.EditorManager;
DocumentManager = testWindow.brackets.test.DocumentManager;
});
});
runs(function () {
var promise = CommandManager.execute(Commands.FILE_OPEN, {fullPath: testFile});
waitsForDone(promise, "Open " + testPath + " into working set");
});
}
function tearDownTestWindow() {
SpecRunnerUtils.closeTestWindow();
}
describe("JavaScript Code Hinting Basic", function () {
beforeEach(function () {
@@ -711,9 +738,10 @@ define(function (require, exports, module) {
it("should list hints for string, as string assigned to 's', 's' assigned to 'r' and 'r' assigned to 't'", function () {
var start = { line: 26, ch: 0 },
middle = { line: 26, ch: 2 };
middle = { line: 26, ch: 6 };
testDoc.replaceRange("t.", start, start);
// pad spaces here as tern has issue,without space, no code hint
testDoc.replaceRange(" t.", start);
testEditor.setCursorPos(middle);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
runs(function () {
@@ -1459,5 +1487,180 @@ define(function (require, exports, module) {
});
});
});
describe("regression tests", function () {
afterEach(function () {
tearDownTest();
});
// Test maybe valid javascript identifier
xit("#3558:should return true for valid identifier, false for invalid one", function () {
var identifierList = ["ᾩ", "ĦĔĽĻŎ", "〱〱〱〱", "जावास्क्रि",
"KingGeorgeⅦ", "π", "ಠ_ಠ", "\u006C\u006F\u006C\u0077\u0061\u0074",
"price_9̶9̶_89", "$_3423", "TRUE", "FALSE", "IV"];
var invalidIdentifierList = [" break", "\tif", "\ntrade"];
invalidIdentifierList.forEach(function (element) {
var result = HintUtils.maybeIdentifier(element);
expect(result).toBe(false);
});
identifierList.forEach(function (element) {
var result = HintUtils.maybeIdentifier(element);
expect(result).toBe(true);
});
});
});
describe("JavaScript Code Hinting with test.html file", function () {
var testFile = extensionPath + "/unittest-files/basic-test-files/test.html";
beforeEach(function () {
setupTest(testFile, true);
});
afterEach(function () {
tearDownTest();
});
// issue #3915
xit("should read function name has double byte chars", function () {
var start = { line: 15, ch: 8 },
testPos = { line: 15, ch: 10 };
runs(function () {
testEditor.setCursorPos(start);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
hintsPresentExact(hintObj, ["fun測试"]);
});
runs(function () {
testEditor.setCursorPos(testPos);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
hintsPresentExact(hintObj, ["fun測试()"]);
});
});
it("should jump to function name with double byte chars", function () {
var start = { line: 16, ch: 9 };
testEditor.setCursorPos(start);
runs(function () {
editorJumped({line: 12, ch: 20});
});
});
// issue #3915
xit("should read function name has non ascii chars", function () {
var start = { line: 16, ch: 16 };
runs(function () {
testEditor.setCursorPos(start);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
hintsPresentExact(hintObj, ["frenchçProp()"]);
});
});
it("should jump to function name with non ascii chars", function () {
var start = { line: 16, ch: 12 };
testEditor.setCursorPos(start);
runs(function () {
editorJumped({line: 12, ch: 20});
});
});
});
describe("JavaScript Code Hinting in quick editor", function () {
var testFile = extensionPath + "/unittest-files/basic-test-files/test.html";
beforeEach(function () {
setupWithTestWindow(testFile);
});
afterEach(tearDownTestWindow);
// framework issue
xit("should see code hint lists in quick editor", function () {
var start = { line: 17, ch: 10 },
testPos = { line: 32, ch: 22};
var previousEditor;
runs(function () {
previousEditor = EditorManager.getActiveEditor();
var openQuickEditor = SpecRunnerUtils.toggleQuickEditAtOffset(EditorManager.getCurrentFullEditor(), start);
waitsForDone(openQuickEditor, "Open quick editor");
JSCodeHints.initializeSession(EditorManager.getActiveEditor(), previousEditor, true);
});
runs(function () {
testEditor = EditorManager.getActiveEditor();
testEditor.setCursorPos(testPos);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
hintsPresentExact(hintObj, ["getMonthName(mo: number)"]);
});
});
it("should see jump to definition on varialbe working in quick editor", function () {
var start = { line: 17, ch: 10 },
testPos = { line: 33, ch: 7},
testJumpPos = { line: 33, ch: 5},
jumpPos = {line: 3, ch: 6};
var previousEditor;
runs(function () {
previousEditor = EditorManager.getActiveEditor();
var openQuickEditor = SpecRunnerUtils.toggleQuickEditAtOffset(EditorManager.getCurrentFullEditor(), start);
waitsForDone(openQuickEditor, "Open quick editor");
JSCodeHints.initializeSession(EditorManager.getActiveEditor(), previousEditor, true);
});
runs(function () {
testEditor = EditorManager.getActiveEditor();
testEditor.setCursorPos(testPos);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
hintsPresentExact(hintObj, ["propA"]);
});
runs(function () {
testEditor = EditorManager.getActiveEditor();
testEditor.setCursorPos(testJumpPos);
editorJumped(jumpPos);
});
});
// framework issue
xit("should see jump to definition on method working in quick editor", function () {
var start = { line: 19, ch: 13 },
testPos = { line: 56, ch: 18},
testPos2 = { line: 56, ch: 12},
jumpPos = {line: 59, ch: 21};
var previousEditor;
runs(function () {
previousEditor = EditorManager.getActiveEditor();
var openQuickEditor = SpecRunnerUtils.toggleQuickEditAtOffset(EditorManager.getCurrentFullEditor(), start);
waitsForDone(openQuickEditor, "Open quick editor");
JSCodeHints.initializeSession(EditorManager.getActiveEditor(), previousEditor, true);
});
runs(function () {
testEditor = EditorManager.getActiveEditor();
testEditor.setCursorPos(testPos);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
hintsPresentExact(hintObj, ["testTryCatch()"]);
});
runs(function () {
testEditor = EditorManager.getActiveEditor();
testEditor.setCursorPos(testPos2);
editorJumped(jumpPos);
});
});
});
});
});