-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
auth-configure-test.ts
47 lines (42 loc) · 1.17 KB
/
auth-configure-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { AuthClass as Auth } from '../src/Auth';
import { Credentials } from '@aws-amplify/core';
describe('configure test', () => {
test('throw error when storage is empty', () => {
const opts = {
userPoolId: 'awsUserPoolsId',
userPoolWebClientId: 'awsUserPoolsWebClientId',
region: 'region',
identityPoolId: 'awsCognitoIdentityPoolId',
mandatorySignIn: false,
storage: {},
};
const auth = new Auth(null);
expect.assertions(1);
try {
auth.configure(opts);
} catch (e) {
expect(e).not.toBeNull();
}
});
test('configure Credentials correctly when using different region', () => {
const opts = {
userPoolId: 'us-east-1_awdasd',
userPoolWebClientId: 'awsUserPoolsWebClientId',
region: 'us-east-1',
identityPoolId: 'awsCognitoIdentityPoolId',
identityPoolRegion: 'us-east-2',
};
const spyOn = jest.spyOn(Credentials, 'configure');
const auth = new Auth(null);
expect.assertions(1);
auth.configure(opts);
expect(spyOn).toBeCalledWith(
expect.objectContaining({
region: 'us-east-1',
identityPoolRegion: 'us-east-2',
identityPoolId: 'awsCognitoIdentityPoolId',
userPoolId: 'us-east-1_awdasd',
})
);
});
});