UNPKG

@segment/analytics-react-native

Version:

The hassle-free way to add Segment analytics to your React-Native app.

28 lines 837 B
export const createMockStore = initialState => { let state = initialState; return { getState: jest.fn((...args) => { // Both overloads return a Promise in the mock for simplicity. // Supports getState() and getState(true). void args; return Promise.resolve(state); }), dispatch: jest.fn(action => { if (typeof action === 'function') { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment state = action(state); } else { state = action.payload; } return Promise.resolve(state); }) }; }; export const createTestPersistor = (storage = {}) => ({ get: async key => Promise.resolve(storage[key]), set: async (key, state) => { storage[key] = state; return Promise.resolve(); } }); //# sourceMappingURL=test-helpers.js.map