mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-22 00:19:45 +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')
|
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...')
|
||||||
|
8
test/fixtures/fetch/pages/old-fetch.vue
vendored
8
test/fixtures/fetch/pages/old-fetch.vue
vendored
@ -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
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