diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index d781d0645..88fd92026 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -246,6 +246,12 @@ describe('Auth0', () => { { daysUntilExpire: 1 } ); }); + it('can be called with no arguments', async () => { + const { auth0, utils } = await setup(); + + await auth0.loginWithPopup(); + expect(utils.openPopup).toHaveBeenCalled(); + }); }); describe('loginWithRedirect()', () => { const REDIRECT_OPTIONS = { @@ -347,6 +353,15 @@ describe('Auth0', () => { `https://test.auth0.com/authorize?query=params${TEST_TELEMETRY_QUERY_STRING}` ); }); + it('can be called with no arguments', async () => { + const { auth0 } = await setup(); + + await auth0.loginWithRedirect(); + + expect(window.location.assign).toHaveBeenCalledWith( + `https://test.auth0.com/authorize?query=params${TEST_TELEMETRY_QUERY_STRING}` + ); + }); }); describe('handleRedirectCallback()', () => { it('throws when there is no query string', async () => { diff --git a/src/Auth0Client.ts b/src/Auth0Client.ts index 06944ccc0..891c38796 100644 --- a/src/Auth0Client.ts +++ b/src/Auth0Client.ts @@ -98,7 +98,7 @@ export default class Auth0Client { * * @param options */ - public async loginWithPopup(options: PopupLoginOptions) { + public async loginWithPopup(options: PopupLoginOptions = {}) { const popup = await openPopup(); const { ...authorizeOptions } = options; const stateIn = encodeState(createRandomString()); @@ -191,7 +191,7 @@ export default class Auth0Client { * * @param options */ - public async loginWithRedirect(options: RedirectLoginOptions) { + public async loginWithRedirect(options: RedirectLoginOptions = {}) { const { redirect_uri, appState, ...authorizeOptions } = options; const stateIn = encodeState(createRandomString()); const nonceIn = createRandomString();