From 60d087c4245549315d2ee0b99efaeecf95dfaee8 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Thu, 30 Jan 2020 15:27:48 +0000 Subject: [PATCH] Fix mock edit history data access --- app/src/api/dataAccess/__mocks__/editHistory.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/api/dataAccess/__mocks__/editHistory.ts b/app/src/api/dataAccess/__mocks__/editHistory.ts index ad84e63b..2e069301 100644 --- a/app/src/api/dataAccess/__mocks__/editHistory.ts +++ b/app/src/api/dataAccess/__mocks__/editHistory.ts @@ -9,14 +9,13 @@ const mockEditHistory = let mockData: EditHistoryEntry[] = []; mockEditHistory.__setHistory = function(mockHistoryData: EditHistoryEntry[]) { - mockData = mockHistoryData; + mockData = mockHistoryData.sort(numDesc(x => BigInt(x.revision_id))); }; mockEditHistory.getHistoryAfterId = function(id: string, count: number): Promise { return Promise.resolve( mockData .filter(x => BigInt(x.revision_id) > BigInt(id)) - .sort(numDesc(x => BigInt(x.revision_id))) .slice(0, count) ); }; @@ -25,16 +24,15 @@ mockEditHistory.getHistoryBeforeId = function(id: string, count: number): Promis return Promise.resolve( mockData .filter(x => BigInt(x.revision_id) < BigInt(id)) - .sort(numDesc(x => BigInt(x.revision_id))) .slice(0, count) ); }; mockEditHistory.getLatestHistory = function(count: number): Promise { + return Promise.resolve( mockData - .slice(mockData.length - count, mockData.length) - .sort(numDesc(x => BigInt(x.revision_id))) + .slice(0, count) ); };