* add components * example: componentize header * fix choo SSR * example: componentize footer * example: fix footer * update component cache asserts * componentize todos * reorder example dir * fix example tests * fix dep check test * Add garbage collection of unused components * Apply args when calling identity * update to new component preview * update nanocomponent * fix cache err name * remove static methods from example * restore app.emit() function * public API tests * offset component cache iteration by 2 * whitelist contents of component folder (#643) * allow lru number arg * fix lint typo
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
var tape = require('tape')
|
|
var h = require('hyperscript')
|
|
|
|
var html = require('./html')
|
|
var raw = require('./html/raw')
|
|
var choo = require('./')
|
|
|
|
tape('should render on the server with bel', function (t) {
|
|
var app = choo()
|
|
app.route('/', function (state, emit) {
|
|
var strong = '<strong>Hello filthy planet</strong>'
|
|
return html`
|
|
<p>${raw(strong)}</p>
|
|
`
|
|
})
|
|
var res = app.toString('/')
|
|
var exp = '<p><strong>Hello filthy planet</strong></p>'
|
|
t.equal(res.toString().trim(), exp, 'result was OK')
|
|
t.end()
|
|
})
|
|
|
|
tape('should render on the server with hyperscript', function (t) {
|
|
var app = choo()
|
|
app.route('/', function (state, emit) {
|
|
return h('p', h('strong', 'Hello filthy planet'))
|
|
})
|
|
var res = app.toString('/')
|
|
var exp = '<p><strong>Hello filthy planet</strong></p>'
|
|
t.equal(res.toString().trim(), exp, 'result was OK')
|
|
t.end()
|
|
})
|
|
|
|
tape('should expose a public API', function (t) {
|
|
var app = choo()
|
|
|
|
t.equal(typeof app.route, 'function', 'app.route prototype method exists')
|
|
t.equal(typeof app.toString, 'function', 'app.toString prototype method exists')
|
|
t.equal(typeof app.start, 'function', 'app.start prototype method exists')
|
|
t.equal(typeof app.mount, 'function', 'app.mount prototype method exists')
|
|
t.equal(typeof app.emitter, 'object', 'app.emitter prototype method exists')
|
|
|
|
t.equal(typeof app.emit, 'function', 'app.emit instance method exists')
|
|
t.equal(typeof app.router, 'object', 'app.router instance object exists')
|
|
t.equal(typeof app.state, 'object', 'app.state instance object exists')
|
|
|
|
t.end()
|
|
})
|