From 2927b9115a5da6770fdd9251a5eb35510de906ae Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Fri, 31 Jul 2020 01:28:21 +0900
Subject: [PATCH] refs #1642 Fix tests for list membership
---
.../Modals/ListMembership.spec.ts | 61 +++++++++++--------
1 file changed, 37 insertions(+), 24 deletions(-)
diff --git a/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts b/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts
index a7ef09f6..bac67d0b 100644
--- a/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts
@@ -26,27 +26,35 @@ const mockClient = {
resolve(res)
})
},
- deleteAccountsFromList: () => {
- return new Promise(resolve => {
- const res: Response = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
+ deleteAccountsFromList: (id: string, account_ids: Array) => {
+ if (id === list3.id && account_ids[0]) {
+ return new Promise(resolve => {
+ const res: Response = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ } else {
+ return Promise.reject(new Error('list id or account id is not match'))
+ }
},
- addAccountsToList: () => {
- return new Promise(resolve => {
- const res: Response = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
+ addAccountsToList: (id: string, account_ids: Array) => {
+ if (id === list1.id && account_ids[0] === account.id) {
+ return new Promise(resolve => {
+ const res: Response = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ } else {
+ return Promise.reject(new Error('list id or account id is not match'))
+ }
}
}
@@ -88,6 +96,11 @@ const list2: Entity.List = {
title: 'list2'
}
+const list3: Entity.List = {
+ id: '3',
+ title: 'list3'
+}
+
let state = (): ListMembershipState => {
return {
modalOpen: false,
@@ -143,7 +156,7 @@ describe('ListMembership', () => {
await store.dispatch('ListMembership/fetchListMembership', {
id: '5'
})
- expect(store.state.ListMembership.belongToLists).toEqual(['1', '2'])
+ expect(store.state.ListMembership.belongToLists).toEqual([list1, list2])
})
})
@@ -161,13 +174,13 @@ describe('ListMembership', () => {
modalOpen: false,
account: account,
lists: [],
- belongToLists: [list2]
+ belongToLists: [list2, list3]
}
}
})
it('should be changed', async () => {
- await store.dispatch('ListMembership/changeBelongToLists', [list1])
- expect(store.state.ListMembership.belongToLists).toEqual([list1])
+ await store.dispatch('ListMembership/changeBelongToLists', [list1.id, list2.id])
+ expect(store.state.ListMembership.belongToLists).toEqual([list1, list2])
})
})
})