Skip to content

Commit

Permalink
Fix promise that never completes [SDK-3216] (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Mar 18, 2022
1 parent ea5f4d1 commit 891e5b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/webauth/__tests__/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ describe('Agent', () => {
A0Auth0.error = new Error('failed to load');
await expect(agent.show('https://auth0.com')).rejects.toMatchSnapshot();
});

it('should reject with error when both error and redirectURL are missing', async () => {
NativeModules.A0Auth0.showUrl = (...args) => {
const callback = args[args.length - 1];
callback(null, null);
};
expect.assertions(1);
try {
await agent.show('https://auth0.com');
} catch (e) {
expect(e).toEqual(new Error('Unknown WebAuth error'));
}
});
});
});

Expand Down
2 changes: 2 additions & 0 deletions src/webauth/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export default class Agent {
resolve(redirectURL);
} else if (closeOnLoad) {
resolve();
} else {
reject(new Error('Unknown WebAuth error'));
}
});
});
Expand Down

0 comments on commit 891e5b1

Please sign in to comment.