preact-assert-equal-jsx
v1.0.0
Published
assertEqualJSX for Preact
Downloads
17
Readme
This is a port of assert-equal-jsx for Preact.
assertEqualJSX
API
assertEqualJSX(jsx, jsx, [opts]);
Example
assertEqualJSX(
<MyComponent/>,
// should equal:
<div className="my-component">
<h1>Hello world</h1>
<p>Look at this amazing component</p>
</div>
)
opts.sanitize
function sanitizeId(str) {
return str.replace(/my-component-id-(\d+)/ig, 'my-component-id-0');
}
assertEqualJSX(
<div id="my-component-id-314159265"/>,
// should equal:
<div id="my-component-id-0">,
// with sanitization:
{
sanitize: sanitizeId
}
)