refs #630 Fix id type for spec

This commit is contained in:
AkiraFukushima 2019-05-27 23:04:53 +09:00
parent a52198836f
commit b6239a5f1e
10 changed files with 59 additions and 112 deletions

View File

@ -94,6 +94,9 @@ const contentsStore = {
Local: LocalStore,
Public: PublicStore,
Mentions: MentionStore
},
actions: {
changeLoading: jest.fn()
}
}
@ -168,7 +171,7 @@ describe('TimelineSpace', () => {
}
})
it('should be detected', async () => {
(Mastodon.get as any).mockResolvedValue(mockedResponse)
;(Mastodon.get as any).mockResolvedValue(mockedResponse)
await store.dispatch('TimelineSpace/detectPleroma')
expect(store.state.TimelineSpace.pleroma).toEqual(true)
expect(store.state.TimelineSpace.useWebsocket).toEqual(true)
@ -203,7 +206,7 @@ describe('TimelineSpace', () => {
}
})
it('should be detected', async () => {
(Mastodon.get as any).mockResolvedValue(mockedResponse)
;(Mastodon.get as any).mockResolvedValue(mockedResponse)
await store.dispatch('TimelineSpace/detectPleroma')
expect(store.state.TimelineSpace.pleroma).toEqual(false)
expect(store.state.TimelineSpace.useWebsocket).toEqual(false)
@ -229,17 +232,14 @@ describe('TimelineSpace', () => {
visible_in_picker: true
}
mockedResponse = {
data: [
emacsEmoji,
rubyEmoji
],
data: [emacsEmoji, rubyEmoji],
status: 200,
statusText: 'OK',
headers: {}
}
})
it('should be updated', async () => {
(Mastodon.get as any).mockResolvedValue(mockedResponse)
;(Mastodon.get as any).mockResolvedValue(mockedResponse)
await store.dispatch('TimelineSpace/fetchEmojis', {})
expect(store.state.TimelineSpace.emojis).toEqual([
{
@ -249,7 +249,8 @@ describe('TimelineSpace', () => {
{
image: 'http://example.com/ruby',
name: ':ruby:'
}])
}
])
})
})
@ -264,7 +265,7 @@ describe('TimelineSpace', () => {
}
})
it('should be updated', async () => {
(Mastodon.get as any).mockResolvedValue(mockedResponse)
;(Mastodon.get as any).mockResolvedValue(mockedResponse)
await store.dispatch('TimelineSpace/fetchInstance', {})
expect(store.state.TimelineSpace.tootMax).toEqual(5000)
})

View File

