Skip to content

Commit

Permalink
test: add test for -l/--list
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni committed Dec 13, 2021
1 parent 6b7b6be commit d99f24f
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/cli/__snapshots__/htmlhint.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,83 @@ Options:
htmlhint --rulesdir ./rules/
"
`;
exports[`Executable should print rules with --list: stderr 1`] = `""`;
exports[`Executable should print rules with --list: stdout 1`] = `
" All rules:
==================================================
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.
attr-lowercase : All attribute names must be in lowercase.
attr-sorted : Attribute tags must be in proper order.
attr-no-duplication : Elements cannot have duplicate attributes.
attr-unsafe-chars : Attribute values cannot contain unsafe chars.
attr-value-double-quotes : Attribute values must be in double quotes.
attr-value-not-empty : All attributes must have values.
attr-value-single-quotes : Attribute values must be in single quotes.
attr-whitespace : All attributes should be separated by only one space and not have leading/trailing whitespace.
doctype-first : Doctype must be declared first.
doctype-html5 : Invalid doctype. Use: \\"<!DOCTYPE html>\\"
head-script-disabled : The <script> tag cannot be used in a <head> tag.
href-abs-or-rel : An href attribute must be either absolute or relative.
html-lang-require : The lang attribute of an <html> element must be present and should be valid.
id-class-ad-disabled : The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.
id-class-value : The id and class attribute values must meet the specified rules.
id-unique : The value of id attributes must be unique.
inline-script-disabled : Inline script cannot be used.
inline-style-disabled : Inline style cannot be used.
input-requires-label : All [ input ] tags must have a corresponding [ label ] tag.
script-disabled : The <script> tag cannot be used.
space-tab-mixed-disabled : Do not mix tabs and spaces for indentation.
spec-char-escape : Special characters must be escaped.
src-not-empty : The src attribute of an img(script,link) must have a value.
style-disabled : <style> tags cannot be used.
tag-pair : Tag must be paired.
tag-self-close : Empty tags must be self closed.
empty-tag-not-self-closed : Empty tags must not use self closed syntax.
tagname-lowercase : All html element names must be in lowercase.
tagname-specialchars : All special characters must be escaped.
title-require : <title> must be present in <head> tag.
tags-check : Checks html tags.
attr-no-unnecessary-whitespace : No spaces between attribute names and values."
`;
exports[`Executable should print rules with -l: stderr 1`] = `""`;
exports[`Executable should print rules with -l: stdout 1`] = `
" All rules:
==================================================
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.
attr-lowercase : All attribute names must be in lowercase.
attr-sorted : Attribute tags must be in proper order.
attr-no-duplication : Elements cannot have duplicate attributes.
attr-unsafe-chars : Attribute values cannot contain unsafe chars.
attr-value-double-quotes : Attribute values must be in double quotes.
attr-value-not-empty : All attributes must have values.
attr-value-single-quotes : Attribute values must be in single quotes.
attr-whitespace : All attributes should be separated by only one space and not have leading/trailing whitespace.
doctype-first : Doctype must be declared first.
doctype-html5 : Invalid doctype. Use: \\"<!DOCTYPE html>\\"
head-script-disabled : The <script> tag cannot be used in a <head> tag.
href-abs-or-rel : An href attribute must be either absolute or relative.
html-lang-require : The lang attribute of an <html> element must be present and should be valid.
id-class-ad-disabled : The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.
id-class-value : The id and class attribute values must meet the specified rules.
id-unique : The value of id attributes must be unique.
inline-script-disabled : Inline script cannot be used.
inline-style-disabled : Inline style cannot be used.
input-requires-label : All [ input ] tags must have a corresponding [ label ] tag.
script-disabled : The <script> tag cannot be used.
space-tab-mixed-disabled : Do not mix tabs and spaces for indentation.
spec-char-escape : Special characters must be escaped.
src-not-empty : The src attribute of an img(script,link) must have a value.
style-disabled : <style> tags cannot be used.
tag-pair : Tag must be paired.
tag-self-close : Empty tags must be self closed.
empty-tag-not-self-closed : Empty tags must not use self closed syntax.
tagname-lowercase : All html element names must be in lowercase.
tagname-specialchars : All special characters must be escaped.
title-require : <title> must be present in <head> tag.
tags-check : Checks html tags.
attr-no-unnecessary-whitespace : No spaces between attribute names and values."
`;
18 changes: 18 additions & 0 deletions src/cli/htmlhint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,22 @@ describe('Executable', () => {

expect(stderr).toMatchSnapshot('stderr')
})

it(`should print rules with --list`, async () => {
const { exitCode, stdout, stderr } = await run(__dirname, ['--list'])

expect(exitCode).toBe(0)
expect(stdout).toMatchSnapshot('stdout')

expect(stderr).toMatchSnapshot('stderr')
})

it(`should print rules with -l`, async () => {
const { exitCode, stdout, stderr } = await run(__dirname, ['-l'])

expect(exitCode).toBe(0)
expect(stdout).toMatchSnapshot('stdout')

expect(stderr).toMatchSnapshot('stderr')
})
})

0 comments on commit d99f24f

Please sign in to comment.