Add logDump tests, ensure Log screen is reversed

zio/stable
Eric Bailey 2023-11-04 13:09:12 -05:00
parent 7e29ebbadb
commit 0c76866757
3 changed files with 37 additions and 2 deletions

View File

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

View File

@ -1,4 +1,4 @@
import {ConsoleTransportEntry} from '#/logger'
import type {ConsoleTransportEntry} from '#/logger'
let entries: ConsoleTransportEntry[] = []

View File

@ -41,7 +41,6 @@ export const LogScreen = observer(function Log({}: NativeStackScreenProps<
<ScrollView style={s.flex1}>
{getEntries()
.slice(0)
.reverse()
.map(entry => {
return (
<View key={`entry-${entry.id}`}>