Skip to content

Commit

Permalink
mock asyncstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran committed Nov 18, 2024
1 parent 945bc60 commit a69821d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
15 changes: 14 additions & 1 deletion sdk/__mocks__/@react-native-async-storage/async-storage.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
export * from '@react-native-async-storage/async-storage/jest/async-storage-mock';
export * from '@react-native-async-storage/async-storage/jest/async-storage-mock';

export default {
getItem: (item, value = null) => {
return new Promise((resolve, reject) => {
resolve(value);
});
},
setItem: (item, value) => {
return new Promise((resolve, reject) => {
resolve(value);
});
}
}
14 changes: 12 additions & 2 deletions sdk/__tests__/RaygunClient.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { init, sendError } from '../src/RaygunClient';
import { RaygunClientOptions } from '../src/Types';

// jest.mock('../RaygunClient');

Expand All @@ -9,9 +10,18 @@ describe('RaygunClient', () => {
// NativeModules.RaygunNativeBridge = { DEVICE_ID: 'test-device-id' };
// });

it('should send error correctly', () => {
it('should send error correctly', async () => {
const options: RaygunClientOptions = {
apiKey: '',// Your API key
version: '', // Your application version
enableCrashReporting: true,
enableRealUserMonitoring: false,
disableNativeCrashReporting: true,
};

init(options);
const error = new Error('Test error');
sendError(error);
await sendError(error);

// expect(raygunClient.sendError).toHaveBeenCalledWith(error);
});
Expand Down

0 comments on commit a69821d

Please sign in to comment.