Dashboard page: refactored setup of fetch mock, added more assertions to unit test

This commit is contained in:
gianantoniopini
2021-01-26 14:22:27 +01:00
parent e27bedcf88
commit 8018d7f527
6 changed files with 34 additions and 12 deletions

View File

@ -54,8 +54,11 @@ export const getFieldProps = (formik, schema, name) => ({
...formik.getFieldProps(name),
});
export const unsplashPhotoRequestUrl =
'https://source.unsplash.com/featured/400x600';
export const getUnsplashPhoto = async () => {
const response = await fetch('https://source.unsplash.com/featured/400x600');
const response = await fetch(unsplashPhotoRequestUrl);
return response.url;
};
@ -121,3 +124,7 @@ export const b64toBlob = (b64Data, contentType = '', sliceSize = 512) => {
const blob = new Blob(byteArrays, { type: contentType });
return blob;
};
export const delay = async (milliseconds) => {
await new Promise((resolve) => setTimeout(resolve, milliseconds));
};