Skip to content

Commit 962cfe3

Browse files
committed
test: ph html lint and integ tests
1 parent ae106ff commit 962cfe3

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

src/extensions/default/HTMLCodeHints/html-lint.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,13 @@ define(function (require, exports, module) {
225225
_reloadOptions();
226226
});
227227

228-
CodeInspection.register("html", {
228+
const registration = {
229229
name: Strings.HTML_LINT_NAME,
230230
scanFileAsync: lintOneFile,
231231
canInspect: function (_fullPath) {
232232
return !prefs.get(PREFS_HTML_LINT_DISABLED);
233233
}
234-
});
234+
};
235+
CodeInspection.register("html", registration);
236+
CodeInspection.register("php", registration);
235237
});

test/spec/Extn-HTMLCodeHints-Lint-integ-test.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
define(function (require, exports, module) {
2525

2626

27-
var SpecRunnerUtils = require("spec/SpecRunnerUtils");
27+
const SpecRunnerUtils = require("spec/SpecRunnerUtils"),
28+
simple1_html = require("text!spec/LiveDevelopment-MultiBrowser-test-files/simple1.html"),
29+
test_php = require("text!spec/LiveDevelopment-MultiBrowser-test-files/htmlOther/test.php");
2830

2931
describe("integration:HTML Lint", function () {
3032
let testProjectsFolder,
31-
Strings = require("strings"),
3233
testWindow,
3334
$,
3435
CodeInspection,
@@ -177,5 +178,22 @@ define(function (require, exports, module) {
177178
await SpecRunnerUtils.deletePathAsync(invalidNameJSON, true, FileSystem);
178179
await SpecRunnerUtils.deletePathAsync(validNameJSON, true, FileSystem);
179180
}, 6000);
181+
182+
const testExtensions = [".htm", ".xhtml", ".jsp", ".asp", ".aspx", ".php"];
183+
for(let testExtension of testExtensions) {
184+
// eslint-disable-next-line no-loop-func
185+
it(`should show html lint error in ${testExtension} files`, async function () {
186+
const testFile = "test_"+testExtension;
187+
const content = testExtension === ".php" ? simple1_html : test_php;
188+
await jsPromise(SpecRunnerUtils.createTextFile(testProjectsFolder + testFile, content, FileSystem));
189+
190+
await awaitsFor(async ()=>{
191+
await _siwtchFilesTo(testFile);
192+
return $("#problems-panel").is(":visible") && $("#problems-panel").text().includes(
193+
"<html> is missing required \"lang\" attribute (element-required-attributes)");
194+
}, "html lint error for "+testFile);
195+
await SpecRunnerUtils.deletePathAsync(testProjectsFolder + testFile, true, FileSystem);
196+
}, 5000);
197+
}
180198
});
181199
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
5+
<h1>My first PHP page</h1>
6+
7+
<?php
8+
echo "Hello World!";
9+
?>
10+
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)