logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 821a09109c4747fcec49059f03c8cc908bd07ac5
parent 04acf069d1600f097805ce52f958263e68e153c1
Author: Henry Jameson <me@hjkos.com>
Date:   Tue, 16 Aug 2022 20:00:29 +0300

fix list tests

Diffstat:

Msrc/modules/lists.js5+++--
Mtest/unit/specs/modules/lists.spec.js16++++++++--------
Mtest/unit/specs/modules/serverSideStorage.spec.js1-
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/modules/lists.js b/src/modules/lists.js @@ -15,10 +15,11 @@ export const mutations = { } state.allListsObject[listId].title = title - if (!find(state.allLists, { id: listId })) { + const entry = find(state.allLists, { id: listId }) + if (!entry) { state.allLists.push({ id: listId, title }) } else { - find(state.allLists, { id: listId }).title = title + entry.title = title } }, setListAccounts (state, { listId, accountIds }) { diff --git a/test/unit/specs/modules/lists.spec.js b/test/unit/specs/modules/lists.spec.js @@ -17,13 +17,13 @@ describe('The lists module', () => { const list = { id: '1', title: 'testList' } const modList = { id: '1', title: 'anotherTestTitle' } - mutations.setList(state, list) - expect(state.allListsObject[list.id]).to.eql({ title: list.title }) + mutations.setList(state, { listId: list.id, title: list.title }) + expect(state.allListsObject[list.id]).to.eql({ title: list.title, accountIds: [] }) expect(state.allLists).to.have.length(1) expect(state.allLists[0]).to.eql(list) - mutations.setList(state, modList) - expect(state.allListsObject[modList.id]).to.eql({ title: modList.title }) + mutations.setList(state, { listId: modList.id, title: modList.title }) + expect(state.allListsObject[modList.id]).to.eql({ title: modList.title, accountIds: [] }) expect(state.allLists).to.have.length(1) expect(state.allLists[0]).to.eql(modList) }) @@ -33,10 +33,10 @@ describe('The lists module', () => { const list = { id: '1', accountIds: ['1', '2', '3'] } const modList = { id: '1', accountIds: ['3', '4', '5'] } - mutations.setListAccounts(state, list) + mutations.setListAccounts(state, { listId: list.id, accountIds: list.accountIds }) expect(state.allListsObject[list.id]).to.eql({ accountIds: list.accountIds }) - mutations.setListAccounts(state, modList) + mutations.setListAccounts(state, { listId: modList.id, accountIds: modList.accountIds }) expect(state.allListsObject[modList.id]).to.eql({ accountIds: modList.accountIds }) }) @@ -47,9 +47,9 @@ describe('The lists module', () => { 1: { title: 'testList', accountIds: ['1', '2', '3'] } } } - const id = '1' + const listId = '1' - mutations.deleteList(state, { id }) + mutations.deleteList(state, { listId }) expect(state.allLists).to.have.length(0) expect(state.allListsObject).to.eql({}) }) diff --git a/test/unit/specs/modules/serverSideStorage.spec.js b/test/unit/specs/modules/serverSideStorage.spec.js @@ -148,7 +148,6 @@ describe('The serverSideStorage module', () => { timestamp: state.prefsStorage._journal[1].timestamp }) }) - }) }) })