define(function(require,exports,module){var Commands=brackets.getModule("command/Commands"),CommandManager=brackets.getModule("command/CommandManager"),MainViewManager=brackets.getModule("view/MainViewManager"),DocumentManager=brackets.getModule("document/DocumentManager"),EditorManager=brackets.getModule("editor/EditorManager"),FileSystem=brackets.getModule("filesystem/FileSystem"),FileUtils=brackets.getModule("file/FileUtils"),PreferencesManager=brackets.getModule("preferences/PreferencesManager"),SpecRunnerUtils=brackets.getModule("spec/SpecRunnerUtils"),JSCodeHints=require("main"),Preferences=brackets.getModule("JSUtils/Preferences"),Session=brackets.getModule("JSUtils/Session"),ScopeManager=brackets.getModule("JSUtils/ScopeManager"),HintUtils=brackets.getModule("JSUtils/HintUtils"),HintUtils2=require("HintUtils2"),ParameterHintProvider,phProvider=new(0,require("ParameterHintsProvider").JSParameterHintsProvider),extensionPath=SpecRunnerUtils.getTestPath("/spec/JSCodeHints-ext-unittest-files/"),testFolder=extensionPath+"basic-test-files/",testPath=extensionPath+"basic-test-files/file1.js",testHtmlPath=extensionPath+"basic-test-files/index.html",testDoc=null,testEditor,preTestText;CommandManager.register("test-file-open",Commands.FILE_OPEN,function(fileInfo){return DocumentManager.getDocumentForPath(fileInfo.fullPath).done(function(doc){MainViewManager._edit(MainViewManager.ACTIVE_PANE,doc)})}),describe("individualrun:JavaScript Code Hinting",function(){function fixPos(pos){return"sticky"in pos||(pos.sticky=null),pos}function expectHints(provider,key){return void 0===key&&(key=null),expect(provider.hasHints(testEditor,key)).toBe(!0),provider.getHints(null)}function expectNoHints(provider,key){void 0===key&&(key=null),expect(provider.hasHints(testEditor,key)).toBe(!1)}function _indexOf(hintList,hint){for(var index=-1,counter=0;counter"}],-1)}),it("should list parameter hint for a source array annotation",async function(){var testPos={line:200,ch:20};testEditor.setCursorPos(testPos),await expectParameterHint([{name:"a",type:"Array."}],0)}),it("should close parameter hint when move off function",async function(){var testPos={line:184,ch:12},endPos={line:184,ch:19};testEditor.setCursorPos(testPos),await expectParameterHint([{name:"other",type:"Array."}],-1),testEditor.setCursorPos(endPos),await expectParameterHintClosed()}),it("should close parameter hint when move off function to another function",async function(){var testPos={line:184,ch:12},newPos={line:181,ch:12};testEditor.setCursorPos(testPos),await expectParameterHint([{name:"other",type:"Array."}],-1),testEditor.setCursorPos(newPos),await expectParameterHintClosed()}),it("should update current parameter as the cursor moves",async function(){var testPos={line:186,ch:19},newPos={line:186,ch:20};testEditor.setCursorPos(testPos),await expectParameterHint([{name:"char",type:"String"},{name:"from",type:"Number",isOptional:!0}],0),testEditor.setCursorPos(newPos),await expectParameterHint([{name:"char",type:"String"},{name:"from",type:"Number",isOptional:!0}],1)}),it("should consider dot a hintable key based on preference",function(){var noHintsOnDot=PreferencesManager.get("jscodehints.noHintsOnDot");testEditor.setCursorPos({line:44,ch:10}),expect(noHintsOnDot).toBeFalsy(),expectHints(JSCodeHints.jsHintProvider,"."),PreferencesManager.set("jscodehints.noHintsOnDot",!0),expectNoHints(JSCodeHints.jsHintProvider,"."),PreferencesManager.set("jscodehints.noHintsOnDot",!!noHintsOnDot)})}),describe("JavaScript Code Hinting in a HTML file",function(){beforeEach(async function(){await setupTest(testHtmlPath,!1)}),afterEach(function(){tearDownTest()}),it("basic codehints in html file",async function(){var start={line:37,ch:9},end={line:37,ch:13};testDoc.replaceRange("x100.",start),testEditor.setCursorPos(end);var hintObj=expectHints(JSCodeHints.jsHintProvider);await hintsPresentOrdered(hintObj,["charAt","charCodeAt","concat","indexOf"])}),it("function type hint in html file",async function(){var start={line:36,ch:12};testEditor.setCursorPos(start),await expectParameterHint([{name:"a",type:"Number"}],0)}),it("should show function type code hint for function in script file inside html file",async function(){var start={line:22,ch:17};testEditor.setCursorPos(start),await expectParameterHint([{name:"a",type:"String"},{name:"b",type:"Number"}],0)}),it("should show function type code hint for function in another script file inside html file",async function(){var start={line:23,ch:17};testEditor.setCursorPos(start),await expectParameterHint([{name:"paramE1",type:"D1"},{name:"paramE2",type:"Number"}],0)}),it("should show global variable in another script file inside html file",async function(){var start={line:27,ch:8},end={line:27,ch:13},testPosStart={line:27,ch:11},testPosEnd={line:27,ch:21};testDoc.replaceRange("arr.m",start),testEditor.setCursorPos(end);var hintObj=expectHints(JSCodeHints.jsHintProvider);await hintsPresent(hintObj,["my-key"]),await selectHint(JSCodeHints.jsHintProvider,hintObj,"my-key"),expect(testDoc.getRange(testPosStart,testPosEnd)).toEql('["my-key"]')}),it("should jump to definition inside html file",async function(){var start={line:36,ch:10};testEditor.setCursorPos(start),await editorJumped({line:19,ch:20})}),it("should jump to funtion definition to loaded file1",async function(){var start={line:22,ch:15};testEditor.setCursorPos(start),await editorJumped({line:33,ch:13})}),it("should jump to funtion definition to loaded file2",async function(){var start={line:23,ch:15};testEditor.setCursorPos(start),await editorJumped({line:6,ch:13})}),it("should jump to property definition to loaded file1",async function(){var start={line:23,ch:28};testEditor.setCursorPos(start),await editorJumped({line:4,ch:16})}),it("should jump to property definition to loaded file2",async function(){var start={line:23,ch:18};testEditor.setCursorPos(start),await editorJumped({line:3,ch:6})})})})});