Skip to content

Commit

Permalink
test(siwe): sub/multi-level domains
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Jun 4, 2024
1 parent b58afe1 commit 17fa3b2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/utils/siwe/createSiweMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,47 @@ test('default', () => {
vi.useRealTimers()
})

test('parameters: domain', () => {
vi.useFakeTimers()
vi.setSystemTime(new Date(Date.UTC(2023, 1, 1)))

expect(
createSiweMessage({
...message,
domain: 'foo.example.com',
}),
).toMatchInlineSnapshot(`
"foo.example.com wants you to sign in with your Ethereum account:
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
URI: https://example.com/path
Version: 1
Chain ID: 1
Nonce: foobarbaz
Issued At: 2023-02-01T00:00:00.000Z"
`)

expect(
createSiweMessage({
...message,
domain: 'example.co.uk',
}),
).toMatchInlineSnapshot(`
"example.co.uk wants you to sign in with your Ethereum account:
0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
URI: https://example.com/path
Version: 1
Chain ID: 1
Nonce: foobarbaz
Issued At: 2023-02-01T00:00:00.000Z"
`)

vi.useRealTimers()
})

test('parameters: scheme', () => {
vi.useFakeTimers()
vi.setSystemTime(new Date(Date.UTC(2023, 1, 1)))
Expand Down

0 comments on commit 17fa3b2

Please sign in to comment.