Skip to content

Commit d99f24f

Browse files
committed
test: add test for -l/--list
1 parent 6b7b6be commit d99f24f

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

src/cli/__snapshots__/htmlhint.spec.js.snap

+80
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,83 @@ Options:
6565
htmlhint --rulesdir ./rules/
6666
"
6767
`;
68+
69+
exports[`Executable should print rules with --list: stderr 1`] = `""`;
70+
71+
exports[`Executable should print rules with --list: stdout 1`] = `
72+
" All rules:
73+
==================================================
74+
alt-require : The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.
75+
attr-lowercase : All attribute names must be in lowercase.
76+
attr-sorted : Attribute tags must be in proper order.
77+
attr-no-duplication : Elements cannot have duplicate attributes.
78+
attr-unsafe-chars : Attribute values cannot contain unsafe chars.
79+
attr-value-double-quotes : Attribute values must be in double quotes.
80+
attr-value-not-empty : All attributes must have values.
81+
attr-value-single-quotes : Attribute values must be in single quotes.
82+
attr-whitespace : All attributes should be separated by only one space and not have leading/trailing whitespace.
83+
doctype-first : Doctype must be declared first.
84+
doctype-html5 : Invalid doctype. Use: \\"<!DOCTYPE html>\\"
85+
head-script-disabled : The <script> tag cannot be used in a <head> tag.
86+
href-abs-or-rel : An href attribute must be either absolute or relative.
87+
html-lang-require : The lang attribute of an <html> element must be present and should be valid.
88+
id-class-ad-disabled : The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.
89+
id-class-value : The id and class attribute values must meet the specified rules.
90+
id-unique : The value of id attributes must be unique.
91+
inline-script-disabled : Inline script cannot be used.
92+
inline-style-disabled : Inline style cannot be used.
93+
input-requires-label : All [ input ] tags must have a corresponding [ label ] tag.
94+
script-disabled : The <script> tag cannot be used.
95+
space-tab-mixed-disabled : Do not mix tabs and spaces for indentation.
96+
spec-char-escape : Special characters must be escaped.
97+
src-not-empty : The src attribute of an img(script,link) must have a value.
98+
style-disabled : <style> tags cannot be used.
99+
tag-pair : Tag must be paired.
100+
tag-self-close : Empty tags must be self closed.
101+
empty-tag-not-self-closed : Empty tags must not use self closed syntax.
102+
tagname-lowercase : All html element names must be in lowercase.
103+
tagname-specialchars : All special characters must be escaped.
104+
title-require : <title> must be present in <head> tag.
105+
tags-check : Checks html tags.
106+
attr-no-unnecessary-whitespace : No spaces between attribute names and values."
107+
`;
108+
109+
exports[`Executable should print rules with -l: stderr 1`] = `""`;
110+
111+
exports[`Executable should print rules with -l: stdout 1`] = `
112+
" All rules:
113+
==================================================
114+
alt-require : The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.
115+
attr-lowercase : All attribute names must be in lowercase.
116+
attr-sorted : Attribute tags must be in proper order.
117+
attr-no-duplication : Elements cannot have duplicate attributes.
118+
attr-unsafe-chars : Attribute values cannot contain unsafe chars.
119+
attr-value-double-quotes : Attribute values must be in double quotes.
120+
attr-value-not-empty : All attributes must have values.
121+
attr-value-single-quotes : Attribute values must be in single quotes.
122+
attr-whitespace : All attributes should be separated by only one space and not have leading/trailing whitespace.
123+
doctype-first : Doctype must be declared first.
124+
doctype-html5 : Invalid doctype. Use: \\"<!DOCTYPE html>\\"
125+
head-script-disabled : The <script> tag cannot be used in a <head> tag.
126+
href-abs-or-rel : An href attribute must be either absolute or relative.
127+
html-lang-require : The lang attribute of an <html> element must be present and should be valid.
128+
id-class-ad-disabled : The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.
129+
id-class-value : The id and class attribute values must meet the specified rules.
130+
id-unique : The value of id attributes must be unique.
131+
inline-script-disabled : Inline script cannot be used.
132+
inline-style-disabled : Inline style cannot be used.
133+
input-requires-label : All [ input ] tags must have a corresponding [ label ] tag.
134+
script-disabled : The <script> tag cannot be used.
135+
space-tab-mixed-disabled : Do not mix tabs and spaces for indentation.
136+
spec-char-escape : Special characters must be escaped.
137+
src-not-empty : The src attribute of an img(script,link) must have a value.
138+
style-disabled : <style> tags cannot be used.
139+
tag-pair : Tag must be paired.
140+
tag-self-close : Empty tags must be self closed.
141+
empty-tag-not-self-closed : Empty tags must not use self closed syntax.
142+
tagname-lowercase : All html element names must be in lowercase.
143+
tagname-specialchars : All special characters must be escaped.
144+
title-require : <title> must be present in <head> tag.
145+
tags-check : Checks html tags.
146+
attr-no-unnecessary-whitespace : No spaces between attribute names and values."
147+
`;

src/cli/htmlhint.spec.js

+18
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,22 @@ describe('Executable', () => {
5353

5454
expect(stderr).toMatchSnapshot('stderr')
5555
})
56+
57+
it(`should print rules with --list`, async () => {
58+
const { exitCode, stdout, stderr } = await run(__dirname, ['--list'])
59+
60+
expect(exitCode).toBe(0)
61+
expect(stdout).toMatchSnapshot('stdout')
62+
63+
expect(stderr).toMatchSnapshot('stderr')
64+
})
65+
66+
it(`should print rules with -l`, async () => {
67+
const { exitCode, stdout, stderr } = await run(__dirname, ['-l'])
68+
69+
expect(exitCode).toBe(0)
70+
expect(stdout).toMatchSnapshot('stdout')
71+
72+
expect(stderr).toMatchSnapshot('stderr')
73+
})
5674
})

0 commit comments

Comments
 (0)