add support for hyperscript in choo.toString (#635)
* add failing test for hyperscript (#634) * add support for hyperscript in choo.toString (#634)
This commit is contained in:
@@ -195,7 +195,7 @@ Choo.prototype.toString = function (location, state) {
|
|||||||
this._matchRoute(location)
|
this._matchRoute(location)
|
||||||
var html = this._prerender(this.state)
|
var html = this._prerender(this.state)
|
||||||
assert.ok(html, 'choo.toString: no valid value returned for the route ' + location)
|
assert.ok(html, 'choo.toString: no valid value returned for the route ' + location)
|
||||||
return html.toString()
|
return typeof html.outerHTML === 'string' ? html.outerHTML : html.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
Choo.prototype._matchRoute = function (locationOverride) {
|
Choo.prototype._matchRoute = function (locationOverride) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"bundle-collapser": "^1.2.1",
|
"bundle-collapser": "^1.2.1",
|
||||||
"dependency-check": "^2.8.0",
|
"dependency-check": "^2.8.0",
|
||||||
"discify": "^1.6.0",
|
"discify": "^1.6.0",
|
||||||
|
"hyperscript": "^2.0.2",
|
||||||
"pretty-bytes-cli": "^2.0.0",
|
"pretty-bytes-cli": "^2.0.0",
|
||||||
"spok": "^0.8.1",
|
"spok": "^0.8.1",
|
||||||
"standard": "^10.0.0",
|
"standard": "^10.0.0",
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
var tape = require('tape')
|
var tape = require('tape')
|
||||||
|
var h = require('hyperscript')
|
||||||
|
|
||||||
var html = require('./html')
|
var html = require('./html')
|
||||||
var raw = require('./html/raw')
|
var raw = require('./html/raw')
|
||||||
var choo = require('./')
|
var choo = require('./')
|
||||||
|
|
||||||
tape('should render on the server', function (t) {
|
tape('should render on the server with bel', function (t) {
|
||||||
var app = choo()
|
var app = choo()
|
||||||
app.route('/', function (state, emit) {
|
app.route('/', function (state, emit) {
|
||||||
var strong = '<strong>Hello filthy planet</strong>'
|
var strong = '<strong>Hello filthy planet</strong>'
|
||||||
@@ -17,3 +18,14 @@ tape('should render on the server', function (t) {
|
|||||||
t.equal(res.toString().trim(), exp, 'result was OK')
|
t.equal(res.toString().trim(), exp, 'result was OK')
|
||||||
t.end()
|
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()
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user