forked from expo/expo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocalAuthentication-test.native.ts
28 lines (24 loc) · 1.09 KB
/
LocalAuthentication-test.native.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
import ExpoLocalAuthentication from '../ExpoLocalAuthentication';
import * as LocalAuthentication from '../LocalAuthentication';
beforeEach(() => {
ExpoLocalAuthentication.authenticateAsync.mockReset();
ExpoLocalAuthentication.authenticateAsync.mockImplementation(async () => ({ success: true }));
});
it(`uses options`, async () => {
const options = {
promptMessage: 'Authentication is required',
cancelLabel: 'Abort',
fallbackLabel: 'Use passcode',
disableDeviceFallback: false,
};
await LocalAuthentication.authenticateAsync(options);
expect(ExpoLocalAuthentication.authenticateAsync).toHaveBeenLastCalledWith(options);
});
it(`throws when an invalid message is used`, async () => {
expect(
LocalAuthentication.authenticateAsync({ promptMessage: undefined as any })
).rejects.toThrow();
expect(LocalAuthentication.authenticateAsync({ promptMessage: '' })).rejects.toThrow();
expect(LocalAuthentication.authenticateAsync({ promptMessage: {} as any })).rejects.toThrow();
expect(LocalAuthentication.authenticateAsync({ promptMessage: 123 as any })).rejects.toThrow();
});