Skip to content

Commit

Permalink
test(clerk-js): Added tests for normalizeRoutingOptions utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Nov 2, 2023
1 parent a305773 commit 69b523d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/clerk-js/src/ui/common/__tests__/authPropHelpers.test.ts
Original file line number Diff line number Diff line change
@@ -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' });
});
});
});

0 comments on commit 69b523d

Please sign in to comment.