|
| 1 | +import AvFilesDelivery from '../filesDelivery'; |
| 2 | + |
| 3 | +const mockHttp = jest.fn(() => Promise.resolve({})); |
| 4 | +const mockMerge = jest.fn((...args) => Object.assign(...args)); |
| 5 | + |
| 6 | +const mockConfig = { |
| 7 | + clientId: '123-456', |
| 8 | + customerId: '1194', |
| 9 | +}; |
| 10 | + |
| 11 | +describe('AvFileDelivery', () => { |
| 12 | + let api; |
| 13 | + |
| 14 | + test('should be defined', () => { |
| 15 | + api = new AvFilesDelivery({ |
| 16 | + http: mockHttp, |
| 17 | + promise: Promise, |
| 18 | + merge: mockMerge, |
| 19 | + config: {}, |
| 20 | + }); |
| 21 | + expect(api).toBeDefined(); |
| 22 | + }); |
| 23 | + |
| 24 | + test('should handle no config passed in', () => { |
| 25 | + api = new AvFilesDelivery({ |
| 26 | + http: mockHttp, |
| 27 | + promise: Promise, |
| 28 | + merge: mockMerge, |
| 29 | + }); |
| 30 | + expect(api).toBeDefined(); |
| 31 | + }); |
| 32 | + |
| 33 | + test('post url should be correct', () => { |
| 34 | + api = new AvFilesDelivery({ |
| 35 | + http: mockHttp, |
| 36 | + promise: Promise, |
| 37 | + merge: mockMerge, |
| 38 | + }); |
| 39 | + expect(api.getUrl(mockConfig)).toBe( |
| 40 | + '/ms/api/availity/internal/platform/file-upload-delivery/v1/batch/deliveries' |
| 41 | + ); |
| 42 | + }); |
| 43 | + |
| 44 | + test('uploadFile() should call create for reference passed', () => { |
| 45 | + api = new AvFilesDelivery({ |
| 46 | + http: mockHttp, |
| 47 | + promise: Promise, |
| 48 | + merge: mockMerge, |
| 49 | + config: {}, |
| 50 | + }); |
| 51 | + |
| 52 | + const data = { |
| 53 | + deliveries: [ |
| 54 | + { |
| 55 | + fileURI: 'uri', |
| 56 | + deliveryChannel: 'DEMO', |
| 57 | + metadata: { |
| 58 | + payerId: 'test_payerId', |
| 59 | + requestId: '123', |
| 60 | + patientLastName: 'lastName', |
| 61 | + patientFirstName: 'firstName', |
| 62 | + }, |
| 63 | + }, |
| 64 | + ], |
| 65 | + }; |
| 66 | + |
| 67 | + api.create = jest.fn(); |
| 68 | + api.uploadFilesDelivery(data, mockConfig); |
| 69 | + expect(api.create).toHaveBeenLastCalledWith(data, api.config(mockConfig)); |
| 70 | + }); |
| 71 | +}); |
0 commit comments