1import ExpoLocalAuthentication from '../ExpoLocalAuthentication';
2import * as LocalAuthentication from '../LocalAuthentication';
3
4beforeEach(() => {
5  ExpoLocalAuthentication.authenticateAsync.mockReset();
6  ExpoLocalAuthentication.authenticateAsync.mockImplementation(async () => ({ success: true }));
7});
8
9it(`uses options`, async () => {
10  const options = {
11    promptMessage: 'Authentication is required',
12    cancelLabel: 'Abort',
13    fallbackLabel: 'Use passcode',
14    disableDeviceFallback: false,
15    requireConfirmation: true,
16  };
17  await LocalAuthentication.authenticateAsync(options);
18
19  expect(ExpoLocalAuthentication.authenticateAsync).toHaveBeenLastCalledWith(options);
20});
21
22it(`throws when an invalid message is used`, async () => {
23  expect(
24    LocalAuthentication.authenticateAsync({ promptMessage: undefined as any })
25  ).rejects.toThrow();
26  expect(LocalAuthentication.authenticateAsync({ promptMessage: '' })).rejects.toThrow();
27  expect(LocalAuthentication.authenticateAsync({ promptMessage: {} as any })).rejects.toThrow();
28  expect(LocalAuthentication.authenticateAsync({ promptMessage: 123 as any })).rejects.toThrow();
29});
30