From: Eduardo San Martin Morote Date: Mon, 25 Nov 2019 15:03:52 +0000 (+0100) Subject: test: adapt ssr tests X-Git-Tag: v0.0.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f3b36c447cc02b3ebd3370dcc781eda7433763d;p=thirdparty%2Fvuejs%2Fpinia.git test: adapt ssr tests --- diff --git a/__tests__/ssr/app.spec.ts b/__tests__/ssr/app.spec.ts index 24b537bc..8c78f9b2 100644 --- a/__tests__/ssr/app.spec.ts +++ b/__tests__/ssr/app.spec.ts @@ -9,13 +9,33 @@ describe('classic vue app', () => { rendered: () => {}, } const app = await renderApp(context) - // TODO: is this really here? - context.rendered() // @ts-ignore const html = await renderer.renderToString(app) expect(html).toMatchInlineSnapshot( - `"

Hi anon

Count: 0 x 2 = 0

"` + `"

Hi anon

Count: 1 x 2 = 2

"` + ) + }) + + it('resets the store', async () => { + const context = { + rendered: () => {}, + } + let app = await renderApp(context) + + // @ts-ignore + let html = await renderer.renderToString(app) + expect(html).toMatchInlineSnapshot( + `"

Hi anon

Count: 1 x 2 = 2

"` + ) + + // render again + app = await renderApp(context) + + // @ts-ignore + html = await renderer.renderToString(app) + expect(html).toMatchInlineSnapshot( + `"

Hi anon

Count: 1 x 2 = 2

"` ) }) }) diff --git a/__tests__/ssr/app/main.ts b/__tests__/ssr/app/main.ts index f06891f0..96020e2d 100644 --- a/__tests__/ssr/app/main.ts +++ b/__tests__/ssr/app/main.ts @@ -11,6 +11,8 @@ export function createApp() { clear() const store = useStore() + store.state.counter++ + // create the app instance, injecting both the router and the store const app = new Vue({ render: h => h(App), diff --git a/__tests__/tds/store.test-d.ts b/__tests__/tds/store.test-d.ts index a401b359..a052ac7f 100644 --- a/__tests__/tds/store.test-d.ts +++ b/__tests__/tds/store.test-d.ts @@ -1,9 +1,16 @@ 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)