Files
buuh/tests/browser/rehydration.js
T

39 lines
919 B
JavaScript
Raw Normal View History

2016-07-03 15:08:48 -07:00
const test = require('tape')
const onReady = require('document-ready')
2016-07-04 09:09:43 -07:00
const append = require('append-child')
2016-12-11 19:35:29 +01:00
const mount = require('../../mount')
2016-07-03 15:08:48 -07:00
const choo = require('../../')
2016-12-11 19:35:29 +01:00
const html = require('../../html')
2016-07-03 15:08:48 -07:00
test('rehydration', function (t) {
t.plan(2)
const app = choo()
2016-12-11 19:35:29 +01:00
const node = html`
<section id="app-root">
<div id="app-root">Hello squirrel!</span>
</section>
`
2016-07-03 15:08:48 -07:00
2016-12-11 19:35:29 +01:00
app.router(['/', function (state, prev, send) {
return html`
<section id="app-root">
<div onclick=${() => send('test')}>Hello world!</span>
</section>
`
}])
2016-07-03 15:08:48 -07:00
2016-12-11 19:35:29 +01:00
append(node)
const tree = app.start()
mount('#app-root', tree)
2016-07-03 15:08:48 -07:00
onReady(function () {
2016-12-11 19:35:29 +01:00
const newNode = document.querySelector('#app-root')
const el = newNode.children[0]
t.equal(el.innerHTML, 'Hello world!', 'same as it ever was')
t.equal(typeof el.onclick, 'function', 'attaches dom listeners')
2016-07-03 15:08:48 -07:00
})
})