-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathjest.setup.js
More file actions
43 lines (36 loc) · 1.16 KB
/
jest.setup.js
File metadata and controls
43 lines (36 loc) · 1.16 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
// Create a mock native implementation that we can control in tests
const createMockNativeModule = () => ({
// Scanning operations
startScan: jest.fn(),
stopScan: jest.fn(),
isScanning: jest.fn(),
// Connection management
connect: jest.fn(),
disconnect: jest.fn(),
isConnected: jest.fn(),
// Service discovery
discoverServices: jest.fn(),
discoverServicesWithCharacteristics: jest.fn(),
getServices: jest.fn(),
getCharacteristics: jest.fn(),
// Characteristic operations
readCharacteristic: jest.fn(),
writeCharacteristic: jest.fn(),
subscribeToCharacteristic: jest.fn(),
unsubscribeFromCharacteristic: jest.fn(),
// Bluetooth state management
isBluetoothEnabled: jest.fn(),
requestBluetoothEnable: jest.fn(),
state: jest.fn(),
subscribeToStateChange: jest.fn(),
});
// Mock react-native-nitro-modules for testing
jest.mock('react-native-nitro-modules', () => ({
NitroModules: {
createHybridObject: jest.fn(() => createMockNativeModule()),
},
}));
// Make the mock creator available globally for tests
global.createMockNativeModule = createMockNativeModule;
// Setup globals for React Native
global.__DEV__ = true;