项目作者: mvasilkov

项目描述 :
Assert the equality of two HTML fragments
高级语言: JavaScript
项目地址: git://github.com/mvasilkov/assert-equal-html.git
创建时间: 2020-04-28T08:34:01Z
项目社区:https://github.com/mvasilkov/assert-equal-html

开源协议:MIT License

下载


assert-equal-html

Assert the equality of two HTML fragments

npm
dependencies


Installation

  1. npm add assert-equal-html

Usage

  1. const { assertEqual } = require('assert-equal-html')
  2. assertEqual(
  3. '<button type="button" class="btn btn-link">Link</button>',
  4. '<button class="btn-link btn" type="button">Link</button>')

The comparison rules are as follows:

  • The DOCTYPE, if present, is ignored
  • HTML comments are also ignored
  • Attributes and class names are sorted
  • ASCII whitespace is stripped and collapsed

ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE.

To strip and collapse ASCII whitespace in a string, replace any sequence of one or more
consecutive code points that are ASCII whitespace in the string with a single U+0020 SPACE
code point, and then remove any leading and trailing ASCII whitespace from that string.

Syntax

assertEqual(actual, expected[, message])

Tests HTML equality between the actual and expected parameters.

assertNotEqual(actual, expected[, message])

Tests HTML inequality between the actual and expected parameters.

License

MIT