diff --git a/webapp/pages/admin.spec.js b/webapp/pages/admin.spec.js index fc3849fc4..aa6eceab1 100644 --- a/webapp/pages/admin.spec.js +++ b/webapp/pages/admin.spec.js @@ -1,7 +1,9 @@ -import { config, mount } from '@vue/test-utils' +import { mount } from '@vue/test-utils' import admin from './admin.vue' -config.stubs['nuxt-child'] = '' +const stubs = { + 'nuxt-child': true, +} const localVue = global.localVue @@ -20,6 +22,7 @@ describe('admin.vue', () => { return mount(admin, { mocks, localVue, + stubs, }) } @@ -28,7 +31,7 @@ describe('admin.vue', () => { }) it('renders', () => { - expect(wrapper.is('div')).toBe(true) + expect(wrapper.element.tagName).toBe('DIV') }) }) }) diff --git a/webapp/pages/group/_id/_slug.spec.js b/webapp/pages/group/_id/_slug.spec.js index 963952f5e..bb9279bce 100644 --- a/webapp/pages/group/_id/_slug.spec.js +++ b/webapp/pages/group/_id/_slug.spec.js @@ -1,15 +1,18 @@ -import { config, mount } from '@vue/test-utils' +import { mount } from '@vue/test-utils' import GroupProfileSlug from './_slug.vue' const localVue = global.localVue localVue.filter('date', (d) => d) -config.stubs['client-only'] = '' -config.stubs['v-popover'] = '' -config.stubs['nuxt-link'] = '' -config.stubs['infinite-loading'] = '' -config.stubs['follow-list'] = '' +const stubs = { + 'client-only': true, + 'v-popover': true, + 'nuxt-link': true, + 'router-link': true, + 'infinite-loading': true, + 'follow-list': true, +} describe('GroupProfileSlug', () => { let wrapper @@ -201,6 +204,7 @@ describe('GroupProfileSlug', () => { mocks, localVue, data, + stubs, }) } diff --git a/webapp/pages/index.spec.js b/webapp/pages/index.spec.js index 43400986c..47011f137 100644 --- a/webapp/pages/index.spec.js +++ b/webapp/pages/index.spec.js @@ -1,14 +1,16 @@ -import { config, shallowMount, mount } from '@vue/test-utils' +import { shallowMount, mount } from '@vue/test-utils' import PostIndex from './index.vue' import Vuex from 'vuex' import HashtagsFilter from '~/components/HashtagsFilter/HashtagsFilter' const localVue = global.localVue -config.stubs['client-only'] = '' -config.stubs['router-link'] = '' -config.stubs['nuxt-link'] = '' -config.stubs['infinite-loading'] = '' +const stubs = { + 'client-only': true, + 'router-link': true, + 'nuxt-link': true, + 'infinite-loading': true, +} describe('PostIndex', () => { let wrapper @@ -95,7 +97,7 @@ describe('PostIndex', () => { it('clears the search when the filter menu emits clearSearch', () => { mocks.$route.query.hashtag = '#samplehashtag' wrapper = Wrapper() - wrapper.find(HashtagsFilter).vm.$emit('clearSearch') + wrapper.findComponent(HashtagsFilter).vm.$emit('clearSearch') expect(wrapper.vm.hashtag).toBeNull() }) @@ -123,6 +125,7 @@ describe('PostIndex', () => { store, mocks, localVue, + stubs, }) } diff --git a/webapp/pages/post/_id/_slug/index.spec.js b/webapp/pages/post/_id/_slug/index.spec.js index 2dd4522b2..4528e64ee 100644 --- a/webapp/pages/post/_id/_slug/index.spec.js +++ b/webapp/pages/post/_id/_slug/index.spec.js @@ -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 PostSlug from './index.vue' @@ -6,10 +6,6 @@ import CommentList from '~/components/CommentList/CommentList' import HcHashtag from '~/components/Hashtag/Hashtag' import VueMeta from 'vue-meta' -config.stubs['client-only'] = '' -config.stubs['nuxt-link'] = '' -config.stubs['router-link'] = '' - const localVue = global.localVue localVue.directive('scrollTo', jest.fn()) localVue.use(VueMeta, { keyName: 'head' }) @@ -81,6 +77,9 @@ describe('PostSlug', () => { }, } stubs = { + 'client-only': true, + 'nuxt-link': true, + 'router-link': true, HcEditor: { render: () => {}, methods: { insertReply: jest.fn(() => null) } }, ContentViewer: true, } @@ -148,7 +147,7 @@ describe('PostSlug', () => { describe('reply method called when emitted reply received', () => { it('CommentList', async () => { wrapper = await Wrapper() - wrapper.find(CommentList).vm.$emit('reply', { + wrapper.findComponent(CommentList).vm.$emit('reply', { id: 'commentAuthorId', slug: 'ogerly', }) @@ -176,12 +175,12 @@ describe('PostSlug', () => { it('are present', async () => { // Get length from backendData and compare against number of tags present in component. - expect(wrapper.findAll(HcHashtag).length).toBe(backendData.post.tags.length) + expect(wrapper.findAllComponents(HcHashtag).length).toBe(backendData.post.tags.length) }) it('are alphabetically ordered', async () => { // Get all HcHastag components - const wrappers = wrapper.findAll(HcHashtag).wrappers + const wrappers = wrapper.findAllComponents(HcHashtag).wrappers // Exctract ID properties (tag names) from component. const ids = [] wrappers.forEach((x) => {