-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathaddDefaultLocalAuthOptions.spec.js
41 lines (38 loc) · 1.71 KB
/
addDefaultLocalAuthOptions.spec.js
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
import LocalAuthenticationLevel from '../../credentials-manager/localAuthenticationLevel';
import addDefaultLocalAuthOptions from '../addDefaultLocalAuthOptions';
import LocalAuthenticationStrategy from '../../credentials-manager/localAuthenticationStrategy';
describe('addDefaultLocalAuthenticationOptions', () => {
it('should return default options when no options are provided', () => {
const localAuthOptions = { title: 'Please authenticate' };
const result = addDefaultLocalAuthOptions(localAuthOptions);
expect(result).toEqual({
title: 'Please authenticate',
authenticationLevel: LocalAuthenticationLevel.strong,
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics,
deviceCredentialFallback: false,
});
});
it('should override default options with provided options', () => {
const localAuthOptions = {
title: 'Please authenticate',
authenticationLevel: LocalAuthenticationLevel.deviceCredential,
evaluationPolicy: LocalAuthenticationStrategy.deviceOwner,
deviceCredentialFallback: false,
};
const result = addDefaultLocalAuthOptions(localAuthOptions);
expect(result).toEqual(localAuthOptions);
});
it('should merge default options with partially provided options', () => {
const options = {
title: 'Please authenticate',
authenticationLevel: LocalAuthenticationLevel.deviceCredential,
};
const result = addDefaultLocalAuthOptions(options);
expect(result).toEqual({
title: 'Please authenticate',
authenticationLevel: LocalAuthenticationLevel.deviceCredential,
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics,
deviceCredentialFallback: false,
});
});
});