mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
70 lines
1.6 KiB
JavaScript
70 lines
1.6 KiB
JavaScript
import { config, mount, createLocalVue } from '@vue/test-utils'
|
|
import MutedUsers from './muted-users.vue'
|
|
import Styleguide from '@human-connection/styleguide'
|
|
import Filters from '~/plugins/vue-filters'
|
|
import { unmuteUser } from '~/graphql/settings/MutedUsers'
|
|
|
|
const localVue = createLocalVue()
|
|
|
|
localVue.use(Styleguide)
|
|
localVue.use(Filters)
|
|
|
|
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
|
|
|
describe('muted-users.vue', () => {
|
|
let wrapper
|
|
let mocks
|
|
|
|
beforeEach(() => {
|
|
mocks = {
|
|
$t: jest.fn(),
|
|
$apollo: {
|
|
mutate: jest.fn(),
|
|
queries: {
|
|
mutedUsers: {
|
|
refetch: jest.fn(),
|
|
},
|
|
},
|
|
},
|
|
$toast: {
|
|
error: jest.fn(),
|
|
success: jest.fn(),
|
|
},
|
|
}
|
|
})
|
|
|
|
describe('mount', () => {
|
|
const Wrapper = () => {
|
|
return mount(MutedUsers, { mocks, localVue })
|
|
}
|
|
|
|
beforeEach(() => {
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('renders', () => {
|
|
expect(wrapper.is('div')).toBe(true)
|
|
})
|
|
|
|
describe('given a list of blocked users', () => {
|
|
beforeEach(() => {
|
|
const mutedUsers = [{ id: 'u1', name: 'John Doe', slug: 'john-doe', avatar: '' }]
|
|
wrapper.setData({ mutedUsers })
|
|
})
|
|
|
|
describe('click unmute', () => {
|
|
beforeEach(() => {
|
|
wrapper.find('button').trigger('click')
|
|
})
|
|
|
|
it('calls unmute mutation with given user', () => {
|
|
expect(mocks.$apollo.mutate).toHaveBeenCalledWith({
|
|
mutation: unmuteUser(),
|
|
variables: { id: 'u1' },
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|