mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
24 lines
834 B
TypeScript
24 lines
834 B
TypeScript
import { fromPartial } from '@total-typescript/shoehorn';
|
|
import type { HttpClient } from '../../../src/common/services/HttpClient';
|
|
import { ImageDownloader } from '../../../src/common/services/ImageDownloader';
|
|
import { windowMock } from '../../__mocks__/Window.mock';
|
|
|
|
describe('ImageDownloader', () => {
|
|
const fetchBlob = vi.fn();
|
|
const httpClient = fromPartial<HttpClient>({ fetchBlob });
|
|
let imageDownloader: ImageDownloader;
|
|
|
|
beforeEach(() => {
|
|
(global as any).URL = { createObjectURL: () => '' };
|
|
|
|
imageDownloader = new ImageDownloader(httpClient, windowMock);
|
|
});
|
|
|
|
it('calls URL with response type blob', async () => {
|
|
fetchBlob.mockResolvedValue(new Blob());
|
|
|
|
await imageDownloader.saveImage('/foo/bar.png', 'my-image.png');
|
|
|
|
expect(fetchBlob).toHaveBeenCalledWith('/foo/bar.png');
|
|
});
|
|
});
|