rendered: () => {},
}
const app = await renderApp(context)
- // TODO: is this really here?
- context.rendered()
// @ts-ignore
const html = await renderer.renderToString(app)
expect(html).toMatchInlineSnapshot(
- `"<div data-server-rendered=\\"true\\"><h2>Hi anon</h2> <p>Count: 0 x 2 = 0</p> <button>Increment</button></div>"`
+ `"<div data-server-rendered=\\"true\\"><h2>Hi anon</h2> <p>Count: 1 x 2 = 2</p> <button>Increment</button></div>"`
+ )
+ })
+
+ it('resets the store', async () => {
+ const context = {
+ rendered: () => {},
+ }
+ let app = await renderApp(context)
+
+ // @ts-ignore
+ let html = await renderer.renderToString(app)
+ expect(html).toMatchInlineSnapshot(
+ `"<div data-server-rendered=\\"true\\"><h2>Hi anon</h2> <p>Count: 1 x 2 = 2</p> <button>Increment</button></div>"`
+ )
+
+ // render again
+ app = await renderApp(context)
+
+ // @ts-ignore
+ html = await renderer.renderToString(app)
+ expect(html).toMatchInlineSnapshot(
+ `"<div data-server-rendered=\\"true\\"><h2>Hi anon</h2> <p>Count: 1 x 2 = 2</p> <button>Increment</button></div>"`
)
})
})
import { createStore } from '../../src'
import { expectType, expectError } from 'tsd'
-const store = createStore('name', () => ({ a: 'on' as 'on' | 'off' }), {
- upper: state => state.a.toUpperCase(),
-})
+const store = createStore(
+ 'name',
+ () => ({ a: 'on' as 'on' | 'off' }),
+ {
+ upper: state => state.a.toUpperCase(),
+ },
+ {
+ doStuff(store, n: number, a: 'on' | 'off') {},
+ }
+)
expectType<{ a: 'on' | 'off' }>(store.state)