Revert init order change
This commit is contained in:
@@ -138,11 +138,11 @@ Choo.prototype.start = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._setCache(this.state)
|
this._setCache(this.state)
|
||||||
this._matchRoute()
|
|
||||||
this._stores.forEach(function (initStore) {
|
this._stores.forEach(function (initStore) {
|
||||||
initStore(self.state)
|
initStore(self.state)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this._matchRoute()
|
||||||
this._tree = this._prerender(this.state)
|
this._tree = this._prerender(this.state)
|
||||||
assert.ok(this._tree, 'choo.start: no valid DOM node returned for location ' + this.state.href)
|
assert.ok(this._tree, 'choo.start: no valid DOM node returned for location ' + this.state.href)
|
||||||
|
|
||||||
@@ -212,11 +212,11 @@ Choo.prototype.toString = function (location, state) {
|
|||||||
|
|
||||||
var self = this
|
var self = this
|
||||||
this._setCache(this.state)
|
this._setCache(this.state)
|
||||||
this._matchRoute(location)
|
|
||||||
this._stores.forEach(function (initStore) {
|
this._stores.forEach(function (initStore) {
|
||||||
initStore(self.state)
|
initStore(self.state)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
assert(!Array.isArray(html), 'choo.toString: return value was an array for the route ' + location)
|
assert(!Array.isArray(html), 'choo.toString: return value was an array for the route ' + location)
|
||||||
|
|||||||
@@ -191,27 +191,6 @@ tape('state should include location on render', function (t) {
|
|||||||
app.mount(container)
|
app.mount(container)
|
||||||
})
|
})
|
||||||
|
|
||||||
tape('state should include location on store init', function (t) {
|
|
||||||
t.plan(6)
|
|
||||||
var app = choo()
|
|
||||||
var container = init('/foo/bar/file.txt?bin=baz')
|
|
||||||
app.use(store)
|
|
||||||
app.route('/:first/:second/*', function (state, emit) {
|
|
||||||
return html`<div></div>`
|
|
||||||
})
|
|
||||||
app.mount(container)
|
|
||||||
|
|
||||||
function store (state, emit) {
|
|
||||||
var params = { first: 'foo', second: 'bar', wildcard: 'file.txt' }
|
|
||||||
t.equal(state.href, '/foo/bar/file.txt', 'state has href')
|
|
||||||
t.equal(state.route, ':first/:second/*', 'state has route')
|
|
||||||
t.ok(state.hasOwnProperty('params'), 'state has params')
|
|
||||||
t.deepEqual(state.params, params, 'params match')
|
|
||||||
t.ok(state.hasOwnProperty('query'), 'state has query')
|
|
||||||
t.deepEqual(state.query, { bin: 'baz' }, 'query match')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('state should include title', function (t) {
|
tape('state should include title', function (t) {
|
||||||
t.plan(3)
|
t.plan(3)
|
||||||
document.title = 'foo'
|
document.title = 'foo'
|
||||||
|
|||||||
@@ -185,26 +185,6 @@ tape('state should include location on render', function (t) {
|
|||||||
t.end()
|
t.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
tape('state should include location on store init', function (t) {
|
|
||||||
t.plan(6)
|
|
||||||
var app = choo()
|
|
||||||
app.use(store)
|
|
||||||
app.route('/:first/:second/*', function (state, emit) {
|
|
||||||
return html`<div></div>`
|
|
||||||
})
|
|
||||||
app.toString('/foo/bar/file.txt?bin=baz')
|
|
||||||
|
|
||||||
function store (state, emit) {
|
|
||||||
var params = { first: 'foo', second: 'bar', wildcard: 'file.txt' }
|
|
||||||
t.equal(state.href, '/foo/bar/file.txt', 'state has href')
|
|
||||||
t.equal(state.route, ':first/:second/*', 'state has route')
|
|
||||||
t.ok(state.hasOwnProperty('params'), 'state has params')
|
|
||||||
t.deepEqual(state.params, params, 'params match')
|
|
||||||
t.ok(state.hasOwnProperty('query'), 'state has query')
|
|
||||||
t.deepEqual(state.query, { bin: 'baz' }, 'query match')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('state should include cache', function (t) {
|
tape('state should include cache', function (t) {
|
||||||
t.plan(6)
|
t.plan(6)
|
||||||
var app = choo()
|
var app = choo()
|
||||||
|
|||||||
Reference in New Issue
Block a user