Sha256: 584daf5782ac735d420b814ff9764312ed5c159babd7072a032b41cb4929ac7c
Contents?: true
Size: 974 Bytes
Versions: 10
Compression:
Stored size: 974 Bytes
Contents
import { testActionSnapshotWithFixtures } from 'react-redux-test-utils'; import API from 'foremanReact/API'; import { handleSync } from '../SyncButtonActions'; import { successResponse } from './SyncButtonFixtures'; jest.mock('foremanReact/API'); API.post.mockImplementation(async () => successResponse); const fixtures = { 'should handleSync': () => handleSync(), 'should handleSync with error message': () => { API.post.mockImplementationOnce(() => Promise.reject(new Error('Network error!')) ); return handleSync(); }, 'should handleSync with custom error message': () => { API.post.mockImplementationOnce(() => { const customError = new Error('Server error!'); customError.response = { data: { message: 'Custom error to display in a toast' }, }; return Promise.reject(customError); }); return handleSync(); }, }; describe('SyncButton actions', () => testActionSnapshotWithFixtures(fixtures));
Version data entries
10 entries across 10 versions & 1 rubygems