refs #850 Fix spec for Modals

This commit is contained in:
AkiraFukushima 2019-04-11 00:30:54 +09:00
parent 21605412cf
commit 2304b98260
3 changed files with 31 additions and 11 deletions

View File

@ -2,7 +2,7 @@ import { Response, Account } from 'megalodon'
import mockedMegalodon from '~/spec/mock/megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import AddListMember from '~/src/renderer/store/TimelineSpace/Modals/AddListMember'
import AddListMember, { AddListMemberState } from '@/store/TimelineSpace/Modals/AddListMember'
jest.mock('megalodon')
@ -28,7 +28,7 @@ const account: Account = {
bot: false
}
const state = () => {
const state = (): AddListMemberState => {
return {
modalOpen: false,
accounts: [],
@ -121,7 +121,7 @@ describe('AddListMember', () => {
mockedMegalodon.mockImplementation(() => mockClient)
const result = await store.dispatch('AddListMember/add', 'akira')
expect(result.data).toEqual({})
expect(result).toEqual({})
})
})
})

View File

@ -1,8 +1,8 @@
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import ImageViewer from '~/src/renderer/store/TimelineSpace/Modals/ImageViewer'
import ImageViewer, { ImageViewerState } from '~/src/renderer/store/TimelineSpace/Modals/ImageViewer'
const state = () => {
const state = (): ImageViewerState => {
return {
modalOpen: false,
currentIndex: -1,

View File

@ -1,11 +1,33 @@
import { Response, List } from 'megalodon'
import { Response, List, Account } from 'megalodon'
import mockedMegalodon from '~/spec/mock/megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import ListMembership from '~/src/renderer/store/TimelineSpace/Modals/ListMembership'
import ListMembership, { ListMembershipState } from '@/store/TimelineSpace/Modals/ListMembership'
jest.mock('megalodon')
const account: Account = {
id: 1,
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
locked: false,
created_at: '2019-03-26T21:30:32',
followers_count: 10,
following_count: 10,
statuses_count: 100,
note: 'engineer',
url: 'https://pleroma.io',
avatar: '',
avatar_static: '',
header: '',
header_static: '',
emojis: [],
moved: null,
fields: null,
bot: false
}
const list1: List = {
id: 1,
title: 'list1'
@ -16,7 +38,7 @@ const list2: List = {
title: 'list2'
}
let state: any = () => {
let state = (): ListMembershipState => {
return {
modalOpen: false,
account: null,
@ -116,9 +138,7 @@ describe('ListMembership', () => {
state = () => {
return {
modalOpen: false,
account: {
id: 65
},
account: account,
lists: [],
belongToLists: [
list2