import { ResourceBrowserSource, ResourceBrowserResource, ResourceBrowserPlugin, ResourceBrowserSourceWithPlugin } from '../types'; export type DeepPartial = { [P in keyof T]?: T[P] extends Array ? Array> : T[P] extends ReadonlyArray ? ReadonlyArray> : DeepPartial; }; export const mockSource = (properties: Partial = {}): ResourceBrowserSource => { return { id: '1', name: 'Test source', type: 'dam', ...properties, }; }; export const mockSourceWithPlugin = (properties: Partial = {}): ResourceBrowserSourceWithPlugin => { return { id: '1', name: 'Test source', type: 'dam', plugin: mockPlugin(), ...properties, }; }; export const mockPlugin = (properties: DeepPartial = {}): ResourceBrowserPlugin => { return { type: 'dam', // @ts-ignore sourceBrowserComponent: jest.fn(), // @ts-ignore renderSelectedResource: jest.fn(), // @ts-ignore resolveResource: jest.fn(), // @ts-ignore sourceSearchComponent: jest.fn(), // @ts-ignore renderResourceLauncher: jest.fn(), ...properties, }; }; export const mockResource = (properties: Partial = {}): ResourceBrowserResource => { return { id: '1', name: 'Resource 1', url: '', source: { id: '1', type: 'dam', }, type: { code: 'jpeg', name: 'JPEG image', }, squizImage: { name: 'an-image-name', imageVariations: { original: { width: 1024, height: 900, url: 'an-image-url', mimeType: 'image/jpeg', byteSize: 1068, sha1Hash: '', aspectRatio: '', }, }, }, ...properties, }; };