|
1 | | -/* |
2 | | - * GNU AGPL-3.0 License |
3 | | - * |
4 | | - * Copyright (c) 2021 - present core.ai . All rights reserved. |
5 | | - * Original work Copyright (c) 2013 - 2021 Adobe Systems Incorporated. All rights reserved. |
6 | | - * |
7 | | - * This program is free software: you can redistribute it and/or modify it |
8 | | - * under the terms of the GNU Affero General Public License as published by |
9 | | - * the Free Software Foundation, either version 3 of the License, or |
10 | | - * (at your option) any later version. |
11 | | - * |
12 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
13 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License |
15 | | - * for more details. |
16 | | - * |
17 | | - * You should have received a copy of the GNU Affero General Public License |
18 | | - * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0. |
19 | | - * |
20 | | - */ |
21 | | - |
22 | | -/*global describe, it, expect, beforeAll, afterAll, awaitsForDone, awaits, awaitsFor */ |
23 | | - |
24 | | -define(function (require, exports, module) { |
25 | | - |
26 | | - |
27 | | - var SpecRunnerUtils = brackets.getModule("spec/SpecRunnerUtils"); |
28 | | - |
29 | | - describe("integration:JSHint", function () { |
30 | | - let testProjectsFolder = SpecRunnerUtils.getTestPath("/spec/JSHintExtensionTest-files/"), |
31 | | - testWindow, |
32 | | - $, |
33 | | - CodeInspection; |
34 | | - |
35 | | - var toggleJSLintResults = function () { |
36 | | - $("#status-inspection").triggerHandler("click"); |
37 | | - }; |
38 | | - |
39 | | - beforeAll(async function () { |
40 | | - testWindow = await SpecRunnerUtils.createTestWindowAndRun(); |
41 | | - // Load module instances from brackets.test |
42 | | - $ = testWindow.$; |
43 | | - CodeInspection = testWindow.brackets.test.CodeInspection; |
44 | | - CodeInspection.toggleEnabled(true); |
45 | | - await awaitsFor(()=>testWindow._JsHintExtensionReadyToIntegTest, |
46 | | - "JsHint extension to be loaded", 10000); |
47 | | - }, 30000); |
48 | | - |
49 | | - afterAll(async function () { |
50 | | - testWindow = null; |
51 | | - $ = null; |
52 | | - await SpecRunnerUtils.closeTestWindow(); |
53 | | - }, 30000); |
54 | | - |
55 | | - it("status icon should toggle Errors panel when errors present", async function () { |
56 | | - await SpecRunnerUtils.loadProjectInTestWindow(testProjectsFolder + "valid-config-error"); |
57 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es8.js"]), "open test file with error"); |
58 | | - await awaitsFor(()=>{ |
59 | | - return $("#problems-panel").is(":visible"); |
60 | | - }, "Problems panel to be visible"); |
61 | | - |
62 | | - toggleJSLintResults(); |
63 | | - await awaitsFor(()=>{ |
64 | | - return !$("#problems-panel").is(":visible"); |
65 | | - }, "Problems panel to be hidden"); |
66 | | - |
67 | | - toggleJSLintResults(); |
68 | | - await awaitsFor(()=>{ |
69 | | - return $("#problems-panel").is(":visible"); |
70 | | - }, "Problems panel to be visible"); |
71 | | - }); |
72 | | - |
73 | | - it("should show errors if invalid .jshintrc detected", async function () { |
74 | | - await SpecRunnerUtils.loadProjectInTestWindow(testProjectsFolder + "invalid-config"); |
75 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["no-errors.js"]), "open test file"); |
76 | | - await awaitsFor(()=>{ |
77 | | - return $("#problems-panel").is(":visible"); |
78 | | - }, "Problems panel to be visible"); |
79 | | - }); |
80 | | - |
81 | | - it("should load valid es6 .jshintrc in project", async function () { |
82 | | - await SpecRunnerUtils.loadProjectInTestWindow(testProjectsFolder + "valid-config-es6"); |
83 | | - // es6 file should have no errors in problems panel |
84 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es6.js"]), "open test file es6.js"); |
85 | | - |
86 | | - await awaits(100); |
87 | | - await awaitsFor(()=>{ |
88 | | - return !$("#problems-panel").is(":visible"); |
89 | | - }, "Problems panel to be hidden"); |
90 | | - |
91 | | - // using es8 async feature in es6 jshint mode should have errors in problems panel |
92 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es8.js"]), "open test file es8.js"); |
93 | | - await awaitsFor(()=>{ |
94 | | - return $("#problems-panel").is(":visible"); |
95 | | - }, "Problems panel to be visible"); |
96 | | - }); |
97 | | - |
98 | | - it("should extend valid es6 .jshintrc in project", async function () { |
99 | | - await SpecRunnerUtils.loadProjectInTestWindow(testProjectsFolder + "valid-config-es6-extend"); |
100 | | - // es6 file should have no errors in problems panel |
101 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es6.js"]), "open test file es6.js"); |
102 | | - |
103 | | - await awaits(100); |
104 | | - await awaitsFor(()=>{ |
105 | | - return !$("#problems-panel").is(":visible"); |
106 | | - }, "Problems panel to be hidden"); |
107 | | - |
108 | | - // using es8 async feature in es6 jshint mode should have errors in problems panel |
109 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["es8.js"]), "open test file es8.js"); |
110 | | - await awaitsFor(()=>{ |
111 | | - return $("#problems-panel").is(":visible"); |
112 | | - }, "Problems panel to be visible"); |
113 | | - }); |
114 | | - |
115 | | - it("should show errors if invalid .jshintrc extend file detected", async function () { |
116 | | - await SpecRunnerUtils.loadProjectInTestWindow(testProjectsFolder + "invalid-config-extend"); |
117 | | - await awaitsForDone(SpecRunnerUtils.openProjectFiles(["no-errors.js"]), "open test file"); |
118 | | - await awaitsFor(()=>{ |
119 | | - return $("#problems-panel").is(":visible"); |
120 | | - }, "Problems panel to be visible"); |
121 | | - }); |
122 | | - }); |
123 | | -}); |
0 commit comments