mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
get most components working
This commit is contained in:
parent
038bae5571
commit
4ce5bdd6fa
@ -1,11 +1,13 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import AvatarMenu from './AvatarMenu.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
config.stubs['router-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
'router-link': true,
|
||||
}
|
||||
|
||||
describe('AvatarMenu.vue', () => {
|
||||
let propsData, getters, wrapper, mocks
|
||||
@ -34,7 +36,7 @@ describe('AvatarMenu.vue', () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return mount(AvatarMenu, { propsData, localVue, store, mocks })
|
||||
return mount(AvatarMenu, { propsData, localVue, store, mocks, stubs })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import CommentCard from './CommentCard.vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
const localVue = global.localVue
|
||||
localVue.directive('scrollTo', jest.fn())
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
|
||||
describe('CommentCard.vue', () => {
|
||||
let propsData, mocks, stubs, getters, wrapper, Wrapper
|
||||
|
||||
@ -46,6 +43,8 @@ describe('CommentCard.vue', () => {
|
||||
}
|
||||
stubs = {
|
||||
ContentViewer: true,
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
@ -56,7 +55,9 @@ describe('CommentCard.vue', () => {
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
Wrapper = () => {
|
||||
const store = new Vuex.Store({
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import CommentList from './CommentList'
|
||||
import Vuex from 'vuex'
|
||||
import Vue from 'vue'
|
||||
@ -8,10 +8,6 @@ const localVue = global.localVue
|
||||
localVue.filter('truncate', (string) => string)
|
||||
localVue.directive('scrollTo', jest.fn())
|
||||
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
|
||||
describe('CommentList.vue', () => {
|
||||
let mocks, store, wrapper, propsData, stubs
|
||||
|
||||
@ -72,7 +68,10 @@ describe('CommentList.vue', () => {
|
||||
},
|
||||
}
|
||||
stubs = {
|
||||
EditorContent: "<div class='stub'></div>",
|
||||
EditorContent: true,
|
||||
'v-popover': true,
|
||||
'nuxt-link': true,
|
||||
'client-only': true,
|
||||
}
|
||||
})
|
||||
|
||||
@ -92,7 +91,9 @@ describe('CommentList.vue', () => {
|
||||
})
|
||||
|
||||
describe('scrollToAnchor mixin', () => {
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
describe('$route.hash !== `#comments`', () => {
|
||||
it('skips $scrollTo', () => {
|
||||
|
||||
@ -52,7 +52,7 @@ describe('ComponentSlider.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBe(true)
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('click on next Button', async () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount, createLocalVue } from '@vue/test-utils'
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import VTooltip from 'v-tooltip'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
@ -10,7 +10,11 @@ localVue.use(Styleguide)
|
||||
localVue.use(VTooltip)
|
||||
localVue.use(Vuex)
|
||||
|
||||
config.stubs['router-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'router-link': {
|
||||
template: '<span><slot /></span>',
|
||||
},
|
||||
}
|
||||
|
||||
let getters, mutations, mocks, menuToggle, openModalSpy
|
||||
|
||||
@ -36,7 +40,7 @@ describe('ContentMenu.vue', () => {
|
||||
'auth/isAdmin': () => false,
|
||||
}
|
||||
|
||||
const openContentMenu = (values = {}) => {
|
||||
const openContentMenu = async (values = {}) => {
|
||||
const store = new Vuex.Store({ mutations, getters })
|
||||
const wrapper = mount(ContentMenu, {
|
||||
propsData: {
|
||||
@ -45,16 +49,17 @@ describe('ContentMenu.vue', () => {
|
||||
mocks,
|
||||
store,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
menuToggle = wrapper.find('[data-test="content-menu-button"]')
|
||||
menuToggle.trigger('click')
|
||||
await menuToggle.trigger('click')
|
||||
return wrapper
|
||||
}
|
||||
|
||||
describe('owner of contribution', () => {
|
||||
let wrapper
|
||||
beforeEach(() => {
|
||||
wrapper = openContentMenu({
|
||||
beforeEach(async () => {
|
||||
wrapper = await openContentMenu({
|
||||
isOwner: true,
|
||||
resourceType: 'contribution',
|
||||
resource: {
|
||||
@ -86,9 +91,9 @@ describe('ContentMenu.vue', () => {
|
||||
})
|
||||
|
||||
describe('admin can', () => {
|
||||
it('pin unpinned post', () => {
|
||||
it('pin unpinned post', async () => {
|
||||
getters['auth/isAdmin'] = () => true
|
||||
const wrapper = openContentMenu({
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'contribution',
|
||||
resource: {
|
||||
@ -111,8 +116,8 @@ describe('ContentMenu.vue', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('unpin pinned post', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('unpin pinned post', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'contribution',
|
||||
resource: {
|
||||
@ -135,11 +140,11 @@ describe('ContentMenu.vue', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('can delete another user', () => {
|
||||
it('can delete another user', async () => {
|
||||
getters['auth/user'] = () => {
|
||||
return { id: 'some-user', slug: 'some-user' }
|
||||
}
|
||||
const wrapper = openContentMenu({
|
||||
const wrapper = await openContentMenu({
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
id: 'another-user',
|
||||
@ -161,8 +166,8 @@ describe('ContentMenu.vue', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('can not delete the own account', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can not delete the own account', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
id: 'some-user',
|
||||
@ -179,8 +184,8 @@ describe('ContentMenu.vue', () => {
|
||||
|
||||
describe('owner of comment can', () => {
|
||||
let wrapper
|
||||
beforeEach(() => {
|
||||
wrapper = openContentMenu({
|
||||
beforeEach(async () => {
|
||||
wrapper = await openContentMenu({
|
||||
isOwner: true,
|
||||
resourceType: 'comment',
|
||||
resource: {
|
||||
@ -208,10 +213,10 @@ describe('ContentMenu.vue', () => {
|
||||
})
|
||||
|
||||
describe('reporting', () => {
|
||||
it('a post of another user is possible', () => {
|
||||
it('a post of another user is possible', async () => {
|
||||
getters['auth/isAdmin'] = () => false
|
||||
getters['auth/isModerator'] = () => false
|
||||
const wrapper = openContentMenu({
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'contribution',
|
||||
resource: {
|
||||
@ -227,8 +232,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('report')
|
||||
})
|
||||
|
||||
it('a comment of another user is possible', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('a comment of another user is possible', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'comment',
|
||||
resource: {
|
||||
@ -244,8 +249,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('report')
|
||||
})
|
||||
|
||||
it('another user is possible', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('another user is possible', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
@ -261,8 +266,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('report')
|
||||
})
|
||||
|
||||
it('another organization is possible', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('another organization is possible', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'organization',
|
||||
resource: {
|
||||
@ -280,10 +285,10 @@ describe('ContentMenu.vue', () => {
|
||||
})
|
||||
|
||||
describe('moderator', () => {
|
||||
it('can disable posts', () => {
|
||||
it('can disable posts', async () => {
|
||||
getters['auth/isAdmin'] = () => false
|
||||
getters['auth/isModerator'] = () => true
|
||||
const wrapper = openContentMenu({
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'contribution',
|
||||
resource: {
|
||||
@ -300,8 +305,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('disable')
|
||||
})
|
||||
|
||||
it('can disable comments', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can disable comments', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'comment',
|
||||
resource: {
|
||||
@ -318,8 +323,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('disable')
|
||||
})
|
||||
|
||||
it('can disable users', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can disable users', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
@ -336,8 +341,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('disable')
|
||||
})
|
||||
|
||||
it('can disable organizations', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can disable organizations', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'organization',
|
||||
resource: {
|
||||
@ -354,8 +359,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('disable')
|
||||
})
|
||||
|
||||
it('can release posts', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can release posts', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'contribution',
|
||||
resource: {
|
||||
@ -372,8 +377,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('release')
|
||||
})
|
||||
|
||||
it('can release comments', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can release comments', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'comment',
|
||||
resource: {
|
||||
@ -390,8 +395,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('release')
|
||||
})
|
||||
|
||||
it('can release users', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can release users', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
@ -408,8 +413,8 @@ describe('ContentMenu.vue', () => {
|
||||
expect(openModalSpy).toHaveBeenCalledWith('release')
|
||||
})
|
||||
|
||||
it('can release organizations', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can release organizations', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'organization',
|
||||
resource: {
|
||||
@ -428,10 +433,10 @@ describe('ContentMenu.vue', () => {
|
||||
})
|
||||
|
||||
describe('user', () => {
|
||||
it('can access settings', () => {
|
||||
it('can access settings', async () => {
|
||||
getters['auth/isAdmin'] = () => false
|
||||
getters['auth/isModerator'] = () => false
|
||||
const wrapper = openContentMenu({
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: true,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
@ -448,8 +453,8 @@ describe('ContentMenu.vue', () => {
|
||||
).toBe('/settings')
|
||||
})
|
||||
|
||||
it('can mute other users', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can mute other users', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
@ -472,8 +477,8 @@ describe('ContentMenu.vue', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('can unmute muted users', () => {
|
||||
const wrapper = openContentMenu({
|
||||
it('can unmute muted users', async () => {
|
||||
const wrapper = await openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import ContributionForm from './ContributionForm.vue'
|
||||
|
||||
import Vuex from 'vuex'
|
||||
@ -11,9 +11,11 @@ global.MutationObserver = MutationObserver
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
'v-popover': true,
|
||||
}
|
||||
|
||||
describe('ContributionForm.vue', () => {
|
||||
let wrapper, postTitleInput, expectedParams, cancelBtn, mocks, propsData
|
||||
@ -88,6 +90,7 @@ describe('ContributionForm.vue', () => {
|
||||
localVue,
|
||||
store,
|
||||
propsData,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -115,9 +115,9 @@ describe('DeleteData.vue', () => {
|
||||
enableContributionDeletionCheckbox = wrapper.find(
|
||||
'[data-test="contributions-deletion-checkbox"]',
|
||||
)
|
||||
enableContributionDeletionCheckbox.trigger('click')
|
||||
enableContributionDeletionCheckbox.setChecked(true)
|
||||
enableCommentDeletionCheckbox = wrapper.find('[data-test="comments-deletion-checkbox"]')
|
||||
enableCommentDeletionCheckbox.trigger('click')
|
||||
enableCommentDeletionCheckbox.setChecked(true)
|
||||
deleteAccountBtn.trigger('click')
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@ -133,7 +133,7 @@ describe('DeleteData.vue', () => {
|
||||
enableContributionDeletionCheckbox = wrapper.find(
|
||||
'[data-test="contributions-deletion-checkbox"]',
|
||||
)
|
||||
enableContributionDeletionCheckbox.trigger('click')
|
||||
enableContributionDeletionCheckbox.setChecked(true)
|
||||
deleteAccountBtn.trigger('click')
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@ -147,7 +147,7 @@ describe('DeleteData.vue', () => {
|
||||
|
||||
it("deletes a user's comments if requested", () => {
|
||||
enableCommentDeletionCheckbox = wrapper.find('[data-test="comments-deletion-checkbox"]')
|
||||
enableCommentDeletionCheckbox.trigger('click')
|
||||
enableCommentDeletionCheckbox.setChecked(true)
|
||||
deleteAccountBtn.trigger('click')
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
@ -35,7 +35,7 @@ describe('Editor.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
it('renders', () => {
|
||||
expect(Wrapper().is('div')).toBe(true)
|
||||
expect(Wrapper().element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
describe('given a piece of text', () => {
|
||||
|
||||
@ -160,7 +160,7 @@ describe('EmbedComponent.vue', () => {
|
||||
|
||||
describe('sets permanently', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.find('input[type=checkbox]').trigger('click')
|
||||
wrapper.find('input[type=checkbox]').setChecked(true)
|
||||
wrapper.find('[data-test="play-now-button"]').trigger('click')
|
||||
})
|
||||
|
||||
|
||||
@ -19,7 +19,9 @@ describe('EnterNonce ', () => {
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
Wrapper = () => {
|
||||
return mount(EnterNonce, {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import GroupForm from './GroupForm.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
const propsData = {
|
||||
update: false,
|
||||
@ -25,7 +27,7 @@ describe('GroupForm', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(GroupForm, { propsData, mocks, localVue })
|
||||
return mount(GroupForm, { propsData, mocks, localVue, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { config, shallowMount } from '@vue/test-utils'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
|
||||
import Hashtag from './Hashtag'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('Hashtag', () => {
|
||||
let id
|
||||
@ -15,6 +17,7 @@ describe('Hashtag', () => {
|
||||
propsData: {
|
||||
id,
|
||||
},
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ describe('HashtagsFilter.vue', () => {
|
||||
|
||||
it('renders a card', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.is('.base-card')).toBe(true)
|
||||
expect(wrapper.classes('base-card')).toBe(true)
|
||||
})
|
||||
|
||||
describe('click clear search button', () => {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import InviteButton from './InviteButton.vue'
|
||||
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'v-popover': true,
|
||||
}
|
||||
|
||||
describe('InviteButton.vue', () => {
|
||||
let wrapper
|
||||
@ -22,7 +24,7 @@ describe('InviteButton.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(InviteButton, { mocks, propsData })
|
||||
return mount(InviteButton, { mocks, propsData, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
|
||||
import LocaleSwitch from './LocaleSwitch.vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
describe('LocaleSwitch.vue', () => {
|
||||
let wrapper, mocks, computed, deutschLanguageItem, getters
|
||||
@ -65,7 +67,7 @@ describe('LocaleSwitch.vue', () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return mount(LocaleSwitch, { mocks, localVue, computed, store })
|
||||
return mount(LocaleSwitch, { mocks, localVue, computed, store, stubs })
|
||||
}
|
||||
|
||||
describe('with current user', () => {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import LoginButton from './LoginButton.vue'
|
||||
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'v-popover': true,
|
||||
}
|
||||
|
||||
describe('LoginButton.vue', () => {
|
||||
let wrapper
|
||||
@ -22,7 +24,7 @@ describe('LoginButton.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(LoginButton, { mocks, propsData })
|
||||
return mount(LoginButton, { mocks, propsData, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -2,15 +2,17 @@ import Vue from 'vue'
|
||||
import LoginForm from './LoginForm.vue'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import Vuex from 'vuex'
|
||||
import { config, mount, createLocalVue } from '@vue/test-utils'
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
config.stubs['locale-switch'] = '<span><slot /></span>'
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
'locale-switch': true,
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
const authUserMock = jest.fn().mockReturnValue({ activeCategories: [] })
|
||||
|
||||
@ -46,7 +48,7 @@ describe('LoginForm', () => {
|
||||
error: jest.fn(),
|
||||
},
|
||||
}
|
||||
return mount(LoginForm, { mocks, localVue, propsData, store })
|
||||
return mount(LoginForm, { mocks, localVue, propsData, store, stubs })
|
||||
}
|
||||
|
||||
describe('fill in email and password and submit', () => {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import MasonryGridItem from './MasonryGridItem'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['ds-grid-item'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'ds-grid-item': true,
|
||||
}
|
||||
|
||||
describe('MasonryGridItem', () => {
|
||||
let wrapper
|
||||
@ -11,34 +13,34 @@ describe('MasonryGridItem', () => {
|
||||
describe('given an imageAspectRatio', () => {
|
||||
it('sets the initial rowSpan to 13 when the ratio is higher than 1.3', () => {
|
||||
const propsData = { imageAspectRatio: 2 }
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData })
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData, stubs })
|
||||
|
||||
expect(wrapper.vm.rowSpan).toBe(13)
|
||||
})
|
||||
|
||||
it('sets the initial rowSpan to 15 when the ratio is between 1.3 and 1', () => {
|
||||
const propsData = { imageAspectRatio: 1.1 }
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData })
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData, stubs })
|
||||
|
||||
expect(wrapper.vm.rowSpan).toBe(15)
|
||||
})
|
||||
|
||||
it('sets the initial rowSpan to 18 when the ratio is between 1 and 0.7', () => {
|
||||
const propsData = { imageAspectRatio: 0.7 }
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData })
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData, stubs })
|
||||
|
||||
expect(wrapper.vm.rowSpan).toBe(18)
|
||||
})
|
||||
|
||||
it('sets the initial rowSpan to 25 when the ratio is lower than 0.7', () => {
|
||||
const propsData = { imageAspectRatio: 0.3 }
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData })
|
||||
wrapper = mount(MasonryGridItem, { localVue, propsData, stubs })
|
||||
expect(wrapper.vm.rowSpan).toBe(25)
|
||||
})
|
||||
|
||||
describe('given no aspect ratio', () => {
|
||||
it('sets the initial rowSpan to 8 when not given an imageAspectRatio', () => {
|
||||
wrapper = mount(MasonryGridItem, { localVue })
|
||||
wrapper = mount(MasonryGridItem, { localVue, stubs })
|
||||
expect(wrapper.vm.rowSpan).toBe(8)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { config, shallowMount, mount } from '@vue/test-utils'
|
||||
import { shallowMount, mount } from '@vue/test-utils'
|
||||
|
||||
import ConfirmModal from './ConfirmModal.vue'
|
||||
import { postMenuModalsData } from '~/components/utils/PostHelpers'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'sweetalert-icon': true,
|
||||
}
|
||||
|
||||
describe('ConfirmModal.vue', () => {
|
||||
let Wrapper
|
||||
@ -41,6 +43,7 @@ describe('ConfirmModal.vue', () => {
|
||||
propsData,
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -90,10 +93,13 @@ describe('ConfirmModal.vue', () => {
|
||||
propsData,
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
describe('given post id', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import { config, mount, shallowMount } from '@vue/test-utils'
|
||||
import { mount, shallowMount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import DeleteUserModal from './DeleteUserModal.vue'
|
||||
const localVue = global.localVue
|
||||
config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
|
||||
const stubs = {
|
||||
'sweetalert-icon': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
localVue.use(DeleteUserModal)
|
||||
|
||||
@ -49,6 +52,7 @@ describe('DeleteUserModal.vue', () => {
|
||||
mocks,
|
||||
store,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -74,9 +78,12 @@ describe('DeleteUserModal.vue', () => {
|
||||
mocks,
|
||||
store,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
describe('given another user', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -102,7 +102,9 @@ describe('DisableModal.vue', () => {
|
||||
localVue,
|
||||
})
|
||||
}
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
describe('given id', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { config, shallowMount, mount } from '@vue/test-utils'
|
||||
import { shallowMount, mount } from '@vue/test-utils'
|
||||
import ReportModal from './ReportModal.vue'
|
||||
import Vue from 'vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'sweetalert-icon': true,
|
||||
}
|
||||
|
||||
describe('ReportModal.vue', () => {
|
||||
let wrapper
|
||||
@ -39,6 +41,7 @@ describe('ReportModal.vue', () => {
|
||||
propsData,
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -109,13 +112,16 @@ describe('ReportModal.vue', () => {
|
||||
propsData,
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(Wrapper().is('div')).toBe(true)
|
||||
expect(Wrapper().element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
describe('given id', () => {
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import { config, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import Notification from './Notification.vue'
|
||||
|
||||
import Vuex from 'vuex'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
|
||||
describe('Notification', () => {
|
||||
let stubs
|
||||
let getters
|
||||
@ -20,6 +18,7 @@ describe('Notification', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
'client-only': true,
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, shallowMount, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { shallowMount, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import NotificationList from './NotificationList'
|
||||
import Notification from '../Notification/Notification'
|
||||
import Vuex from 'vuex'
|
||||
@ -9,9 +9,6 @@ const localVue = global.localVue
|
||||
|
||||
localVue.filter('truncate', (string) => string)
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
|
||||
describe('NotificationList.vue', () => {
|
||||
let wrapper
|
||||
let mocks
|
||||
@ -33,6 +30,8 @@ describe('NotificationList.vue', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
'client-only': true,
|
||||
'v-popover': true,
|
||||
}
|
||||
propsData = { notifications }
|
||||
})
|
||||
@ -44,6 +43,7 @@ describe('NotificationList.vue', () => {
|
||||
mocks,
|
||||
store,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import { config, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import NotificationMenu from './NotificationMenu'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
localVue.filter('truncate', (string) => string)
|
||||
|
||||
config.stubs.dropdown = '<span class="dropdown"><slot :toggleMenu="() => null" /></span>'
|
||||
|
||||
describe('NotificationMenu.vue', () => {
|
||||
let wrapper
|
||||
let mocks
|
||||
@ -23,6 +21,8 @@ describe('NotificationMenu.vue', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
UserTeaser: true,
|
||||
'client-only': true,
|
||||
}
|
||||
})
|
||||
|
||||
@ -38,13 +38,13 @@ describe('NotificationMenu.vue', () => {
|
||||
|
||||
it('renders as link without counter', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.is('a.notifications-menu')).toBe(true)
|
||||
expect(wrapper.classes('notifications-menu')).toBe(true)
|
||||
expect(() => wrapper.get('.count')).toThrow()
|
||||
})
|
||||
|
||||
it('no dropdown is rendered', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.contains('.dropdown')).toBe(false)
|
||||
expect(wrapper.find('.dropdown').exists()).toBe(false)
|
||||
})
|
||||
|
||||
describe('given only read notifications', () => {
|
||||
@ -73,13 +73,13 @@ describe('NotificationMenu.vue', () => {
|
||||
|
||||
it('renders as link without counter', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.is('a.notifications-menu')).toBe(true)
|
||||
expect(wrapper.classes('notifications-menu')).toBe(true)
|
||||
expect(() => wrapper.get('.count')).toThrow()
|
||||
})
|
||||
|
||||
it('no dropdown is rendered', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.contains('.dropdown')).toBe(false)
|
||||
expect(wrapper.find('.dropdown').exists()).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@ -101,6 +101,14 @@ describe('NotificationMenu.vue', () => {
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
from: {
|
||||
title: 'Title',
|
||||
author: {
|
||||
id: 'reporter',
|
||||
slug: 'reporter',
|
||||
name: 'reporter',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'notification-42',
|
||||
@ -115,6 +123,14 @@ describe('NotificationMenu.vue', () => {
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
from: {
|
||||
title: 'Title',
|
||||
author: {
|
||||
id: 'reporter',
|
||||
slug: 'reporter',
|
||||
name: 'reporter',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'notification-43',
|
||||
@ -129,6 +145,14 @@ describe('NotificationMenu.vue', () => {
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
from: {
|
||||
title: 'Title',
|
||||
author: {
|
||||
id: 'reporter',
|
||||
slug: 'reporter',
|
||||
name: 'reporter',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
|
||||
import Vuex from 'vuex'
|
||||
import NotificationsTable from './NotificationsTable'
|
||||
@ -8,8 +8,6 @@ const localVue = global.localVue
|
||||
|
||||
localVue.filter('truncate', (string) => string)
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
|
||||
describe('NotificationsTable.vue', () => {
|
||||
let wrapper, mocks, propsData, stubs
|
||||
const postNotification = notifications[0]
|
||||
@ -21,6 +19,7 @@ describe('NotificationsTable.vue', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
'client-only': true,
|
||||
}
|
||||
propsData = {}
|
||||
})
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import PageFooter from './PageFooter.vue'
|
||||
import linksDefault from '~/constants/links.js'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': {
|
||||
template: '<span class="nuxt-link"><slot /></span>',
|
||||
},
|
||||
}
|
||||
|
||||
describe('PageFooter.vue', () => {
|
||||
let mocks
|
||||
@ -21,7 +25,7 @@ describe('PageFooter.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(PageFooter, { mocks, localVue })
|
||||
return mount(PageFooter, { mocks, localVue, stubs })
|
||||
}
|
||||
|
||||
describe('links.js', () => {
|
||||
|
||||
@ -90,9 +90,8 @@ describe('ChangePassword.vue', () => {
|
||||
})
|
||||
|
||||
describe('submit form', () => {
|
||||
beforeEach(async (done) => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.find('form').trigger('submit')
|
||||
done()
|
||||
})
|
||||
|
||||
it('calls changePassword mutation', () => {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import ChangePassword from './ChangePassword'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'sweetalert-icon': true,
|
||||
}
|
||||
|
||||
describe('ChangePassword ', () => {
|
||||
let wrapper
|
||||
@ -27,13 +29,16 @@ describe('ChangePassword ', () => {
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
Wrapper = () => {
|
||||
return mount(ChangePassword, {
|
||||
mocks,
|
||||
propsData,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Request from './Request'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
|
||||
describe('Request', () => {
|
||||
let wrapper, Wrapper, mocks, stubs
|
||||
|
||||
@ -27,11 +23,16 @@ describe('Request', () => {
|
||||
}
|
||||
stubs = {
|
||||
LocaleSwitch: "<div class='stub'></div>",
|
||||
'sweetalert-icon': true,
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
Wrapper = () => {
|
||||
return mount(Request, {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, shallowMount, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { shallowMount, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
|
||||
import Vuex from 'vuex'
|
||||
|
||||
@ -6,9 +6,6 @@ import PostTeaser from './PostTeaser.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
|
||||
describe('PostTeaser', () => {
|
||||
let store
|
||||
let stubs
|
||||
@ -35,6 +32,8 @@ describe('PostTeaser', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
'client-only': true,
|
||||
'v-popover': true,
|
||||
}
|
||||
mocks = {
|
||||
$t: jest.fn(),
|
||||
@ -77,7 +76,9 @@ describe('PostTeaser', () => {
|
||||
spy.mockReset()
|
||||
})
|
||||
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
describe('test Post callbacks', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Signup, { SignupMutation } from './Signup'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'sweetalert-icon': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('Signup', () => {
|
||||
let wrapper
|
||||
@ -28,13 +30,16 @@ describe('Signup', () => {
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
Wrapper = () => {
|
||||
return mount(Signup, {
|
||||
mocks,
|
||||
propsData,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ describe('RelativeDateTime', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(Wrapper().is('span')).toBe(true)
|
||||
expect(Wrapper().element.tagName).toBe('SPAN')
|
||||
})
|
||||
|
||||
describe("locale == 'en'", () => {
|
||||
|
||||
@ -100,7 +100,9 @@ describe('ReleaseModal.vue', () => {
|
||||
})
|
||||
}
|
||||
|
||||
beforeEach(jest.useFakeTimers)
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers()
|
||||
})
|
||||
|
||||
describe('given id', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import SocialMedia from './SocialMedia.vue'
|
||||
|
||||
config.stubs['ds-space'] = '<span><slot /></span>'
|
||||
config.stubs['ds-text'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'ds-space': true,
|
||||
'ds-text': true,
|
||||
}
|
||||
|
||||
describe('SocialMedia.vue', () => {
|
||||
let propsData
|
||||
@ -18,7 +20,7 @@ describe('SocialMedia.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(SocialMedia, { propsData, mocks })
|
||||
return mount(SocialMedia, { propsData, mocks, stubs })
|
||||
}
|
||||
|
||||
describe('socialMedia card title', () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import SearchResults from './SearchResults'
|
||||
import helpers from '~/storybook/helpers'
|
||||
@ -9,8 +9,10 @@ const localVue = global.localVue
|
||||
|
||||
localVue.directive('scrollTo', jest.fn())
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('SearchResults', () => {
|
||||
let mocks, getters, propsData, wrapper
|
||||
@ -18,7 +20,7 @@ describe('SearchResults', () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return mount(SearchResults, { mocks, localVue, propsData, store })
|
||||
return mount(SearchResults, { mocks, localVue, propsData, store, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import TabNavigation from './TabNavigation'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
describe('TabNavigation', () => {
|
||||
let mocks, propsData, wrapper
|
||||
const Wrapper = () => {
|
||||
return mount(TabNavigation, { mocks, localVue, propsData })
|
||||
return mount(TabNavigation, { mocks, localVue, propsData, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import FiledReportsTable from './FiledReportsTable'
|
||||
import { reports } from '~/components/features/ReportList/ReportList.story.js'
|
||||
@ -7,8 +7,6 @@ const localVue = global.localVue
|
||||
|
||||
localVue.filter('truncate', (string) => string)
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
|
||||
describe('FiledReportsTable.vue', () => {
|
||||
let wrapper, mocks, propsData, stubs, filed
|
||||
|
||||
@ -18,6 +16,7 @@ describe('FiledReportsTable.vue', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
'client-only': true,
|
||||
}
|
||||
propsData = {}
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import helpers from '~/storybook/helpers'
|
||||
@ -6,9 +6,11 @@ import FollowList from './FollowList.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['ds-space'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'ds-space': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
const user = {
|
||||
...helpers.fakeUser()[0],
|
||||
@ -45,6 +47,7 @@ describe('FollowList.vue', () => {
|
||||
$t: jest.fn((str) => str),
|
||||
},
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
|
||||
beforeAll(() => {
|
||||
@ -138,11 +141,11 @@ describe('FollowList.vue', () => {
|
||||
})
|
||||
|
||||
it('renders the user-teasers as an overflowing list', () => {
|
||||
expect(wrapper.find('.--overflow').is('ul')).toBe(true)
|
||||
expect(wrapper.find('.--overflow').element.tagName).toBe('UL')
|
||||
})
|
||||
|
||||
it('renders a filter text input', () => {
|
||||
expect(wrapper.find('[name="followingFilter"]').is('input')).toBe(true)
|
||||
expect(wrapper.find('[name="followingFilter"]').element.tagName).toBe('INPUT')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import ReportList from './ReportList'
|
||||
import { reports } from './ReportList.story'
|
||||
@ -7,8 +7,10 @@ import DropdownFilter from '~/components/DropdownFilter/DropdownFilter'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('ReportList', () => {
|
||||
let mocks, mutations, getters, wrapper
|
||||
@ -45,7 +47,7 @@ describe('ReportList', () => {
|
||||
mutations,
|
||||
getters,
|
||||
})
|
||||
return mount(ReportList, { mocks, localVue, store })
|
||||
return mount(ReportList, { mocks, localVue, store, stubs })
|
||||
}
|
||||
|
||||
describe('renders children components', () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import ReportRow from './ReportRow.vue'
|
||||
import BaseIcon from '~/components/_new/generic/BaseIcon/BaseIcon'
|
||||
@ -6,8 +6,6 @@ import { reports } from '~/components/features/ReportList/ReportList.story.js'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
|
||||
describe('ReportRow', () => {
|
||||
let propsData, mocks, stubs, getters, wrapper
|
||||
|
||||
@ -18,6 +16,7 @@ describe('ReportRow', () => {
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub,
|
||||
'client-only': true,
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import ReportsTable from './ReportsTable.vue'
|
||||
import { reports } from '~/components/features/ReportList/ReportList.story.js'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('ReportsTable', () => {
|
||||
let propsData, mocks, getters, wrapper, reportsTable
|
||||
@ -29,7 +31,7 @@ describe('ReportsTable', () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return mount(ReportsTable, { propsData, mocks, localVue, store })
|
||||
return mount(ReportsTable, { propsData, mocks, localVue, store, stubs })
|
||||
}
|
||||
|
||||
describe('given no reports', () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import SearchField from './SearchField.vue'
|
||||
import SearchableInput from '~/components/generic/SearchableInput/SearchableInput'
|
||||
@ -7,7 +7,10 @@ const localVue = global.localVue
|
||||
|
||||
localVue.filter('truncate', () => 'truncated string')
|
||||
localVue.filter('dateTime', () => Date.now)
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('SearchField.vue', () => {
|
||||
let mocks, wrapper, getters
|
||||
@ -26,7 +29,7 @@ describe('SearchField.vue', () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return mount(SearchField, { mocks, localVue, store })
|
||||
return mount(SearchField, { mocks, localVue, store, stubs })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
@ -37,11 +37,11 @@ describe('SearchPost.vue', () => {
|
||||
})
|
||||
|
||||
it('renders post commentsCount', () => {
|
||||
expect(counts.text()).toContain(propsData.option.commentsCount)
|
||||
expect(counts.text()).toContain(propsData.option.commentsCount.toString())
|
||||
})
|
||||
|
||||
it('renders post shoutedCount', () => {
|
||||
expect(counts.text()).toContain(propsData.option.shoutedCount)
|
||||
expect(counts.text()).toContain(propsData.option.shoutedCount.toString())
|
||||
})
|
||||
|
||||
it('renders post author', () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import Vue from 'vue'
|
||||
import SearchableInput from './SearchableInput'
|
||||
@ -8,7 +8,10 @@ const localVue = global.localVue
|
||||
|
||||
localVue.filter('truncate', () => 'truncated string')
|
||||
localVue.filter('dateTime', () => Date.now)
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('SearchableInput.vue', () => {
|
||||
let mocks, propsData, getters, wrapper
|
||||
@ -28,7 +31,7 @@ describe('SearchableInput.vue', () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return mount(SearchableInput, { mocks, localVue, propsData, store })
|
||||
return mount(SearchableInput, { mocks, localVue, propsData, store, stubs })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user