test: add basic test for old-fetch functionality

This commit is contained in:
pooya parsa 2020-03-13 19:20:10 +01:00
parent 87dc99e8e5
commit 2091233a6d
3 changed files with 19 additions and 4 deletions

View File

@ -35,6 +35,12 @@ describe('basic browser', () => {
expect(await page.$text('pre')).toContain('pi0') expect(await page.$text('pre')).toContain('pi0')
}) })
test('/old-fetch', async () => {
await page.nuxt.navigate('/old-fetch')
const storeState = await page.nuxt.storeState()
expect(storeState).toMatchObject({ oldFetchData: 'old-fetch' })
})
test('/fetch-error', async () => { test('/fetch-error', async () => {
await page.nuxt.navigate('/fetch-error') await page.nuxt.navigate('/fetch-error')
expect(await page.$text('p')).toContain('Fetching...') expect(await page.$text('p')).toContain('Fetching...')

View File

@ -1,13 +1,13 @@
<template> <template>
<div> <div id="old-fetch">
Display a warning in the console oldFetchData: {{ $store.state.oldFetchData }}
</div> </div>
</template> </template>
<script> <script>
export default { export default {
async fetch (context) { fetch ({ store, route }) {
// Should display a warning store.commit('setOldFetchData', route.name)
}, },
data () { data () {
return { return {

9
test/fixtures/fetch/store/index.js vendored Normal file
View File

@ -0,0 +1,9 @@
export const state = () => ({
oldFetchData: 'not-set'
})
export const mutations = {
setOldFetchData (state, data) {
state.oldFetchData = data
}
}