RunKit + npm: hyperhtml

node v8.14.0
endpointsharetweet
const { Document } = require('basichtml'); const sinon = require('sinon'); const test = require('tressa'); const clickFn = sinon.spy(); global.document = new Document(); document.documentElement.innerHTML = ` <head></head> <body> <div id="test"></div> </body> `; const { bind, wire } = require('hyperhtml'); function component(props) { return wire()` <p onclick=${props.clickFn}>${props.text}</p> `; } bind(document.getElementById('test'))` ${[component({ text: 'test', clickFn })]} `; const pTags = document.getElementsByTagName('p'); const renderedComponent = pTags[0]; renderedComponent.click(); test(pTags.length === 1, '<p> length'); test(renderedComponent.textContent === 'test', 'Text content'); test(clickFn.called === true, 'Click');
Created from: https://npm.runkit.com/hyperhtml
Loading…