Assert that tree exists, fix tests (#358)
* assert that tree exists, fix tests * make assertions more helpful
This commit is contained in:
@@ -16,6 +16,7 @@ test('freeze (default)', function (t) {
|
||||
t.equal(state.foo, 'bar', 'cannot modify property')
|
||||
state.bar = 'baz'
|
||||
t.equal(state.bar, undefined, 'cannot add property')
|
||||
return document.createElement('div')
|
||||
}])
|
||||
|
||||
app.start()
|
||||
@@ -36,6 +37,7 @@ test('noFreeze', function (t) {
|
||||
t.equal(state.foo, '', 'can modify property')
|
||||
state.bar = 'baz'
|
||||
t.equal(state.bar, 'baz', 'can add property')
|
||||
return document.createElement('div')
|
||||
}])
|
||||
|
||||
app.start()
|
||||
|
||||
@@ -12,7 +12,7 @@ test('rehydration', function (t) {
|
||||
|
||||
const node = html`
|
||||
<section id="app-root">
|
||||
<div id="app-root">Hello squirrel!</span>
|
||||
<div>Hello squirrel!</span>
|
||||
</section>
|
||||
`
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ test('routing', function (t) {
|
||||
app.router('/', [
|
||||
['/', function () {
|
||||
t.pass('rendered')
|
||||
return document.createElement('div')
|
||||
}]
|
||||
])
|
||||
|
||||
@@ -139,7 +140,10 @@ test('routing', function (t) {
|
||||
})
|
||||
|
||||
const app = choo({ href: false })
|
||||
app.router(['/', () => t.pass('rendered')])
|
||||
app.router(['/', function () {
|
||||
t.pass('rendered')
|
||||
return document.createElement('div')
|
||||
}])
|
||||
app.start()
|
||||
})
|
||||
|
||||
@@ -152,30 +156,14 @@ test('routing', function (t) {
|
||||
app.router({ default: '/users/123' }, [
|
||||
['/users', [
|
||||
['/:user', function (state) {
|
||||
t.deepEqual(state.params, {user: '123'})
|
||||
t.deepEqual(state.location.params, {user: '123'})
|
||||
return document.createElement('div')
|
||||
}]
|
||||
]]
|
||||
])
|
||||
|
||||
app.start()
|
||||
})
|
||||
|
||||
t.test('prev.params always exists', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
const choo = require('../..')
|
||||
const app = choo()
|
||||
|
||||
app.router('/users/123', (route) => [
|
||||
route('/users', [
|
||||
route('/:user', function (state, prev) {
|
||||
t.ok(prev.params)
|
||||
})
|
||||
])
|
||||
])
|
||||
|
||||
app.start()
|
||||
})
|
||||
})
|
||||
|
||||
function resetLocation () {
|
||||
|
||||
Reference in New Issue
Block a user