Files

21 lines
861 B
JavaScript

import axios from 'axios'
import { downloadProvisioningBatch } from '@/api/sense/provisioning'
import { getToken } from '@/utils/auth'
jest.mock('axios', () => ({ get: jest.fn() }))
jest.mock('@/utils/auth', () => ({ getToken: jest.fn() }))
jest.mock('@/utils/request', () => jest.fn())
describe('Sense provisioning result export', () => {
test('downloads the audited server export as a blob', async() => {
const blob = new Blob(['status'], { type: 'text/csv' })
getToken.mockReturnValue('synthetic-token')
axios.get.mockResolvedValue({ data: blob })
await expect(downloadProvisioningBatch('batch-1')).resolves.toBe(blob)
expect(axios.get).toHaveBeenCalledWith(expect.stringContaining('/api/v1/provisioning/batches/batch-1/export'), {
responseType: 'blob',
headers: { Authorization: 'Bearer synthetic-token' }
})
})
})