Skip to content

Commit

Permalink
feat: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spence-s committed Jun 8, 2023
1 parent fcee7ad commit 67173ff
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
},
"ava": {
"environmentVariables": {
"NODE_OPTIONS": "-r ts-node/register/transpile-only",
"TZ": "EST"
"NODE_OPTIONS": "-r ts-node/register/transpile-only"
},
"extensions": [
"ts"
Expand Down
32 changes: 32 additions & 0 deletions test/prettify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,38 @@ test('full log line with all data and extra data', (t) => {
t.snapshot(output);
});

test('full log line with all data and extra data multiline', (t) => {
const time = new Date('2020-01-01T00:00:00.000Z');
const input = JSON.stringify({
level: 30,
time,
res: {
statusCode: 200,
something: 'extra',
},
req: {
method: 'GET',
url: 'http://localhost:3000',
something: 'extra',
},
name: 'test',
ns: 'test',
msg: 'hello',
responseTime: 100,
extra: 'data',
multi: 'line',
idk: 'what',
else: 'to add',
for: {
extra: 'data',
},
});

const output = t.context.prettify(input);

t.snapshot(output);
});

// export const WHITE_LIST = [
// 'res.statusCode',
// 'req.method',
Expand Down
11 changes: 11 additions & 0 deletions test/snapshots/prettify.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,14 @@ Generated by [AVA](https://avajs.dev).
`πŸ•°οΈ [0:00:00] ✨ INFO test - test: GET 200 http://localhost:3000 hello 100ms ␊
"extra": "data"`

## full log line with all data and extra data multiline

> Snapshot 1
`πŸ•°οΈ [0:00:00] ✨ INFO test - test: GET 200 http://localhost:3000 hello 100ms ␊
"extra": "data",␊
"multi": "line",␊
"idk": "what",␊
"else": "to add",␊
"for": {"extra": "data"}`
Binary file modified test/snapshots/prettify.test.ts.snap
Binary file not shown.

0 comments on commit 67173ff

Please sign in to comment.