Changed the mocks for the test.

This commit is contained in:
Hannes Heine 2021-08-10 15:31:25 +02:00
parent e6ffd08db9
commit a10f5a3bcc

View File

@ -1,16 +1,11 @@
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import UserCardFormUsername from './UserCard_FormUsername' import UserCardFormUsername from './UserCard_FormUsername'
import loginAPI from '../../../apis/loginAPI'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import { extend } from 'vee-validate' import { extend } from 'vee-validate'
jest.mock('../../../apis/loginAPI')
const localVue = global.localVue const localVue = global.localVue
const mockAPIcall = jest.fn((args) => { const mockAPIcall = jest.fn()
return { success: true }
})
// override this rule to avoid API call // override this rule to avoid API call
extend('gddUsernameUnique', { extend('gddUsernameUnique', {
@ -23,8 +18,6 @@ const toastErrorMock = jest.fn()
const toastSuccessMock = jest.fn() const toastSuccessMock = jest.fn()
const storeCommitMock = jest.fn() const storeCommitMock = jest.fn()
loginAPI.changeUsernameProfile = mockAPIcall
describe('UserCard_FormUsername', () => { describe('UserCard_FormUsername', () => {
let wrapper let wrapper
@ -42,6 +35,9 @@ describe('UserCard_FormUsername', () => {
success: toastSuccessMock, success: toastSuccessMock,
error: toastErrorMock, error: toastErrorMock,
}, },
$apollo: {
query: mockAPIcall,
},
} }
const Wrapper = () => { const Wrapper = () => {