mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-10 09:33:51 +00:00
Created ImageDownloader test
This commit is contained in:
25
test/common/services/ImageDownloader.test.ts
Normal file
25
test/common/services/ImageDownloader.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { ImageDownloader } from '../../../src/common/services/ImageDownloader';
|
||||
import { windowMock } from '../../mocks/WindowMock';
|
||||
|
||||
describe('ImageDownloader', () => {
|
||||
const get = jest.fn();
|
||||
const axios = Mock.of<AxiosInstance>({ get });
|
||||
let imageDownloader: ImageDownloader;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
(global as any).URL = { createObjectURL: () => '' };
|
||||
|
||||
imageDownloader = new ImageDownloader(axios, windowMock);
|
||||
});
|
||||
|
||||
test('calls URL with response type blob', async () => {
|
||||
get.mockResolvedValue({ data: {} });
|
||||
|
||||
await imageDownloader.saveImage('/foo/bar.png', 'my-image.png');
|
||||
|
||||
expect(get).toHaveBeenCalledWith('/foo/bar.png', { responseType: 'blob' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user