layouts tests working

This commit is contained in:
Moriz Wahl 2023-02-15 11:19:29 +01:00
parent 6eb5ad25af
commit 0eddfd3aa0
4 changed files with 37 additions and 14 deletions

View File

@ -1,10 +1,14 @@
import Vuex from 'vuex'
import { config, shallowMount } from '@vue/test-utils'
import { shallowMount } from '@vue/test-utils'
import Basic from './basic.vue'
const localVue = global.localVue
config.stubs.nuxt = '<span><slot /></span>'
const stubs = {
nuxt: {
template: '<span><slot /></span>',
},
}
describe('basic.vue', () => {
let wrapper
@ -28,6 +32,7 @@ describe('basic.vue', () => {
store,
mocks,
localVue,
stubs,
})
}
@ -36,7 +41,7 @@ describe('basic.vue', () => {
})
it('renders', () => {
expect(wrapper.is('.layout-blank')).toBe(true)
expect(wrapper.classes('layout-blank')).toBe(true)
})
})
})

View File

@ -1,9 +1,13 @@
import { config, shallowMount } from '@vue/test-utils'
import { shallowMount } from '@vue/test-utils'
import Blank from './blank.vue'
const localVue = global.localVue
config.stubs.nuxt = '<span><slot /></span>'
const stubs = {
nuxt: {
template: '<span><slot /></span>',
},
}
describe('blank.vue', () => {
let wrapper
@ -20,6 +24,7 @@ describe('blank.vue', () => {
return shallowMount(Blank, {
mocks,
localVue,
stubs,
})
}
@ -28,7 +33,7 @@ describe('blank.vue', () => {
})
it('renders', () => {
expect(wrapper.is('.layout-blank')).toBe(true)
expect(wrapper.classes('layout-blank')).toBe(true)
})
})
})

View File

@ -1,13 +1,21 @@
import Vuex from 'vuex'
import { config, shallowMount } from '@vue/test-utils'
import { shallowMount } from '@vue/test-utils'
import Default from './default.vue'
const localVue = global.localVue
localVue.directive('scrollTo', jest.fn())
config.stubs.nuxt = '<span><slot /></span>'
config.stubs['client-only'] = '<span><slot /></span>'
config.stubs['nuxt-link'] = '<span><slot /></span>'
const stubs = {
nuxt: {
template: '<span><slot /></span>',
},
'client-only': {
template: '<span><slot /></span>',
},
'nuxt-link': {
template: '<span><slot /></span>',
},
}
describe('default.vue', () => {
let wrapper
@ -38,6 +46,7 @@ describe('default.vue', () => {
store,
mocks,
localVue,
stubs,
})
}
@ -46,7 +55,7 @@ describe('default.vue', () => {
})
it('renders', () => {
expect(wrapper.is('.layout-default')).toBe(true)
expect(wrapper.classes('layout-default')).toBe(true)
})
})
})

View File

@ -1,9 +1,13 @@
import { config, shallowMount } from '@vue/test-utils'
import { shallowMount } from '@vue/test-utils'
import Error from './error.vue'
const localVue = global.localVue
config.stubs['nuxt-link'] = '<span><slot /></span>'
const stubs = {
'nuxt-link': {
template: '<span><slot /></span>',
},
}
describe('error.vue', () => {
let mocks, wrapper
@ -15,7 +19,7 @@ describe('error.vue', () => {
})
const Wrapper = (propsData = {}) => {
return shallowMount(Error, { mocks, propsData, localVue })
return shallowMount(Error, { mocks, propsData, localVue, stubs })
}
describe('shallowMount', () => {