@ -7,7 +7,7 @@ import Home, { HomeState } from '@/store/TimelineSpace/Contents/Home'
jest.mock('megalodon')
const account: Account = {
id: 1,
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
@ -28,7 +28,7 @@ const account: Account = {
bot: false
}
const status1: Status = {
id: 1,
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
@ -58,7 +58,7 @@ const status1: Status = {
pinned: null
}
const status2: Status = {
id: 2,
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
@ -141,9 +141,7 @@ describe('Home', () => {
get: (_path: string, _params: object) => {
return new Promise<Response<Status[]>>(resolve => {
const res: Response<Status[]> = {
data: [
status1
],
data: [status1],
status: 200,
statusText: 'OK',
headers: {}
@ -155,12 +153,8 @@ describe('Home', () => {
mockedMegalodon.mockImplementation(() => mockClient)
const statuses = await store.dispatch('Home/fetchTimeline')
expect(statuses).toEqual([
status1
])
expect(store.state.Home.timeline).toEqual([
status1
])
expect(statuses).toEqual([status1])
expect(store.state.Home.timeline).toEqual([status1])
})
})
@ -184,9 +178,7 @@ describe('Home', () => {
get: (_path: string, _params: object) => {
return new Promise<Response<[Status]>>(resolve => {
const res: Response<[Status]> = {
data: [
status2
],
data: [status2],
status: 200,
statusText: 'OK',
headers: {}
@ -198,10 +190,7 @@ describe('Home', () => {
mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Home/lazyFetchTimeline', { id: 20 })
expect(store.state.Home.lazyLoading).toEqual(false)
expect(store.state.Home.timeline).toEqual([
status1,
status2
])
expect(store.state.Home.timeline).toEqual([status1, status2])
})
})
})

View File

@ -7,7 +7,7 @@ import Mentions from '~/src/renderer/store/TimelineSpace/Contents/Mentions'
jest.mock('megalodon')
const account: Account = {
id: 1,
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
@ -29,7 +29,7 @@ const account: Account = {
}
const status: Status = {
id: 1,
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
@ -62,7 +62,7 @@ const status: Status = {
const mention: Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: 1,
id: '1',
status: status,
type: 'mention'
}
@ -70,7 +70,7 @@ const mention: Notification = {
const reblog: Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: 2,
id: '2',
status: status,
type: 'reblog'
}
@ -78,7 +78,7 @@ const reblog: Notification = {
const favourite: Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: 3,
id: '3',
status: status,
type: 'favourite'
}
@ -86,7 +86,7 @@ const favourite: Notification = {
const follow: Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: 4,
id: '4',
status: null,
type: 'follow'
}
@ -142,12 +142,7 @@ describe('Mentions', () => {
get: (_path: string, _params: object) => {
return new Promise<Response<Notification[]>>(resolve => {
const res: Response<Notification[]> = {
data: [
mention,
reblog,
favourite,
follow
],
data: [mention, reblog, favourite, follow],
status: 200,
statusText: 'OK',
headers: {}
@ -159,12 +154,7 @@ describe('Mentions', () => {
mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Mentions/fetchMentions')
expect(store.state.Mentions.mentions).toEqual([
mention,
reblog,
favourite,
follow
])
expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
})
})
@ -193,10 +183,7 @@ describe('Mentions', () => {
return {
lazyLoading: false,
heading: true,
mentions: [
mention,
reblog
],
mentions: [mention, reblog],
unreadMentions: [],
filter: ''
}
@ -207,10 +194,7 @@ describe('Mentions', () => {
get: (_path: string, _params: object) => {
return new Promise<Response<Notification[]>>(resolve => {
const res: Response<Notification[]> = {
data: [
favourite,
follow
],
data: [favourite, follow],
status: 200,
statusText: 'OK',
headers: {}
@ -222,12 +206,7 @@ describe('Mentions', () => {
mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Mentions/lazyFetchMentions', { id: 1 })
expect(store.state.Mentions.mentions).toEqual([
mention,
reblog,
favourite,
follow
])
expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
expect(store.state.Mentions.lazyLoading).toEqual(false)
})
})
@ -239,12 +218,7 @@ describe('Mentions', () => {
return {
lazyLoading: false,
heading: true,
mentions: [
mention,
favourite,
reblog,
follow
],
mentions: [mention, favourite, reblog, follow],
unreadMentions: [],
filter: ''
}
@ -252,9 +226,7 @@ describe('Mentions', () => {
})
it('should return only mentions', () => {
const mentions = store.getters['Mentions/mentions']
expect(mentions).toEqual([
mention
])
expect(mentions).toEqual([mention])
})
})
})

View File

@ -7,7 +7,7 @@ import HeaderMenu, { HeaderMenuState } from '~/src/renderer/store/TimelineSpace/
jest.mock('megalodon')
const list: List = {
id: 1,
id: '1',
title: 'example'
}

View File

@ -7,7 +7,7 @@ import AddListMember, { AddListMemberState } from '@/store/TimelineSpace/Modals/
jest.mock('megalodon')
const account: Account = {
id: 1,
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
@ -83,9 +83,7 @@ describe('AddListMember', () => {
get: () => {
return new Promise<Response<Account[]>>(resolve => {
const res: Response<Account[]> = {
data: [
account
],
data: [account],
status: 200,
statusText: 'OK',
headers: {}
@ -97,9 +95,7 @@ describe('AddListMember', () => {
mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('AddListMember/search', 'akira')
expect(store.state.AddListMember.accounts).toEqual([
account
])
expect(store.state.AddListMember.accounts).toEqual([account])
})
})

View File

@ -7,7 +7,7 @@ import ListMembership, { ListMembershipState } from '@/store/TimelineSpace/Modal
jest.mock('megalodon')
const account: Account = {
id: 1,
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
@ -29,12 +29,12 @@ const account: Account = {
}
const list1: List = {
id: 1,
id: '1',
title: 'list1'
}
const list2: List = {
id: 2,
id: '2',
title: 'list2'
}
@ -86,10 +86,7 @@ describe('ListMembership', () => {
get: (_path: string, _params: object) => {
return new Promise<Response<List[]>>(resolve => {
const res: Response<List[]> = {
data: [
list1,
list2
],
data: [list1, list2],
status: 200,
statusText: 'OK',
headers: {}
@ -100,9 +97,9 @@ describe('ListMembership', () => {
}
mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('ListMembership/fetchListMembership', {
id: 5
id: '5'
})
expect(store.state.ListMembership.belongToLists).toEqual([1, 2])
expect(store.state.ListMembership.belongToLists).toEqual(['1', '2'])
})
})
@ -112,10 +109,7 @@ describe('ListMembership', () => {
get: (_path: string, _params: object) => {
return new Promise<Response<List[]>>(resolve => {
const res: Response<List[]> = {
data: [
list1,
list2
],
data: [list1, list2],
status: 200,
statusText: 'OK',
headers: {}
@ -126,10 +120,7 @@ describe('ListMembership', () => {
}
mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('ListMembership/fetchLists')
expect(store.state.ListMembership.lists).toEqual([
list1,
list2
])
expect(store.state.ListMembership.lists).toEqual([list1, list2])
})
})
@ -140,9 +131,7 @@ describe('ListMembership', () => {
modalOpen: false,
account: account,
lists: [],
belongToLists: [
list2
]
belongToLists: [list2]
}
}
})

View File

@ -9,12 +9,12 @@ import LocalTag from '~/src/types/localTag'
jest.mock('megalodon')
const list1: List = {
id: 1,
id: '1',
title: 'example1'
}
const list2: List = {
id: 2,
id: '2',
title: 'example2'
}

View File

@ -2,7 +2,7 @@ import { Account, Status, Application } from 'megalodon'
import Home, { HomeState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Home'
const account: Account = {
id: 1,
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
@ -23,7 +23,7 @@ const account: Account = {
bot: false
}
const status1: Status = {
id: 1,
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
@ -53,7 +53,7 @@ const status1: Status = {
pinned: null
}
const status2: Status = {
id: 2,
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
@ -212,7 +212,7 @@ describe('TimelineSpace/Contents/Home', () => {
})
describe('message is reblogged', () => {
const rebloggedStatus: Status = {
id: 3,
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,
@ -285,7 +285,7 @@ describe('TimelineSpace/Contents/Home', () => {
describe('message is reblogged', () => {
beforeEach(() => {
const rebloggedStatus: Status = {
id: 3,
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
account: account,

View File

@ -2,7 +2,7 @@ import { Account, Notification, Status, Application } from 'megalodon'
import Mentions, { MentionsState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Mentions'
const account1: Account = {
id: 1,
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
display_name: 'h3poteto',
@ -24,7 +24,7 @@ const account1: Account = {
}
const account2: Account = {
id: 2,
id: '2',
username: 'h3poteto',
acct: 'h3poteto@mstdn.io',
display_name: 'h3poteto',
@ -46,7 +46,7 @@ const account2: Account = {
}
const status: Status = {
id: 1,
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
account: account1,
@ -77,7 +77,7 @@ const status: Status = {
}
const notification1: Notification = {
id: 1,
id: '1',
account: account2,
status: status,
type: 'favourite',
@ -85,7 +85,7 @@ const notification1: Notification = {
}
const notification2: Notification = {
id: 2,
id: '2',
account: account2,
status: status,
type: 'reblog',

View File

@ -56,15 +56,15 @@ describe('TimelineSpace/Modals/Jump', () => {
describe('updateListChannel', () => {
it('should be updated', () => {
const admin: List = {
id: 0,
id: '0',
title: 'admin'
}
const engineer: List = {
id: 1,
id: '1',
title: 'engineer'
}
const designer: List = {
id: 2,
id: '2',
title: 'designer'
}
const channelList = [admin, engineer, designer]