From 51d5d1cd64306d4c53e6b6ce2fae9697060cbad8 Mon Sep 17 00:00:00 2001 From: saki Date: Sat, 2 Dec 2023 09:17:12 +0900 Subject: [PATCH] update the new card position to the top of the list --- src/applications/applicationService.ts | 2 +- tests/applications/applicationService.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/applications/applicationService.ts b/src/applications/applicationService.ts index fea42bd..6c10c14 100644 --- a/src/applications/applicationService.ts +++ b/src/applications/applicationService.ts @@ -213,7 +213,7 @@ export class ApplicationService { const board = state.boards.find(b => b.id === boardId) if (board) { const updatedLists = board.lists.map(l => { - return (l.id === listId) ? { ...l, cards: [...l.cards, card] } : l + return (l.id === listId) ? { ...l, cards: [card, ...l.cards] } : l }) const updated = { boards: state.boards.map(b => { diff --git a/tests/applications/applicationService.test.ts b/tests/applications/applicationService.test.ts index 0abd005..159e2ae 100644 --- a/tests/applications/applicationService.test.ts +++ b/tests/applications/applicationService.test.ts @@ -76,6 +76,7 @@ describe('ApplicationService', () => { it('createCard', () => { const updated = service.createCard(state, 'card2', boardId1, listId1) expect(updated.boards.find(b => b.id === boardId1)?.lists.find(l => l.id === listId1)?.cards.length).toEqual(2) + expect(updated.boards.find(b => b.id === boardId1)?.lists.find(l => l.id === listId1)?.cards[0].name).toEqual('card2') }) it('deleteCard', () => { const updated = service.deleteCard(state, cardId1, boardId1, listId1)