From 69b523dc471cd7d4fff8b630738d0dce71552f60 Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Wed, 1 Nov 2023 13:45:34 +0200 Subject: [PATCH] test(clerk-js): Added tests for normalizeRoutingOptions utility function --- .../common/__tests__/authPropHelpers.test.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/clerk-js/src/ui/common/__tests__/authPropHelpers.test.ts diff --git a/packages/clerk-js/src/ui/common/__tests__/authPropHelpers.test.ts b/packages/clerk-js/src/ui/common/__tests__/authPropHelpers.test.ts new file mode 100644 index 00000000000..31cc156f659 --- /dev/null +++ b/packages/clerk-js/src/ui/common/__tests__/authPropHelpers.test.ts @@ -0,0 +1,20 @@ +import { normalizeRoutingOptions } from '../../../utils/authPropHelpers'; + +describe('auth prop helpers', () => { + describe('normalizeRoutingOptions', () => { + it("returns routing: 'path' if path was provided and no routing was provided", () => { + expect(normalizeRoutingOptions({ path: 'test' })).toEqual({ routing: 'path', path: 'test' }); + }); + + it('returns routing: null if path was provided and routing was null (avoid breaking integrations)', () => { + // @ts-expect-error Need to test this case + expect(normalizeRoutingOptions({ path: 'test', routing: null })).toEqual({ routing: null, path: 'test' }); + }); + + it('returns the same options if routing was provided (any routing) and path was provided (avoid breaking integrations)', () => { + expect(normalizeRoutingOptions({ routing: 'path', path: 'test' })).toEqual({ routing: 'path', path: 'test' }); + expect(normalizeRoutingOptions({ routing: 'hash', path: 'test' })).toEqual({ routing: 'hash', path: 'test' }); + expect(normalizeRoutingOptions({ routing: 'virtual' })).toEqual({ routing: 'virtual' }); + }); + }); +});