Media test data
Sample data to be used in Media tests
yarn add @atlaskit/media-test-data
3.0.0
Major Changes
-
#117363
10a0f7f6c2027
- This package'speerDependencies
have been adjusted forreact
and/orreact-dom
to reflect the status of only supporting React 18 going forward. No explicit breaking change to React support has been made in this release, but this is to signify going forward, breaking changes for React 16 or React 17 may come via non-major semver releases.Please refer this community post for more details: https://community.developer.atlassian.com/t/rfc-78-dropping-support-for-react-16-and-rendering-in-a-react-18-concurrent-root-in-jira-and-confluence/87026
Patch Changes
- Updated dependencies
Sample data to be used in Media tests
Data for Media Api Mocks
File Metadata
To create Media Api Mocks, it is convenient to have a preset of file metadata to be returned from the metadata endpoints.
The exported object generateSampleFileItem
includes a set of functions dedicated to generate file metadata for different file types and processing states.
The returned value includes in a tuple a ResponseFileItem (return type of metadata endpoints) and a FileIdentifier that can be used to reference the file from the testing subject.
Example:
import { MockedMediaClientProvider } from '@atlaskit/media-client-react/test-helpers';
import { createMockedMediaApi } from '@atlaskit/media-client/test-helpers';
import { generateSampleFileItem } from '@atlaskit/media-test-data';
// Create metadata of an image that has successfuly been processed
const [imageResponseFileItem, imageFileIdentifier] = generateSampleFileItem.workingImgWithRemotePreview();
// Create metadata of a video that has failed processing
const [failedVideoResponseFileItem, failedVideoFileIdentifier] = generateSampleFileItem.failedVideo();
// You can inject the file items into the Media Api Mock (Sold separately)
const myMockedMediaApi = createMockedMediaApi([imageResponseFileItem, failedVideoResponseFileItem]);
export function MyExample = () => {
// Render your mocked environment and your component in it
return (
<MockedMediaClientProvider mockedMediaApi={myMockedMediaApi}>
<MyFileComponent fileIdentifier={imageFileIdentifier} />
<MyFileComponent fileIdentifier={failedVideoFileIdentifier} />
</MockedMediaClientProvider>
);
}