mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
pages tests nearly working
This commit is contained in:
parent
b2eda033ee
commit
4850e456fe
@ -20,6 +20,7 @@ module.exports = {
|
||||
transform: {
|
||||
'.*\\.(vue)$': 'vue-jest',
|
||||
'^.+\\.js$': 'babel-jest',
|
||||
'<rootDir>/node_modules/@mapbox/mapbox-gl-geocoder/dist/*': 'babel-jest',
|
||||
},
|
||||
testMatch: ['**/?(*.)+(spec|test).js?(x)'],
|
||||
modulePathIgnorePatterns: ['<rootDir>/build/'],
|
||||
|
||||
@ -67,7 +67,8 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "~7.12.3",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||
"@babel/preset-env": "~7.9.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.20.11",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@faker-js/faker": "5.1.0",
|
||||
"@nuxtjs/composition-api": "0.32.0",
|
||||
"@storybook/addon-a11y": "^6.3.6",
|
||||
@ -81,7 +82,7 @@
|
||||
"async-validator": "^3.2.4",
|
||||
"babel-core": "~7.0.0-bridge.0",
|
||||
"babel-eslint": "~10.1.0",
|
||||
"babel-jest": "~25.3.0",
|
||||
"babel-jest": "29.4",
|
||||
"babel-loader": "~8.1.0",
|
||||
"babel-plugin-require-context-hook": "^1.0.0",
|
||||
"babel-preset-vue": "~2.0.2",
|
||||
|
||||
@ -33,7 +33,7 @@ describe('code-of-conduct.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -33,7 +33,7 @@ describe('data-privacy.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -37,7 +37,7 @@ describe('donate.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -33,7 +33,7 @@ describe('faq.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import _id from './_id.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-child'] = '<span class="nuxt-child"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-child': true,
|
||||
}
|
||||
|
||||
describe('Group profile _id.vue', () => {
|
||||
let wrapper
|
||||
@ -19,6 +21,7 @@ describe('Group profile _id.vue', () => {
|
||||
return mount(_id, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -27,7 +30,7 @@ describe('Group profile _id.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.findAll('.nuxt-child')).toHaveLength(1)
|
||||
expect(wrapper.findComponent({ name: 'nuxt-child' }).exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import groups from './groups.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
|
||||
config.stubs['client-only'] = '<span class="client-only"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
describe('groups', () => {
|
||||
let wrapper
|
||||
@ -21,6 +23,7 @@ describe('groups', () => {
|
||||
return mount(groups, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -29,7 +32,7 @@ describe('groups', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBe(true)
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -37,7 +37,7 @@ describe('imprint.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import Vuex from 'vuex'
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import login from './login.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span class="client-only"><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('Login.vue', () => {
|
||||
let store
|
||||
@ -50,6 +52,7 @@ describe('Login.vue', () => {
|
||||
store,
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ describe('logout.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBe(true)
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('logs out and redirects to login', () => {
|
||||
|
||||
@ -5,6 +5,8 @@ import VueMeta from 'vue-meta'
|
||||
import Vuex from 'vuex'
|
||||
import Map from './map'
|
||||
|
||||
jest.mock('@mapbox/mapbox-gl-geocoder')
|
||||
|
||||
jest.mock('mapbox-gl', () => {
|
||||
return {
|
||||
GeolocateControl: jest.fn(),
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import moderation from './moderation.vue'
|
||||
|
||||
config.stubs['nuxt-child'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-child': true,
|
||||
}
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
@ -20,6 +22,7 @@ describe('moderation.vue', () => {
|
||||
return mount(moderation, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -28,7 +31,7 @@ describe('moderation.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBe(true)
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Moderation from './index.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
describe('moderation/index.vue', () => {
|
||||
let wrapper
|
||||
@ -16,7 +19,7 @@ describe('moderation/index.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(Moderation, { mocks, localVue })
|
||||
return mount(Moderation, { mocks, localVue, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
@ -24,7 +27,7 @@ describe('moderation/index.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('.base-card')).toBe(true)
|
||||
expect(wrapper.classes('base-card')).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { config, shallowMount, mount } from '@vue/test-utils'
|
||||
import { shallowMount, mount } from '@vue/test-utils'
|
||||
import NotificationsPage from './index.vue'
|
||||
|
||||
import DropdownFilter from '~/components/DropdownFilter/DropdownFilter'
|
||||
@ -7,7 +7,9 @@ import PaginationButtons from '~/components/_new/generic/PaginationButtons/Pagin
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
describe('PostIndex', () => {
|
||||
let wrapper, Wrapper, mocks, propsData
|
||||
@ -42,6 +44,7 @@ describe('PostIndex', () => {
|
||||
mocks,
|
||||
localVue,
|
||||
propsData,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
@ -67,6 +70,7 @@ describe('PostIndex', () => {
|
||||
mocks,
|
||||
localVue,
|
||||
propsData,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -79,7 +83,7 @@ describe('PostIndex', () => {
|
||||
{ label: 'Unread', value: false },
|
||||
]
|
||||
wrapper = Wrapper()
|
||||
wrapper.find(DropdownFilter).vm.$emit('filter', propsData.filterOptions[1])
|
||||
wrapper.findComponent(DropdownFilter).vm.$emit('filter', propsData.filterOptions[1])
|
||||
})
|
||||
|
||||
it('sets `notificationRead` to value of received option', () => {
|
||||
@ -98,7 +102,9 @@ describe('PostIndex', () => {
|
||||
describe('markNotificationAsRead', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
wrapper.find(NotificationsTable).vm.$emit('markNotificationAsRead', 'notificationSourceId')
|
||||
wrapper
|
||||
.findComponent(NotificationsTable)
|
||||
.vm.$emit('markNotificationAsRead', 'notificationSourceId')
|
||||
})
|
||||
|
||||
it('calls markNotificationAsRead mutation', () => {
|
||||
@ -112,7 +118,7 @@ describe('PostIndex', () => {
|
||||
mocks.$apollo.mutate = jest.fn().mockRejectedValueOnce({ message: 'Some error message' })
|
||||
wrapper = Wrapper()
|
||||
wrapper
|
||||
.find(NotificationsTable)
|
||||
.findComponent(NotificationsTable)
|
||||
.vm.$emit('markNotificationAsRead', 'notificationSourceId')
|
||||
})
|
||||
|
||||
@ -129,7 +135,7 @@ describe('PostIndex', () => {
|
||||
|
||||
describe('next: given a user is on the first page', () => {
|
||||
it('adds offset to pageSize to skip first x notifications and display next page', () => {
|
||||
wrapper.find(PaginationButtons).vm.$emit('next')
|
||||
wrapper.findComponent(PaginationButtons).vm.$emit('next')
|
||||
expect(wrapper.vm.offset).toEqual(12)
|
||||
})
|
||||
})
|
||||
@ -137,7 +143,7 @@ describe('PostIndex', () => {
|
||||
describe('back: given a user is on the third page', () => {
|
||||
it('sets offset when back is emitted', () => {
|
||||
wrapper.setData({ offset: 24 })
|
||||
wrapper.find(PaginationButtons).vm.$emit('back')
|
||||
wrapper.findComponent(PaginationButtons).vm.$emit('back')
|
||||
expect(wrapper.vm.offset).toEqual(12)
|
||||
})
|
||||
})
|
||||
|
||||
@ -37,7 +37,7 @@ describe('organization.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import Vuex from 'vuex'
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import PasswordReset from './password-reset.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span class="client-only"><slot /></span>'
|
||||
config.stubs['nuxt-child'] = '<span class="nuxt-child"><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'nuxt-child': true,
|
||||
}
|
||||
|
||||
describe('password-reset.vue', () => {
|
||||
let wrapper
|
||||
@ -47,12 +49,13 @@ describe('password-reset.vue', () => {
|
||||
return mount(PasswordReset, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
it('renders', async () => {
|
||||
wrapper = await Wrapper()
|
||||
expect(wrapper.is('div')).toBe(true)
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('renders with asyncData and not loggedIn', async () => {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import enterNonce from './enter-nonce.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('enter-nonce.vue', () => {
|
||||
let wrapper
|
||||
@ -20,7 +22,7 @@ describe('enter-nonce.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(enterNonce, { mocks, localVue })
|
||||
return mount(enterNonce, { mocks, localVue, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import request from './request.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
// config.stubs['sweetalert-icon'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('request.vue', () => {
|
||||
let wrapper
|
||||
@ -29,7 +30,7 @@ describe('request.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(request, { mocks, localVue })
|
||||
return mount(request, { mocks, localVue, stubs })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import _id from './_id.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['nuxt-child'] = '<span class="nuxt-child"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-child': true,
|
||||
}
|
||||
|
||||
describe('Profile _id.vue', () => {
|
||||
let wrapper
|
||||
@ -19,6 +21,7 @@ describe('Profile _id.vue', () => {
|
||||
return mount(_id, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -27,7 +30,7 @@ describe('Profile _id.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.findAll('.nuxt-child')).toHaveLength(1)
|
||||
expect(wrapper.findComponent({ name: 'nuxt-child' }).exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import ProfileSlug from './_slug.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
localVue.filter('date', (d) => d)
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
config.stubs['infinite-loading'] = '<span><slot /></span>'
|
||||
config.stubs['follow-list'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'v-popover': true,
|
||||
'nuxt-link': true,
|
||||
'infinite-loading': true,
|
||||
'follow-list': true,
|
||||
}
|
||||
|
||||
describe('ProfileSlug', () => {
|
||||
let wrapper
|
||||
@ -51,6 +53,7 @@ describe('ProfileSlug', () => {
|
||||
return mount(ProfileSlug, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
import Vuex from 'vuex'
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Registration from './registration.vue'
|
||||
import Vue from 'vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
config.stubs['client-only'] = '<span><slot /></span>'
|
||||
config.stubs['router-link'] = '<span><slot /></span>'
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
config.stubs['infinite-loading'] = '<span><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
'router-link': true,
|
||||
'nuxt-link': true,
|
||||
'infinite-loading': true,
|
||||
}
|
||||
|
||||
describe('Registration', () => {
|
||||
let wrapper
|
||||
@ -73,6 +75,7 @@ describe('Registration', () => {
|
||||
return mount(Registration, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
@ -310,7 +313,7 @@ describe('Registration', () => {
|
||||
|
||||
it('renders', async () => {
|
||||
wrapper = await Wrapper()
|
||||
expect(wrapper.is('.registration-slider')).toBe(true)
|
||||
expect(wrapper.classes('registration-slider')).toBe(true)
|
||||
})
|
||||
|
||||
// The asyncTests must go last
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import searchResults from './search-results.vue'
|
||||
import VueMeta from 'vue-meta'
|
||||
|
||||
const localVue = global.localVue
|
||||
localVue.use(VueMeta, { keyName: 'head' })
|
||||
|
||||
config.stubs['client-only'] = '<span class="client-only"><slot /></span>'
|
||||
const stubs = {
|
||||
'client-only': true,
|
||||
}
|
||||
|
||||
describe('search-results.vue', () => {
|
||||
let wrapper
|
||||
@ -32,7 +34,7 @@ describe('search-results.vue', () => {
|
||||
return { ...data, ...aData }
|
||||
}
|
||||
}
|
||||
return mount(searchResults, { mocks, localVue })
|
||||
return mount(searchResults, { mocks, localVue, stubs })
|
||||
}
|
||||
|
||||
it('renders', async () => {
|
||||
|
||||
@ -37,7 +37,7 @@ describe('support.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import Vuex from 'vuex'
|
||||
import { config, mount } from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import TermsAndConditionsConfirm from './terms-and-conditions-confirm.vue'
|
||||
import VueMeta from 'vue-meta'
|
||||
|
||||
const localVue = global.localVue
|
||||
localVue.use(VueMeta, { keyName: 'head' })
|
||||
|
||||
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
|
||||
const stubs = {
|
||||
'nuxt-link': true,
|
||||
}
|
||||
|
||||
describe('terms-and-conditions-confirm.vue', () => {
|
||||
let wrapper
|
||||
@ -45,12 +47,13 @@ describe('terms-and-conditions-confirm.vue', () => {
|
||||
return mount(TermsAndConditionsConfirm, {
|
||||
mocks,
|
||||
localVue,
|
||||
stubs,
|
||||
})
|
||||
}
|
||||
|
||||
it('renders', async () => {
|
||||
wrapper = await Wrapper()
|
||||
expect(wrapper.is('div')).toBe(true)
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', async () => {
|
||||
|
||||
@ -33,7 +33,7 @@ describe('terms-and-conditions.vue', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
1888
webapp/yarn.lock
1888
webapp/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user