Sha256: 2f44b7b98eb78fddd5afd7de9fef802b0a3c83993505b5e5fcb2a9c67b44070b
Contents?: true
Size: 968 Bytes
Versions: 9
Compression:
Stored size: 968 Bytes
Contents
import { testActionSnapshotWithFixtures } from '@theforeman/test'; 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
9 entries across 9 versions & 1 rubygems