Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Kumar committed May 29, 2024
1 parent c1fbd39 commit 1f7703c
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions packages/auth/__tests__/auth-unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3820,36 +3820,18 @@ describe('auth unit test', () => {

test('should call urlListener by default', async () => {
const urlListenerSpy = jest.spyOn(urlListener, 'default');
const options: AuthOptions = {
region: 'region',
userPoolId: 'userPoolId',
oauth: {
domain: 'mydomain.auth.us-east-1.amazoncognito.com',
scope: ['aws.cognito.signin.user.admin'],
redirectSignIn: 'http://localhost:3000/',
redirectSignOut: 'http://localhost:3000/',
responseType: 'code',
},
identityPoolId: 'awsCognitoIdentityPoolId',
};
new Auth(options);
new Auth(authOptionsWithHostedUIConfig);
expect(urlListenerSpy).toHaveBeenCalledTimes(1);
});

test('should not call urlListener when IDP initiated oauth is disabled', async () => {
const urlListenerSpy = jest.spyOn(urlListener, 'default');
const options: AuthOptions = {
region: 'region',
userPoolId: 'userPoolId',
...authOptionsWithHostedUIConfig,
oauth: {
domain: 'mydomain.auth.us-east-1.amazoncognito.com',
scope: ['aws.cognito.signin.user.admin'],
redirectSignIn: 'http://localhost:3000/',
redirectSignOut: 'http://localhost:3000/',
responseType: 'code',
...authOptionsWithHostedUIConfig.oauth!,
idpEnabled: false,
},
identityPoolId: 'awsCognitoIdentityPoolId',
};
new Auth(options);
expect(urlListenerSpy).not.toHaveBeenCalled();
Expand All @@ -3865,17 +3847,11 @@ describe('auth unit test', () => {
const urlListenerSpy = jest.spyOn(urlListener, 'default');

const options: AuthOptions = {
region: 'region',
userPoolId: 'userPoolId',
...authOptionsWithHostedUIConfig,
oauth: {
domain: 'mydomain.auth.us-east-1.amazoncognito.com',
scope: ['aws.cognito.signin.user.admin'],
redirectSignIn: 'http://localhost:3000/',
redirectSignOut: 'http://localhost:3000/',
responseType: 'code',
...authOptionsWithHostedUIConfig.oauth!,
idpEnabled: false,
},
identityPoolId: 'awsCognitoIdentityPoolId',
};
new Auth(options);
expect(urlListenerSpy).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 1f7703c

Please sign in to comment.