Fix tests

This commit is contained in:
Wolfgang Huß 2021-08-05 17:57:48 +02:00
parent e3ea3e1733
commit 41252785d2
14 changed files with 79 additions and 48 deletions

View File

@ -21,12 +21,6 @@ describe('DonationInfo.vue', () => {
const Wrapper = () => mount(DonationInfo, { mocks, localVue })
it('includes a link to the ocelot.social donations website', () => {
expect(Wrapper().find('a').attributes('href')).toBe(
'https://ocelot-social.herokuapp.com/donations',
)
})
it('displays a call to action button', () => {
expect(Wrapper().find('.base-button').text()).toBe('donations.donate-now')
})

View File

@ -1,9 +1,9 @@
import { config, mount } from '@vue/test-utils'
import InviteButton from './InviteButton.vue'
import LoginButton from './LoginButton.vue'
config.stubs['v-popover'] = '<span><slot /></span>'
describe('InviteButton.vue', () => {
describe('LoginButton.vue', () => {
let wrapper
let mocks
let propsData
@ -22,7 +22,7 @@ describe('InviteButton.vue', () => {
describe('mount', () => {
const Wrapper = () => {
return mount(InviteButton, { mocks, propsData })
return mount(LoginButton, { mocks, propsData })
}
beforeEach(() => {
@ -30,24 +30,12 @@ describe('InviteButton.vue', () => {
})
it('renders', () => {
expect(wrapper.contains('.invite-button')).toBe(true)
expect(wrapper.contains('.login-button')).toBe(true)
})
it('open popup', () => {
wrapper.find('.base-button').trigger('click')
expect(wrapper.contains('.invite-button')).toBe(true)
})
it('invite codes not available', async () => {
wrapper.find('.base-button').trigger('click') // open popup
wrapper.find('.invite-button').trigger('click') // click copy button
expect(mocks.$t).toHaveBeenCalledWith('invite-codes.not-available')
})
it.skip('invite codes copied to clipboard', async () => {
wrapper.find('.base-button').trigger('click') // open popup
wrapper.find('.invite-button').trigger('click') // click copy button
expect(mocks.$t).toHaveBeenCalledWith('invite-codes.not-available')
expect(wrapper.contains('.login-button')).toBe(true)
})
})
})

View File

@ -29,8 +29,8 @@ describe('PageFooter.vue', () => {
wrapper = Wrapper()
})
it('renders four links', () => {
expect(wrapper.findAll('a')).toHaveLength(4)
it('renders five links', () => {
expect(wrapper.findAll('a')).toHaveLength(5)
})
it('renders three nuxt-links', () => {
@ -56,12 +56,12 @@ describe('PageFooter.vue', () => {
beforeEach(async () => {
const links = {
...linksDefault,
ORGANIZATION: { ...linksDefault.ORGANIZATION, externalLink: null },
IMPRINT: { ...linksDefault.IMPRINT, externalLink: null },
TERMS_AND_CONDITIONS: { ...linksDefault.TERMS_AND_CONDITIONS, externalLink: null },
CODE_OF_CONDUCT: { ...linksDefault.CODE_OF_CONDUCT, externalLink: null },
DATA_PRIVACY: { ...linksDefault.DATA_PRIVACY, externalLink: null },
FAQ: { ...linksDefault.FAQ, externalLink: null },
ORGANIZATION: linksDefault.ORGANIZATION.overwrite({ externalLink: null }),
IMPRINT: linksDefault.IMPRINT.overwrite({ externalLink: null }),
TERMS_AND_CONDITIONS: linksDefault.TERMS_AND_CONDITIONS.overwrite({ externalLink: null }),
CODE_OF_CONDUCT: linksDefault.CODE_OF_CONDUCT.overwrite({ externalLink: null }),
DATA_PRIVACY: linksDefault.DATA_PRIVACY.overwrite({ externalLink: null }),
FAQ: linksDefault.FAQ.overwrite({ externalLink: null }),
}
wrapper = Wrapper()
wrapper.setData({ links })
@ -99,21 +99,22 @@ describe('PageFooter.vue', () => {
beforeEach(async () => {
const links = {
...linksDefault,
ORGANIZATION: { ...linksDefault.ORGANIZATION, externalLink: 'https://ocelot.social' },
IMPRINT: { ...linksDefault.IMPRINT, externalLink: 'https://ocelot.social/IMPRINT' },
TERMS_AND_CONDITIONS: {
...linksDefault.TERMS_AND_CONDITIONS,
ORGANIZATION: linksDefault.ORGANIZATION.overwrite({
externalLink: 'https://ocelot.social',
}),
IMPRINT: linksDefault.IMPRINT.overwrite({
externalLink: 'https://ocelot.social/IMPRINT',
}),
TERMS_AND_CONDITIONS: linksDefault.TERMS_AND_CONDITIONS.overwrite({
externalLink: 'https://ocelot.social/TERMS_AND_CONDITIONS',
},
CODE_OF_CONDUCT: {
...linksDefault.CODE_OF_CONDUCT,
}),
CODE_OF_CONDUCT: linksDefault.CODE_OF_CONDUCT.overwrite({
externalLink: 'https://ocelot.social/CODE_OF_CONDUCT',
},
DATA_PRIVACY: {
...linksDefault.DATA_PRIVACY,
}),
DATA_PRIVACY: linksDefault.DATA_PRIVACY.overwrite({
externalLink: 'https://ocelot.social/DATA_PRIVACY',
},
FAQ: { ...linksDefault.FAQ, externalLink: 'https://ocelot.social/FAQ' },
}),
FAQ: linksDefault.FAQ.overwrite({ externalLink: 'https://ocelot.social/FAQ' }),
}
wrapper = Wrapper()
wrapper.setData({ links })

View File

@ -27,11 +27,6 @@
<script>
export default {
name: 'InternalPage',
head() {
return {
title: this.$t(this.pageParams.internalPage.headTitleIdent),
}
},
props: {
pageParams: { type: Object, required: true },
},

View File

@ -1,3 +1,4 @@
import Vuex from 'vuex'
import { config, shallowMount } from '@vue/test-utils'
import Basic from './basic.vue'
@ -8,16 +9,23 @@ config.stubs.nuxt = '<span><slot /></span>'
describe('basic.vue', () => {
let wrapper
let mocks
let store
beforeEach(() => {
mocks = {
$t: jest.fn(),
}
store = new Vuex.Store({
getters: {
'auth/isLoggedIn': () => true,
},
})
})
describe('shallow mount', () => {
const Wrapper = () => {
return shallowMount(Basic, {
store,
mocks,
localVue,
})

View File

@ -9,6 +9,11 @@ export function internalPageMixins(pageParams) {
data() {
return { pageParams }
},
head() {
return {
title: this.$t(this.pageParams.internalPage.headTitleIdent),
}
},
created() {
if (!this.pageParams.isInternalPage) {
// to avoid possible errors, because 'window' is only defined on browser side but not in NodeJS on client side. check for 'typeof window' is neccessary, because if it's not defined at all you can't check for 'window !== undefined' without the same error 'window is undefined'

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('code-of-conduct.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('data-privacy.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('donate.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('faq.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('imprint.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('organization.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('support.vue', () => {
let wrapper
let mocks

View File

@ -5,6 +5,11 @@ import VueMeta from 'vue-meta'
const localVue = global.localVue
localVue.use(VueMeta, { keyName: 'head' })
// avoid: 'Error: Not implemented: navigation (except hash changes)', see https://stackoverflow.com/questions/54090231/how-to-fix-error-not-implemented-navigation-except-hash-changes
const assignMock = jest.fn()
delete window.location
window.location = { assign: assignMock }
describe('terms-and-conditions.vue', () => {
let wrapper
let mocks