forked from react-native-sensors/react-native-sensors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock.js
35 lines (30 loc) · 785 Bytes
/
mock.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
/**
* Library mock for test runners. e.g.:
*
* ```js
* jest.mock('react-native-sensors', () => require('react-native-sensors/mock'));
* ```
*/
const sensorMock = (observerValue) => ({
subscribe: (observer) => {
observer(observerValue || { x: 0, y: 0, z: 0, timestamp: 0 })
return ({ unsubscribe: jest.fn() })
},
})
const rnSensors = {
SensorTypes: {
accelerometer: 'accelerometer',
gyroscope: 'gyroscope',
magnetometer: 'magnetometer',
barometer: 'barometer',
gravity: 'gravity'
},
accelerometer: sensorMock(),
gyroscope: sensorMock(),
magnetometer: sensorMock(),
barometer: sensorMock({ pressure: 0 }),
gravity: sensorMock(),
setLogLevelForType: jest.fn(),
setUpdateIntervalForType: jest.fn(),
}
module.exports = rnSensors