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')
})
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 () => {
await page.nuxt.navigate('/fetch-error')
expect(await page.$text('p')).toContain('Fetching...')

View File

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