forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
46 lines (42 loc) · 1.47 KB
/
Copy pathsetup.js
File metadata and controls
46 lines (42 loc) · 1.47 KB
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
// Mock the native modules
jest.mock('react-native', () => {
const RN = jest.requireActual('react-native');
RN.NativeModules.OmiModule = {
connect: jest.fn(() => Promise.resolve()),
disconnect: jest.fn(() => Promise.resolve()),
isConnected: jest.fn(() => Promise.resolve(false)),
getAudioCodec: jest.fn(() => Promise.resolve(1)),
startAudioBytesNotifications: jest.fn(() => Promise.resolve()),
stopAudioBytesNotifications: jest.fn(() => Promise.resolve()),
getBatteryLevel: jest.fn(() => Promise.resolve(100)),
startScan: jest.fn(() => Promise.resolve()),
stopScan: jest.fn(() => Promise.resolve()),
};
return RN;
});
// Mock the BLE library
jest.mock('react-native-ble-plx', () => {
return {
BleManager: jest.fn().mockImplementation(() => {
return {
startDeviceScan: jest.fn(),
stopDeviceScan: jest.fn(),
connectToDevice: jest.fn(() => Promise.resolve({
id: 'test-device-id',
name: 'Test Device',
discoverAllServicesAndCharacteristics: jest.fn(() => Promise.resolve()),
services: jest.fn(() => Promise.resolve([])),
cancelConnection: jest.fn(() => Promise.resolve()),
onDisconnected: jest.fn(() => ({ remove: jest.fn() })),
})),
state: jest.fn(() => Promise.resolve('PoweredOn')),
};
}),
Subscription: jest.fn(),
Device: jest.fn(),
};
});
// Mock base-64
jest.mock('base-64', () => ({
decode: jest.fn((str) => str),
}));