mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
lint fixes
This commit is contained in:
parent
a7eaf13ae1
commit
61d0f18f24
@ -1,34 +1,19 @@
|
|||||||
import { shallowMount } from '@vue/test-utils'
|
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import ShoutButton from './ShoutButton.vue'
|
import ShoutButton from './ShoutButton.vue'
|
||||||
import Vuex from 'vuex'
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
describe('ShoutButton.vue', () => {
|
describe('ShoutButton.vue', () => {
|
||||||
let wrapper
|
|
||||||
let state
|
|
||||||
let mocks
|
let mocks
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mocks = {
|
mocks = {
|
||||||
$filters: {
|
|
||||||
truncate: (a) => a,
|
|
||||||
},
|
|
||||||
$toast: {
|
|
||||||
success: () => {},
|
|
||||||
error: () => {},
|
|
||||||
},
|
|
||||||
$t: jest.fn(),
|
$t: jest.fn(),
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: jest.fn()
|
mutate: jest.fn(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
state = {
|
|
||||||
open: null,
|
|
||||||
data: {},
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mount', () => {
|
describe('mount', () => {
|
||||||
@ -43,15 +28,15 @@ describe('ShoutButton.vue', () => {
|
|||||||
|
|
||||||
it('renders button and text', () => {
|
it('renders button and text', () => {
|
||||||
expect(mocks.$t).toHaveBeenCalledWith('shoutButton.shouted')
|
expect(mocks.$t).toHaveBeenCalledWith('shoutButton.shouted')
|
||||||
expect(wrapper.findAll(".base-button")).toHaveLength(1)
|
expect(wrapper.findAll('.base-button')).toHaveLength(1)
|
||||||
expect(wrapper.findAll(".shout-button-text")).toHaveLength(1)
|
expect(wrapper.findAll('.shout-button-text')).toHaveLength(1)
|
||||||
expect(wrapper.vm.shouted).toBe(false)
|
expect(wrapper.vm.shouted).toBe(false)
|
||||||
expect(wrapper.vm.shoutedCount).toBe(0)
|
expect(wrapper.vm.shoutedCount).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toggle the button', async () => {
|
it('toggle the button', async () => {
|
||||||
mocks.$apollo.mutate = jest.fn().mockResolvedValue({ data: { shout: 'WeDoShout' } });
|
mocks.$apollo.mutate = jest.fn().mockResolvedValue({ data: { shout: 'WeDoShout' } })
|
||||||
wrapper.find(".base-button").trigger('click')
|
wrapper.find('.base-button').trigger('click')
|
||||||
expect(wrapper.vm.shouted).toBe(true)
|
expect(wrapper.vm.shouted).toBe(true)
|
||||||
expect(wrapper.vm.shoutedCount).toBe(1)
|
expect(wrapper.vm.shoutedCount).toBe(1)
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
@ -60,14 +45,13 @@ describe('ShoutButton.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toggle the button, but backend fails', async () => {
|
it('toggle the button, but backend fails', async () => {
|
||||||
mocks.$apollo.mutate = jest.fn().mockRejectedValue({ message: 'Ouch!' });
|
mocks.$apollo.mutate = jest.fn().mockRejectedValue({ message: 'Ouch!' })
|
||||||
await wrapper.find(".base-button").trigger('click')
|
await wrapper.find('.base-button').trigger('click')
|
||||||
expect(wrapper.vm.shouted).toBe(true)
|
expect(wrapper.vm.shouted).toBe(true)
|
||||||
expect(wrapper.vm.shoutedCount).toBe(1)
|
expect(wrapper.vm.shoutedCount).toBe(1)
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
expect(wrapper.vm.shouted).toBe(false)
|
expect(wrapper.vm.shouted).toBe(false)
|
||||||
expect(wrapper.vm.shoutedCount).toBe(0)
|
expect(wrapper.vm.shoutedCount).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user