diff --git a/src/logger/__tests__/logDump.test.ts b/src/logger/__tests__/logDump.test.ts new file mode 100644 index 00000000..13599822 --- /dev/null +++ b/src/logger/__tests__/logDump.test.ts @@ -0,0 +1,36 @@ +import {expect, test} from '@jest/globals' + +import {ConsoleTransportEntry, LogLevel} from '#/logger' +import {add, getEntries} from '#/logger/logDump' + +test('works', () => { + const items: ConsoleTransportEntry[] = [ + { + id: '1', + level: LogLevel.Debug, + message: 'hello', + metadata: {}, + timestamp: Date.now(), + }, + { + id: '2', + level: LogLevel.Debug, + message: 'hello', + metadata: {}, + timestamp: Date.now(), + }, + { + id: '3', + level: LogLevel.Debug, + message: 'hello', + metadata: {}, + timestamp: Date.now(), + }, + ] + + for (const item of items) { + add(item) + } + + expect(getEntries()).toEqual(items.reverse()) +}) diff --git a/src/logger/logDump.ts b/src/logger/logDump.ts index 777ff777..ec64bf4b 100644 --- a/src/logger/logDump.ts +++ b/src/logger/logDump.ts @@ -1,4 +1,4 @@ -import {ConsoleTransportEntry} from '#/logger' +import type {ConsoleTransportEntry} from '#/logger' let entries: ConsoleTransportEntry[] = [] diff --git a/src/view/screens/Log.tsx b/src/view/screens/Log.tsx index 9389bd5a..6ae61888 100644 --- a/src/view/screens/Log.tsx +++ b/src/view/screens/Log.tsx @@ -41,7 +41,6 @@ export const LogScreen = observer(function Log({}: NativeStackScreenProps< {getEntries() .slice(0) - .reverse() .map(entry => { return (