Skip to content

Commit

Permalink
fix(content-uploader): fix bug in assigning new item ids (#3796)
Browse files Browse the repository at this point in the history
* fix(content-uploader): fix bug in assigning new item ids

* fix(content-uploader): fix bug in assigning new item ids
  • Loading branch information
ahorowitz123 authored Dec 17, 2024
1 parent 2efabff commit 1672213
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/elements/content-uploader/ContentUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class ContentUploader extends Component<ContentUploaderProps, State> {

const firstFile = getFile(newFiles[0]);

const newItemIdsState = { ...this.itemsRef.current, ...newItemIds };
const newItemIdsState = { ...this.itemIdsRef.current, ...newItemIds };

this.itemIdsRef.current = newItemIdsState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ describe('elements/content-uploader/ContentUploader', () => {
test('should add generated itemId', () => {
const wrapper = getWrapper({ rootFolderId: 0 });
const instance = wrapper.instance();
instance.itemIdsRef.current = { abcd: true };

global.Date.now = jest.fn(() => 10000);

instance.addFilesToUploadQueue([{ name: 'yoyo', size: 1000 }], jest.fn(), false);

const expected = { yoyo: true, yoyo_0_10000: true };
const expected = { abcd: true, yoyo: true, yoyo_0_10000: true };
expect(wrapper.state().itemIds).toEqual(expected);
expect(instance.itemIdsRef.current).toEqual(expected);
});
Expand Down

0 comments on commit 1672213

Please sign in to comment.