+++ /dev/null
-import renderApp from './app/entry-server'
-import { createRenderer } from 'vue-server-renderer'
-
-const renderer = createRenderer()
-
-// FIXME: add when ssr is available in vue 3
-describe.skip('classic vue app', () => {
- it('renders using the store', async () => {
- const context = {
- rendered: () => {},
- }
- const app = await renderApp(context)
-
- // @ts-ignore
- const 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>"`
- )
- })
-
- 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>"`
- )
- })
-})
+++ /dev/null
-import { defineComponent, computed } from 'vue'
-import { useStore } from './store'
-
-export default defineComponent({
- setup() {
- const store = useStore()
-
- const doubleCount = computed(() => store.state.counter * 2)
- function increment() {
- store.state.counter++
- }
-
- return {
- doubleCount,
- increment,
- state: store.state,
- }
- },
-
- template: `
- <div>
- <h2>Hi {{ state.name }}</h2>
- <p>Count: {{ state.counter }} x 2 = {{ doubleCount }}</p>
- <button @click="increment">Increment</button>
- </div>
- `,
-})
+++ /dev/null
-import { createApp } from './main'
-
-export default function(context: any) {
- return new Promise(resolve => {
- const { app, store } = createApp()
-
- // This `rendered` hook is called when the app has finished rendering
- context.rendered = () => {
- // After the app is rendered, our store is now
- // filled with the state from our components.
- // When we attach the state to the context, and the `template` option
- // is used for the renderer, the state will automatically be
- // serialized and injected into the HTML as `window.__INITIAL_STATE__`.
- context.state = store.state
- }
-
- resolve(app)
- })
-}
+++ /dev/null
-import Vue from 'vue'
-// import VueCompositionApi from '@vue/composition-api'
-import App from './App'
-import { useStore } from './store'
-import { setActiveReq } from '../../../src'
-import { createPinia } from '../../src'
-
-// Done in setup.ts
-// Vue.use(VueCompositionApi)
-
-export function createApp() {
- // create router and store instances
- setActiveReq(createPinia())
- 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),
- })
-
- // expose the app, the router and the store.
- return { app, store }
-}
+++ /dev/null
-import { createStore } from '../../src'
-
-export const useStore = createStore({
- id: 'main',
- state: () => ({
- counter: 0,
- name: 'anon',
- }),
-})