diff --git a/.travis.yml b/.travis.yml index bfc6603..87998f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ node_js: -- '4' - '6' +- '7' sudo: false language: node_js env: diff --git a/index.js b/index.js index f199c7c..7cb7841 100644 --- a/index.js +++ b/index.js @@ -58,14 +58,6 @@ function Choo (opts) { bus.prependListener('pushState', updateHistory.bind(null, 'push')) bus.prependListener('replaceState', updateHistory.bind(null, 'replace')) - function updateHistory (mode, href) { - if (href) window.history[mode + 'State']({}, null, href) - bus.emit('render') - setTimeout(function () { - scrollIntoView() - }, 0) - } - if (opts.href !== false) { nanohref(function (location) { var href = location.href @@ -76,6 +68,14 @@ function Choo (opts) { } } + function updateHistory (mode, href) { + if (href) window.history[mode + 'State']({}, null, href) + bus.emit('render') + setTimeout(function () { + scrollIntoView() + }, 0) + } + rerender = nanoraf(function () { if (hasPerformance && timingEnabled) { window.performance.mark('choo:renderStart') diff --git a/test.js b/test.js index 1fe0229..36f2f94 100644 --- a/test.js +++ b/test.js @@ -1 +1,17 @@ -// var tape = require('tape') +var tape = require('tape') + +var html = require('./html') +var choo = require('./') + +tape('should render on the server', function (t) { + var app = choo() + app.route('/', function (state, emit) { + return html` +

Hello filthy planet

+ ` + }) + var res = app.toString('/') + var exp = '

Hello filthy planet

' + t.equal(res.toString(), exp, 'result was OK') + t.end() +})