From 636d2f233dca7713d05f01e1005b5d2bf84ca9c4 Mon Sep 17 00:00:00 2001 From: Alex H Date: Thu, 16 Jan 2025 22:17:56 -0500 Subject: [PATCH] Test for isDeepLink Signed-off-by: Alex H --- test/decode.test.ts | 17 +++++++++++++++++ tsconfig.json | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/decode.test.ts diff --git a/test/decode.test.ts b/test/decode.test.ts new file mode 100644 index 00000000..235f6e1f --- /dev/null +++ b/test/decode.test.ts @@ -0,0 +1,17 @@ +import { isDeepLink } from '../app/lib/decode'; + +jest.mock('../app/lib/decode', () => ({ + isDeepLink: jest.fn(), +})); + +describe('isDeepLink', () => { + it('returns true if deep link starts with correct scheme', () => { + //use sample text + const text = 'https://lcw.app/request.html?issuer=issuer.example.com&auth_type=bearer&challenge=4adfe67b-58b3-45d0-8043-cc3f11f75513&vc_request_url=https://dashboard.dcconsortium.org/api/exchange/d7ff30bd-cc7c-4500-92b8-d17f2de33d32/4adfe67b-58b3-45d0-8043-cc3f11f75513/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3ODk2ZjNkNjYyMDNmM2Q5Zjk3YzYyNiIsImlhdCI6MTczNzA2MDE5MSwiZXhwIjoxNzM4MjY5NzkxfQ.f_UnlImw-KJeDuHZXs9vxGNVbo9NQZaDjTXwJhZ12aU'; + + (isDeepLink as jest.Mock).mockReturnValue(true); + + const result = isDeepLink(text); + expect(result).toBe(true); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 7886cc19..907550d0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "jsx": "react", "strict": true - } + }, + "types": ["jest", "node"] }