Skip to content

Commit

Permalink
Made options argument for popup and redirect optional (#61)
Browse files Browse the repository at this point in the history
* Made options argument for popup and redirect optional

* Added no arguments test for loginWithPopup
  • Loading branch information
Steve Hobbs authored and luisrudge committed Jul 11, 2019
1 parent f8a4bc4 commit 051ad6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions src/Auth0Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 051ad6d

Please sign in to comment.