Skip to content

Commit

Permalink
tests: tighten test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 23, 2023
1 parent a4b20e8 commit 85f4381
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/address/isAddressEqual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('errors', () => {
`)
expect(() =>
isAddressEqual(
'0xa5cc3c03994db5b0d9a5eEdD10Cabab0813678aff',
'0xa5cc3c03994db5b0d9a5eEdD10Cabab0813678ac',
'0xa5cc3c03994db5b0d9a5eEdD10Cabab0813678aff',
),
).toThrowErrorMatchingInlineSnapshot(`
"Address \\"0xa5cc3c03994db5b0d9a5eEdD10Cabab0813678aff\\" is invalid.
Expand Down
1 change: 1 addition & 0 deletions src/utils/data/isBytes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import { isBytes } from './isBytes'
test('is bytes', () => {
expect(isBytes(new Uint8Array([1, 69, 420])))
expect(isBytes('0x1')).toBeFalsy()
expect(isBytes({})).toBeFalsy()
expect(isBytes(undefined)).toBeFalsy()
})
41 changes: 41 additions & 0 deletions src/utils/stringify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,44 @@ test('default', () => {
}),
).toEqual('{"foo":"bar","baz":{"value":"69"}}')
})

test('args: replacer', () => {
expect(
stringify(
{
foo: 'bar',
baz: {
value: 69n,
},
},
(key, value) => {
if (key === 'value') {
return `${value}!`
}
return value
},
),
).toEqual('{"foo":"bar","baz":{"value":"69!"}}')
})

test('args: space', () => {
expect(
stringify(
{
foo: 'bar',
baz: {
value: 69n,
},
},
null,
2,
),
).toMatchInlineSnapshot(`
"{
\\"foo\\": \\"bar\\",
\\"baz\\": {
\\"value\\": \\"69\\"
}
}"
`)
})

0 comments on commit 85f4381

Please sign in to comment.