[major] choo v4 (#352)
* location: change url on location:setLocation - [ ] don't break hashing - [ ] allow not changing the url fixup! move fns around fixup! add search string * app.start: clean * walk: add * location: update arg calls * fixup! location: update * uri-wrap: fix thunking * router: update to latest sheet-router (#239) * router: update to latest sheet-router * tests: fix for latest version * tests: fix SSR * tests: fix history * tests: spruce up * docs: update example * examples: update * deps: bump sheet-router * 4.0.0-0 * chore(changelog): 4.0.0 (#211) * feat(api:) arg order (#268) * s/data, state/state, data/ * feat(api): swap arguments * fix(href): fix routing (#271) * feat(http): remove (#269) * feat(router): enable hash routing (#273) * deps: fix mount * 4.0.0-1 * feat(mount): copy {script,link} tags * 4.0.0-2 * fix(mount): forEach -> for Lol can't use forEach * fix(router): use state.location.href (#282) * fix(mount): use deep node clone * 4.0.0-3 * fix(deps): remove hash-match * 4.0.0-4 * fix(mount): return node * 4.0.0-5 * fix(router): check if a hash is a valid selector (#339) * 4.0.0-6 * fix(router): pass params on newstate (#343) * 4.0.0-7 * feat(docs): update for 4.0.0 (#320) * feat(docs): update for 4.0.0 * docs: update router example in readme (#337) * chore(changelog): update for v4 (#351)
This commit is contained in:
+15
-35
@@ -8,9 +8,7 @@ test('server', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
const app = choo()
|
||||
app.router((route) => [
|
||||
route('/', () => view`<h1>Hello Tokyo!</h1>`)
|
||||
])
|
||||
app.router(['/', () => view`<h1>Hello Tokyo!</h1>`])
|
||||
|
||||
const html = app.toString('/')
|
||||
const expected = '<h1>Hello Tokyo!</h1>'
|
||||
@@ -21,9 +19,7 @@ test('server', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
const app = choo()
|
||||
app.router((route) => [
|
||||
route('/', () => minDocument.createElement('div'))
|
||||
])
|
||||
app.router(['/', () => minDocument.createElement('div')])
|
||||
|
||||
const html = app.toString('/')
|
||||
const expected = '<div></div>'
|
||||
@@ -34,11 +30,9 @@ test('server', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
const app = choo()
|
||||
app.router((route) => [
|
||||
route('/', function (state, prev, send) {
|
||||
return view`<h1>meow meow ${state.message}</h1>`
|
||||
})
|
||||
])
|
||||
app.router(['/', (state, prev, send) => {
|
||||
return view`<h1>meow meow ${state.message}</h1>`
|
||||
}])
|
||||
|
||||
const html = app.toString('/', { message: 'nyan!' })
|
||||
const expected = '<h1>meow meow nyan!</h1>'
|
||||
@@ -50,11 +44,9 @@ test('server', function (t) {
|
||||
|
||||
const app = choo()
|
||||
app.model({ state: { bin: 'baz', beep: 'boop' } })
|
||||
app.router((route) => [
|
||||
route('/', function (state, prev, send) {
|
||||
return view`<h1>${state.foo} ${state.bin} ${state.beep}</h1>`
|
||||
})
|
||||
])
|
||||
app.router(['/', (state, prev, send) => {
|
||||
return view`<h1>${state.foo} ${state.bin} ${state.beep}</h1>`
|
||||
}])
|
||||
|
||||
const state = { foo: 'bar!', beep: 'beep' }
|
||||
const html = app.toString('/', state)
|
||||
@@ -70,13 +62,11 @@ test('server', function (t) {
|
||||
namespace: 'hello',
|
||||
state: { bin: 'baz', beep: 'boop' }
|
||||
})
|
||||
app.router((route) => [
|
||||
route('/', function (state, prev, send) {
|
||||
return view`
|
||||
<h1>${state.hello.foo} ${state.hello.bin} ${state.hello.beep}</h1>
|
||||
`
|
||||
})
|
||||
])
|
||||
app.router(['/', (state, prev, send) => {
|
||||
return view`
|
||||
<h1>${state.hello.foo} ${state.hello.bin} ${state.hello.beep}</h1>
|
||||
`
|
||||
}])
|
||||
|
||||
const state = {
|
||||
hello: {
|
||||
@@ -93,12 +83,7 @@ test('server', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
const app = choo()
|
||||
app.router((route) => [
|
||||
route('/', function (state, prev, send) {
|
||||
send('hey!')
|
||||
})
|
||||
])
|
||||
|
||||
app.router(['/', (state, prev, send) => send('hey!')])
|
||||
t.throws(app.toString.bind(null), /route must be a string/)
|
||||
})
|
||||
|
||||
@@ -106,12 +91,7 @@ test('server', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
const app = choo()
|
||||
app.router((route) => [
|
||||
route('/', function (state, prev, send) {
|
||||
send('hey!')
|
||||
})
|
||||
])
|
||||
|
||||
app.router(['/', (state, prev, send) => send('hey!')])
|
||||
const msg = /send\(\) cannot be called/
|
||||
t.throws(app.toString.bind(null, '/', { message: 'nyan!' }), msg)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user