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' }); + }); + }); +});