mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 15:10:58 +00:00
test: add basic test for old-fetch functionality
This commit is contained in:
parent
87dc99e8e5
commit
2091233a6d
@ -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...')
|
||||
|
8
test/fixtures/fetch/pages/old-fetch.vue
vendored
8
test/fixtures/fetch/pages/old-fetch.vue
vendored
@ -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
9
test/fixtures/fetch/store/index.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export const state = () => ({
|
||||
oldFetchData: 'not-set'
|
||||
})
|
||||
|
||||
export const mutations = {
|
||||
setOldFetchData (state, data) {
|
||||
state.oldFetchData = data
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user