|
| 1 | +const mockCallback = (callback) => { |
| 2 | + if (typeof callback === 'function') { |
| 3 | + callback(null, []); |
| 4 | + } |
| 5 | +}; |
| 6 | + |
| 7 | +const mockFunctionWithCallback = jest.fn().mockImplementation(mockCallback); |
| 8 | + |
| 9 | +const mockBloodPressureCallback = jest |
| 10 | + .fn() |
| 11 | + .mockImplementation((_, callback) => { |
| 12 | + callback(null, [ |
| 13 | + { |
| 14 | + bloodPressureSystolicValue: 120, |
| 15 | + bloodPressureDiastolicValue: 80, |
| 16 | + startDate: '2023-01-01', |
| 17 | + endDate: '2023-01-01', |
| 18 | + id: 'bp-mock-1', |
| 19 | + sourceId: 'test-source', |
| 20 | + }, |
| 21 | + ]); |
| 22 | + }); |
| 23 | + |
| 24 | +const mockOxygenSaturationCallback = jest |
| 25 | + .fn() |
| 26 | + .mockImplementation((_, callback) => { |
| 27 | + callback(null, [ |
| 28 | + { |
| 29 | + value: 0.98, |
| 30 | + unit: 'percent', |
| 31 | + startDate: '2023-01-01', |
| 32 | + endDate: '2023-01-01', |
| 33 | + id: 'o2-mock-1', |
| 34 | + }, |
| 35 | + ]); |
| 36 | + }); |
| 37 | + |
| 38 | +module.exports = { |
| 39 | + initHealthKit: jest.fn().mockImplementation((options, callback) => { |
| 40 | + if (typeof callback === 'function') { |
| 41 | + callback(null, true); |
| 42 | + } |
| 43 | + }), |
| 44 | + |
| 45 | + isAvailable: jest.fn().mockImplementation((callback) => { |
| 46 | + callback(null, true); |
| 47 | + }), |
| 48 | + |
| 49 | + getBloodGlucoseSamples: mockFunctionWithCallback, |
| 50 | + getHeightSamples: mockFunctionWithCallback, |
| 51 | + getWeightSamples: mockFunctionWithCallback, |
| 52 | + getHeartRateSamples: mockFunctionWithCallback, |
| 53 | + getRestingHeartRateSamples: mockFunctionWithCallback, |
| 54 | + getOxygenSaturationSamples: mockOxygenSaturationCallback, |
| 55 | + getBloodPressureSamples: mockBloodPressureCallback, |
| 56 | + getDailyStepCountSamples: mockFunctionWithCallback, |
| 57 | + getActiveEnergyBurned: mockFunctionWithCallback, |
| 58 | + getBasalEnergyBurned: mockFunctionWithCallback, |
| 59 | + |
| 60 | + saveBloodGlucoseSample: jest.fn().mockImplementation((data, callback) => { |
| 61 | + if (typeof callback === 'function') { |
| 62 | + callback(null, true); |
| 63 | + } |
| 64 | + }), |
| 65 | + saveHeight: jest.fn().mockImplementation((data, callback) => { |
| 66 | + if (typeof callback === 'function') { |
| 67 | + callback(null, true); |
| 68 | + } |
| 69 | + }), |
| 70 | + saveWeight: jest.fn().mockImplementation((data, callback) => { |
| 71 | + if (typeof callback === 'function') { |
| 72 | + callback(null, true); |
| 73 | + } |
| 74 | + }), |
| 75 | + saveHeartRateSample: jest.fn().mockImplementation((data, callback) => { |
| 76 | + if (typeof callback === 'function') { |
| 77 | + callback(null, true); |
| 78 | + } |
| 79 | + }), |
| 80 | + saveSteps: jest.fn().mockImplementation((data, callback) => { |
| 81 | + if (typeof callback === 'function') { |
| 82 | + callback(null, true); |
| 83 | + } |
| 84 | + }), |
| 85 | + |
| 86 | + Constants: { |
| 87 | + Permissions: { |
| 88 | + BloodGlucose: 'BloodGlucose', |
| 89 | + Height: 'Height', |
| 90 | + Weight: 'Weight', |
| 91 | + HeartRate: 'HeartRate', |
| 92 | + RestingHeartRate: 'RestingHeartRate', |
| 93 | + BloodPressureDiastolic: 'BloodPressureDiastolic', |
| 94 | + BloodPressureSystolic: 'BloodPressureSystolic', |
| 95 | + OxygenSaturation: 'OxygenSaturation', |
| 96 | + Steps: 'Steps', |
| 97 | + ActiveEnergyBurned: 'ActiveEnergyBurned', |
| 98 | + BasalEnergyBurned: 'BasalEnergyBurned', |
| 99 | + }, |
| 100 | + Units: { |
| 101 | + gram: 'gram', |
| 102 | + kilogram: 'kilogram', |
| 103 | + ounce: 'ounce', |
| 104 | + pound: 'pound', |
| 105 | + meter: 'meter', |
| 106 | + inch: 'inch', |
| 107 | + foot: 'foot', |
| 108 | + centimeter: 'centimeter', |
| 109 | + bpm: 'count/min', |
| 110 | + calories: 'kcal', |
| 111 | + count: 'count', |
| 112 | + percent: 'percent', |
| 113 | + mmhg: 'mmHg', |
| 114 | + mmolPerL: 'mmol<180.1558800000541>/L', |
| 115 | + mgPerdL: 'mg/dL', |
| 116 | + }, |
| 117 | + }, |
| 118 | + |
| 119 | + getDateOfBirth: mockFunctionWithCallback, |
| 120 | + getBiologicalSex: mockFunctionWithCallback, |
| 121 | + getLatestWeight: mockFunctionWithCallback, |
| 122 | + getLatestHeight: mockFunctionWithCallback, |
| 123 | + getLatestBmi: mockFunctionWithCallback, |
| 124 | +}; |
0 commit comments