forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathintegration-tests.js
More file actions
1 lines (1 loc) · 2.78 KB
/
Copy pathintegration-tests.js
File metadata and controls
1 lines (1 loc) · 2.78 KB
1
define(function(require,exports,module){const SpecRunnerUtils=brackets.getModule("spec/SpecRunnerUtils"),CASES=[{file:"a.js",line:0,ch:3,content:"/**\nfunction add(a, b) {\n}\n",expect:["@param {*} a","@param {*} b","@returns {*}"]},{file:"b.ts",line:0,ch:3,content:"/**\nfunction add(a: number, b: number): number {\n}\n",expect:["@param a","@param b","@returns"],absent:["@param {","{number}"]},{file:"c.ts",line:0,ch:3,content:"/**\nfunction run(items: T[], cb: (x: T) => void): Promise<number> {\n}\n",expect:["@param items","@param cb","@returns"],absent:["@param {","{T[]}","{*}"]},{file:"a.php",line:1,ch:3,content:"<?php\n/**\nfunction f($a) {\n}\n",expect:["@param mixed $a","@return mixed"]},{file:"A.java",line:1,ch:7,content:"class T {\n /**\n int f(int a) {\n }\n}\n",expect:["@param a","@return"]},{file:"a.cpp",line:0,ch:3,content:"/**\nint f(int a) {\n}\n",expect:["@param a","@return"]},{file:"a.py",line:1,ch:7,content:'def f(a):\n """\n',expect:['"""',"Args:","a:"]}];describe("integration:DocCommentHints",function(){let testWindow,$,CommandManager,Commands,EditorManager,FileSystem,tempDir;function $docHint(){return $(".codehint-menu:visible li a").filter(function(){return $(this).find(".doc-comment-hint").length>0})}beforeAll(async function(){testWindow=await SpecRunnerUtils.createTestWindowAndRun(),$=testWindow.$,CommandManager=testWindow.brackets.test.CommandManager,Commands=testWindow.brackets.test.Commands,EditorManager=testWindow.brackets.test.EditorManager,FileSystem=testWindow.brackets.test.FileSystem,tempDir=await SpecRunnerUtils.getTempDirectory(),await SpecRunnerUtils.ensureExistsDirAsync(tempDir);for(const tc of CASES)await jsPromise(SpecRunnerUtils.createTextFile(tempDir+"/"+tc.file,tc.content,FileSystem));await SpecRunnerUtils.loadProjectInTestWindow(tempDir)},3e4),afterAll(async function(){testWindow=$=CommandManager=Commands=EditorManager=FileSystem=null,await SpecRunnerUtils.closeTestWindow()},3e4),CASES.forEach(function(tc){it("shows the popup and inserts the right doc comment for "+tc.file,async function(){await awaitsForDone(SpecRunnerUtils.openProjectFiles([tc.file]),"open "+tc.file);const editor=EditorManager.getActiveEditor();editor.setCursorPos(tc.line,tc.ch),CommandManager.execute(Commands.SHOW_CODE_HINTS),await awaitsFor(function(){return $docHint().length>0},"doc-comment hint popup for "+tc.file,5e3);const $a=$docHint();$a.first().trigger("mousedown"),$a.first().trigger("click"),await awaitsFor(function(){const text=editor.document.getText();return tc.expect.every(function(frag){return-1!==text.indexOf(frag)})},"inserted doc comment for "+tc.file,5e3);const text=editor.document.getText();tc.expect.forEach(function(frag){expect(-1!==text.indexOf(frag)).toBe(!0)}),(tc.absent||[]).forEach(function(frag){expect(text.indexOf(frag)).toBe(-1)})},15e3)})})});