fix(media-library-cloudinary): when 'multiple' is true, always return an array (#2656)
This commit is contained in:
parent
49e142ef59
commit
4c32ee4aed
@ -147,6 +147,17 @@ Object {
|
||||
expect(handleInsert).toHaveBeenCalledWith(expect.any(Array));
|
||||
});
|
||||
|
||||
it('calls insert function with array when only one asset is returned and config.multiple is true', async () => {
|
||||
const options = {
|
||||
config: {
|
||||
multiple: true,
|
||||
},
|
||||
};
|
||||
await cloudinary.init({ options, handleInsert });
|
||||
cloudinaryInsertHandler({ assets: [asset] });
|
||||
expect(handleInsert).toHaveBeenCalledWith(expect.any(Array));
|
||||
});
|
||||
|
||||
it('calls insert function with secure url', async () => {
|
||||
await cloudinary.init({ handleInsert });
|
||||
cloudinaryInsertHandler({ assets: [asset] });
|
||||
|
@ -60,7 +60,7 @@ async function init({ options = {}, handleInsert } = {}) {
|
||||
|
||||
const insertHandler = data => {
|
||||
const assets = data.assets.map(asset => getAssetUrl(asset, resolvedOptions));
|
||||
handleInsert(assets.length > 1 ? assets : assets[0]);
|
||||
handleInsert(providedConfig.multiple || assets.length > 1 ? assets : assets[0]);
|
||||
};
|
||||
|
||||
const mediaLibrary = window.cloudinary.createMediaLibrary(cloudinaryConfig, { insertHandler });
|
||||
|
Loading…
x
Reference in New Issue
Block a user