From f65e5400e8424cffa2eb99c099fbd2126967f803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=C3=B3rio=20Granado=20Magalh=C3=A3es?= Date: Wed, 6 Jul 2022 09:50:39 -0300 Subject: [PATCH] Add tests for validate function (#88) --- packages/siwe/lib/client.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/siwe/lib/client.test.ts b/packages/siwe/lib/client.test.ts index 84b4eb40..bc936407 100644 --- a/packages/siwe/lib/client.test.ts +++ b/packages/siwe/lib/client.test.ts @@ -55,7 +55,15 @@ describe(`Message verification without suppressExceptions`, () => { domain: (test_fields as any).domainBinding, nonce: (test_fields as any).matchNonce, }) - .then(({ success }) => success) + // when validate is removed uncomment this and remove the following then + // .then(({ success }) => success) + .then(async ({ data }) => { + jest + .useFakeTimers() + .setSystemTime(new Date((test_fields as any).time || test_fields.issuedAt)); + const res = await msg.validate(test_fields.signature); + return res === data; + }) ).resolves.toBeTruthy(); } );