Skip to content

Commit

Permalink
fix: extra data formatting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
spence-s committed Jun 8, 2023
1 parent 58158df commit fcee7ad
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const stringify = (obj: unknown, indent?: number, theme?: Theme) => {
},
});

return stringified.startsWith('{"')
return /^{.*"/.test(stringified)
? ' ' + stringified.replace(/^{/, '').replace(/}$/, '')
: stringified.replace(/^{\n/, '').replace(/\n}$/, '');
};
Expand Down
2 changes: 1 addition & 1 deletion test/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test('formatExtraFields', async (t) => {
extra: 'fields',
}) ?? '',
);
t.is(extraFields, '\n{"extra": "fields"}');
t.is(extraFields, '\n "extra": "fields"');
});

test('formatMethod', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/prettify.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`🕰️ [0:00:00] ✨ INFO test - test: GET 200 http://localhost:3000 hello 100ms ␊
{"extra": "data"}`
"extra": "data"`
Binary file modified test/snapshots/prettify.test.ts.snap
Binary file not shown.

0 comments on commit fcee7ad

Please sign in to comment.