Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix promise that never completes [SDK-3216] #464

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/webauth/__tests__/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ 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) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const callback = args[args.length - 1];
callback(null, null);
};
expect.assertions(1);
try {
await agent.show('https://auth0.com');
fail('should have thrown error');
} 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