fix list tests

This commit is contained in:
Henry Jameson 2022-08-16 20:00:29 +03:00
parent 04acf069d1
commit 821a09109c
3 changed files with 11 additions and 11 deletions

View File

@ -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 }) {

View File

@ -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({})
})

View File

@ -150,7 +150,6 @@ describe('The serverSideStorage module', () => {
})
})
})
})
describe('helper functions', () => {
describe('_moveItemInArray', () => {