Commit 4682d966 authored by David Sveningsson's avatar David Sveningsson

fix(rules): fix handling of invalid void style

fixes #52
parent 6ac2f046
......@@ -50,5 +50,5 @@ This rule takes an optional object:
- `omit` requires end tag to be omitted and disallows self-closing
elements (default).
- `selfclosing` requests self-closing any void element.
- `selfclose` requests self-closing any void element.
- `any` allows both omitting and self-closing elements.
......@@ -132,17 +132,13 @@ describe("rule void", () => {
});
});
describe('configured with style="foobar"', () => {
beforeAll(() => {
htmlvalidate = new HtmlValidate({
rules: { void: ["error", { style: "foobar" }] },
});
});
it('should default to "any"', () => {
const report = htmlvalidate.validateString("<input><input/>");
expect(report).toBeValid();
it("should throw error if configured with invalid value", () => {
htmlvalidate = new HtmlValidate({
rules: { void: ["error", { style: "foobar" }] },
});
expect(() => htmlvalidate.validateString("<input>")).toThrow(
`Invalid style "foobar" for "void" rule`
);
});
it("should contain documentation", () => {
......
......@@ -95,9 +95,10 @@ function parseStyle(name: string): Style {
case "omit":
return Style.AlwaysOmit;
case "selfclose":
case "selfclosing":
return Style.AlwaysSelfclose;
default:
return Style.Any;
throw new Error(`Invalid style "${name}" for "void" rule`);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment