Files
buuh/test.js
T

48 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-05-24 13:02:33 +02:00
var tape = require('tape')
var h = require('hyperscript')
2017-05-24 13:02:33 +02:00
var html = require('./html')
2017-09-19 19:43:37 +01:00
var raw = require('./html/raw')
2017-05-24 13:02:33 +02:00
var choo = require('./')
tape('should render on the server with bel', function (t) {
2017-05-24 13:02:33 +02:00
var app = choo()
app.route('/', function (state, emit) {
2017-09-19 19:43:37 +01:00
var strong = '<strong>Hello filthy planet</strong>'
2017-05-24 13:02:33 +02:00
return html`
2017-09-19 19:43:37 +01:00
<p>${raw(strong)}</p>
2017-05-24 13:02:33 +02:00
`
})
var res = app.toString('/')
2017-09-19 19:43:37 +01:00
var exp = '<p><strong>Hello filthy planet</strong></p>'
t.equal(res.toString().trim(), exp, 'result was OK')
2017-05-24 13:02:33 +02:00
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()
})
2018-03-30 18:19:06 +02:00
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()
})