1.0.3 • Published 4 years ago

html-generators v1.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

html-generators

Build Status

Coverage Status

HTML generator based on chance-generators, intended for use in property based tests with unexpected-check or unchecked.

const { htmlString } = require("html-generators");

console.log(htmlString.first());
<html tabindex="-233" lang="T"><head contenteditable="false"><title contenteditable="false"></title><link integrity="bhrYrGYj" href="cm^CtnX3xF"></link></head><body draggable="true"></body></html>

Example with unexpected-check

Check that html-minifier always produces shorter output:

const htmlMinifier = require("html-minifier");
const { htmlString } = require("html-generators");
const expect = require("unexpected")
  .clone()
  .use(require("unexpected-check"));

expect.addAssertion(
  "<string> to be shorter than <string>",
  (expect, subject, value) => {
    expect(subject.length, "to be less than", value.length);
  }
);

describe("html-minifier", function() {
  it("should always produce a shorter string", function() {
    expect(
      html => {
        expect(
          htmlMinifier.minify(html, {
            removeEmptyAttributes: true,
            removeAttributeQuotes: true
          }),
          "to be shorter than",
          html
        );
      },
      "to be valid for all",
      htmlString
    );
  });
});