Skip to content

Commit 369c6a3

Browse files
committed
feature: Added test to check the expected behaviour
1 parent 9f557b2 commit 369c6a3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

packages/core/test/ArrayField.test.jsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,41 @@ describe('ArrayField', () => {
17021702
);
17031703
});
17041704

1705+
it('should handle a change event with multiple files that results the same items in the list', async () => {
1706+
sandbox.stub(window, 'FileReader').returns({
1707+
set onload(fn) {
1708+
fn({ target: { result: 'data:text/plain;base64,x=' } });
1709+
},
1710+
// eslint-disable-next-line @typescript-eslint/no-empty-function
1711+
readAsDataUrl() {},
1712+
});
1713+
1714+
const { node, onChange } = createFormComponent({ schema });
1715+
1716+
act(() => {
1717+
fireEvent.change(node.querySelector('.field input[type=file]'), {
1718+
target: {
1719+
files: [
1720+
{ name: 'file1.txt', size: 1, type: 'type' },
1721+
{ name: 'file2.txt', size: 2, type: 'type' },
1722+
],
1723+
},
1724+
});
1725+
});
1726+
1727+
await act(() => {
1728+
new Promise(setImmediate);
1729+
});
1730+
1731+
sinon.assert.calledWithMatch(
1732+
onChange.lastCall,
1733+
{
1734+
formData: ['data:text/plain;name=file1.txt;base64,x=', 'data:text/plain;name=file2.txt;base64,x='],
1735+
},
1736+
'root'
1737+
);
1738+
});
1739+
17051740
it('should fill field with data', () => {
17061741
const { node } = createFormComponent({
17071742
schema,

0 commit comments

Comments
 (0)