Skip to content

Commit 52a27d5

Browse files
committed
make changes in test to reflect new modified field operational changes
1 parent 1b2c0b7 commit 52a27d5

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

contentcuration/contentcuration/frontend/shared/data/__tests__/ContentNodeResource.spec.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,12 @@ describe('ContentNode methods', () => {
574574

575575
it('should update the node with the payload', async () => {
576576
node.parent = parent.id;
577-
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toBe(payload);
578-
expect(table.update).toHaveBeenCalledWith(node.id, payload);
577+
const result = await ContentNode.tableMove({ node, parent, payload, change });
578+
expect(result).toMatchObject({ ...payload, modified: expect.any(String) });
579+
expect(table.update).toHaveBeenCalledTimes(1);
580+
const [updateId, updatePayload] = table.update.mock.calls[0];
581+
expect(updateId).toBe(node.id);
582+
expect(updatePayload).toBe(result);
579583
expect(table.put).not.toBeCalled();
580584
expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true });
581585
});
@@ -584,19 +588,23 @@ describe('ContentNode methods', () => {
584588
node.parent = parent.id;
585589
updated = false;
586590
const newPayload = { ...payload, root_id: parent.root_id };
587-
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toMatchObject(
588-
newPayload,
591+
const result = await ContentNode.tableMove({ node, parent, payload, change });
592+
expect(result).toMatchObject({ ...newPayload, modified: expect.any(String) });
593+
expect(table.update).toHaveBeenCalledWith(
594+
node.id,
595+
expect.objectContaining({ ...payload, modified: expect.any(String) }),
589596
);
590-
expect(table.update).toHaveBeenCalledWith(node.id, payload);
591-
expect(table.put).toHaveBeenCalledWith(newPayload);
597+
expect(table.put).toHaveBeenCalledWith(result);
592598
expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true });
593599
});
594600

595601
it('should mark the old parent as changed', async () => {
596-
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toMatchObject(
597-
payload,
602+
const result = await ContentNode.tableMove({ node, parent, payload, change });
603+
expect(result).toMatchObject({ ...payload, modified: expect.any(String) });
604+
expect(table.update).toHaveBeenCalledWith(
605+
node.id,
606+
expect.objectContaining({ ...payload, modified: expect.any(String) }),
598607
);
599-
expect(table.update).toHaveBeenCalledWith(node.id, payload);
600608
expect(table.put).not.toBeCalled();
601609
expect(table.update).toHaveBeenCalledWith(node.parent, { changed: true });
602610
});

0 commit comments

Comments
 (0)