Skip to content

Commit

Permalink
test: add validation for single file upload mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshbhutkar committed Feb 14, 2025
1 parent d1c61d1 commit 9b55f51
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/media-utils/src/utils/test/upload-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,18 @@ describe( 'uploadMedia', () => {
);
expect( uploadToServer ).not.toHaveBeenCalled();
} );

it( 'should throw error when multiple files are selected in single file upload mode', async () => {
const onError = jest.fn();
await uploadMedia( {
filesList: [ imageFile, xmlFile ],
onError,
multiple: false,
} );

expect( onError ).toHaveBeenCalledWith(
new Error( 'Only one file can be used here.' )
);
expect( uploadToServer ).not.toHaveBeenCalled();
} );
} );

0 comments on commit 9b55f51

Please sign in to comment.