Fix mock edit history data access
This commit is contained in:
parent
2d4682685b
commit
60d087c424
@ -9,14 +9,13 @@ const mockEditHistory =
|
|||||||
let mockData: EditHistoryEntry[] = [];
|
let mockData: EditHistoryEntry[] = [];
|
||||||
|
|
||||||
mockEditHistory.__setHistory = function(mockHistoryData: 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<EditHistoryEntry[]> {
|
mockEditHistory.getHistoryAfterId = function(id: string, count: number): Promise<EditHistoryEntry[]> {
|
||||||
return Promise.resolve(
|
return Promise.resolve(
|
||||||
mockData
|
mockData
|
||||||
.filter(x => BigInt(x.revision_id) > BigInt(id))
|
.filter(x => BigInt(x.revision_id) > BigInt(id))
|
||||||
.sort(numDesc(x => BigInt(x.revision_id)))
|
|
||||||
.slice(0, count)
|
.slice(0, count)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -25,16 +24,15 @@ mockEditHistory.getHistoryBeforeId = function(id: string, count: number): Promis
|
|||||||
return Promise.resolve(
|
return Promise.resolve(
|
||||||
mockData
|
mockData
|
||||||
.filter(x => BigInt(x.revision_id) < BigInt(id))
|
.filter(x => BigInt(x.revision_id) < BigInt(id))
|
||||||
.sort(numDesc(x => BigInt(x.revision_id)))
|
|
||||||
.slice(0, count)
|
.slice(0, count)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
mockEditHistory.getLatestHistory = function(count: number): Promise<EditHistoryEntry[]> {
|
mockEditHistory.getLatestHistory = function(count: number): Promise<EditHistoryEntry[]> {
|
||||||
|
|
||||||
return Promise.resolve(
|
return Promise.resolve(
|
||||||
mockData
|
mockData
|
||||||
.slice(mockData.length - count, mockData.length)
|
.slice(0, count)
|
||||||
.sort(numDesc(x => BigInt(x.revision_id)))
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user