Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('AssessmentEditor', () => {

it('emits delete item event with a correct key', () => {
expect(listeners.deleteItem).toHaveBeenCalledWith(ITEM2);
expect(listeners.updateItems).toBeCalledTimes(1);
expect(listeners.updateItems).toHaveBeenCalledTimes(1);
});

it('emits update item events with updated order of items after the deleted item', () => {
Expand All @@ -288,7 +288,7 @@ describe('AssessmentEditor', () => {
order: 2,
},
]);
expect(listeners.updateItems).toBeCalledTimes(1);
expect(listeners.updateItems).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -300,7 +300,7 @@ describe('AssessmentEditor', () => {
});

it('emits add item event with a new item with a correct order', () => {
expect(listeners.addItem).toBeCalledWith({
expect(listeners.addItem).toHaveBeenCalledWith({
contentnode: NODE_ID,
question: '',
type: AssessmentItemTypes.SINGLE_SELECTION,
Expand Down Expand Up @@ -330,7 +330,7 @@ describe('AssessmentEditor', () => {
order: 4,
},
]);
expect(listeners.updateItems).toBeCalledTimes(1);
expect(listeners.updateItems).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -351,7 +351,7 @@ describe('AssessmentEditor', () => {
order: 2,
[DELAYED_VALIDATION]: true,
});
expect(listeners.addItem).toBeCalledTimes(1);
expect(listeners.addItem).toHaveBeenCalledTimes(1);
});

it('emits update item events with updated order of items below the new item', () => {
Expand All @@ -373,7 +373,7 @@ describe('AssessmentEditor', () => {
order: 4,
},
]);
expect(listeners.updateItems).toBeCalledTimes(1);
expect(listeners.updateItems).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -395,7 +395,7 @@ describe('AssessmentEditor', () => {
order: 1,
},
]);
expect(listeners.updateItems).toBeCalledTimes(1);
expect(listeners.updateItems).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -417,7 +417,7 @@ describe('AssessmentEditor', () => {
order: 1,
},
]);
expect(listeners.updateItems).toBeCalledTimes(1);
expect(listeners.updateItems).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -427,7 +427,7 @@ describe('AssessmentEditor', () => {
});

it('emits add item event with a new item with a correct order', () => {
expect(listeners.addItem).toBeCalledWith({
expect(listeners.addItem).toHaveBeenCalledWith({
contentnode: NODE_ID,
question: '',
type: AssessmentItemTypes.SINGLE_SELECTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('FeedBackUtility Tests', () => {

it('should throw an error when endpoint is not defined', () => {
flagFeedbackEvent.endpoint = undefined;
expect(() => flagFeedbackEvent.getUrl()).toThrowError(
expect(() => flagFeedbackEvent.getUrl()).toThrow(
'Resource is not defined for the FeedBack Object.',
);
});
Expand All @@ -130,7 +130,7 @@ describe('FeedBackUtility Tests', () => {

it.skip('should handle errors when sending a request using sendRequest function', async () => {
client.post.mockRejectedValue(new Error('Mocked API Error'));
await expect(sendRequest(flagFeedbackEvent)).rejects.toThrowError('Mocked API Error');
await expect(sendRequest(flagFeedbackEvent)).rejects.toThrow('Mocked API Error');
expect(client.post).toHaveBeenCalledWith(
flagFeedbackEvent.getUrl(),
flagFeedbackEvent.getData(),
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('FeedBackUtility Tests', () => {

it('should throw an error when endpoint is not defined', () => {
recommendationsEvent.endpoint = undefined;
expect(() => recommendationsEvent.getUrl()).toThrowError(
expect(() => recommendationsEvent.getUrl()).toThrow(
'Resource is not defined for the FeedBack Object.',
);
});
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('FeedBackUtility Tests', () => {
recommendationsEvent = setupRecommendationsEvent({
method: 'post',
});
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError('Mocked API Error');
await expect(sendRequest(recommendationsEvent)).rejects.toThrow('Mocked API Error');
expect(client.post).toHaveBeenCalledWith(
recommendationsEvent.getUrl(),
recommendationsEvent.getData(),
Expand All @@ -232,7 +232,7 @@ describe('FeedBackUtility Tests', () => {
method: 'put',
eventId: uuidv4(),
});
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError('Mocked API Error');
await expect(sendRequest(recommendationsEvent)).rejects.toThrow('Mocked API Error');
expect(client.put).toHaveBeenCalledWith(
recommendationsEvent.getUrl(),
recommendationsEvent.getData(),
Expand All @@ -245,7 +245,7 @@ describe('FeedBackUtility Tests', () => {
method: 'patch',
eventId: uuidv4(),
});
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError('Mocked API Error');
await expect(sendRequest(recommendationsEvent)).rejects.toThrow('Mocked API Error');
expect(client.patch).toHaveBeenCalledWith(
recommendationsEvent.getUrl(),
recommendationsEvent.getData(),
Expand All @@ -257,7 +257,7 @@ describe('FeedBackUtility Tests', () => {
method: 'delete',
eventId: uuidv4(),
});
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsEvent)).rejects.toThrow(
'Unsupported HTTP method: delete',
);
});
Expand All @@ -267,7 +267,7 @@ describe('FeedBackUtility Tests', () => {
method: 'get',
eventId: uuidv4(),
});
await expect(sendRequest(recommendationsEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsEvent)).rejects.toThrow(
'Unsupported HTTP method: get',
);
});
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('FeedBackUtility Tests', () => {
dataOverride: null,
override: true,
}),
).toThrowError('The data property cannot be null or undefined');
).toThrow('The data property cannot be null or undefined');
});

it('should throw an error when data is an array but method is not a POST', () => {
Expand All @@ -307,7 +307,7 @@ describe('FeedBackUtility Tests', () => {
override: true,
eventId: uuidv4(),
}),
).toThrowError("Array 'data' is only allowed for 'post' requests");
).toThrow("Array 'data' is only allowed for 'post' requests");
});

it('should throw an error when data is an empty array and method is a POST', () => {
Expand All @@ -318,7 +318,7 @@ describe('FeedBackUtility Tests', () => {
dataOverride: [],
override: true,
}),
).toThrowError("The 'data' array cannot be empty");
).toThrow("The 'data' array cannot be empty");
});

it('should throw an error when data is any of any type other than array or object', () => {
Expand All @@ -329,7 +329,7 @@ describe('FeedBackUtility Tests', () => {
dataOverride: 'invalid data type',
override: true,
}),
).toThrowError("The 'data' must be either a non-null object or an array of objects");
).toThrow("The 'data' must be either a non-null object or an array of objects");
});

it('should throw an error when submitted data has missing fields', () => {
Expand All @@ -340,7 +340,7 @@ describe('FeedBackUtility Tests', () => {
dataOverride: {},
override: true,
}),
).toThrowError(/The 'data' object is missing required property: \w+/);
).toThrow(/The 'data' object is missing required property: \w+/);
});

it('should throw an error when submitted data array has invalid data', () => {
Expand All @@ -351,7 +351,7 @@ describe('FeedBackUtility Tests', () => {
dataOverride: [null],
override: true,
}),
).toThrowError(/Item at position \w+ in 'data' is not a valid object/);
).toThrow(/Item at position \w+ in 'data' is not a valid object/);
});

it('should throw an error when submitted data array has valid data but with missing fields', () => {
Expand All @@ -362,12 +362,12 @@ describe('FeedBackUtility Tests', () => {
dataOverride: [{}],
override: true,
}),
).toThrowError(/Missing required property in 'data': \w+ at position: \w+/);
).toThrow(/Missing required property in 'data': \w+ at position: \w+/);
});

it('should throw an error when endpoint is not defined', () => {
recommendationsInteractionEvent.endpoint = undefined;
expect(() => recommendationsInteractionEvent.getUrl()).toThrowError(
expect(() => recommendationsInteractionEvent.getUrl()).toThrow(
'Resource is not defined for the FeedBack Object.',
);
});
Expand Down Expand Up @@ -440,7 +440,7 @@ describe('FeedBackUtility Tests', () => {
recommendationsInteractionEvent = setupRecommendationsInteractionEvent({
method: 'post',
});
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
'Mocked API Error',
);
expect(client.post).toHaveBeenCalledWith(
Expand All @@ -455,7 +455,7 @@ describe('FeedBackUtility Tests', () => {
method: 'put',
eventId: uuidv4(),
});
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
'Mocked API Error',
);
expect(client.put).toHaveBeenCalledWith(
Expand All @@ -470,7 +470,7 @@ describe('FeedBackUtility Tests', () => {
method: 'patch',
eventId: uuidv4(),
});
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
'Mocked API Error',
);
expect(client.patch).toHaveBeenCalledWith(
Expand All @@ -483,7 +483,7 @@ describe('FeedBackUtility Tests', () => {
recommendationsInteractionEvent = setupRecommendationsInteractionEvent({
method: 'delete',
});
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
'Unsupported HTTP method: delete',
);
});
Expand All @@ -493,7 +493,7 @@ describe('FeedBackUtility Tests', () => {
method: 'get',
id: uuidv4(),
});
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrowError(
await expect(sendRequest(recommendationsInteractionEvent)).rejects.toThrow(
'Unsupported HTTP method: get',
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ describe('ContentNode methods', () => {
expect(treeLock).toHaveBeenCalledWith(parent.root_id, expect.any(Function));
expect(get).toHaveBeenCalledWith('abc123', false);
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).not.toBeCalled();
expect(cb).toBeCalled();
expect(getNewSortOrder).not.toHaveBeenCalled();
expect(cb).toHaveBeenCalled();
const result = cb.mock.calls[0][0];
expect(result).toMatchObject({
node,
Expand Down Expand Up @@ -356,8 +356,8 @@ describe('ContentNode methods', () => {
expect(treeLock).toHaveBeenCalledWith(parent.root_id, expect.any(Function));
expect(get).toHaveBeenCalledWith('abc123', false);
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).not.toBeCalled();
expect(cb).toBeCalled();
expect(getNewSortOrder).not.toHaveBeenCalled();
expect(cb).toHaveBeenCalled();
const result = cb.mock.calls[0][0];
expect(result).toMatchObject({
node,
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('ContentNode methods', () => {
expect(get).toHaveBeenCalledWith('abc123', false);
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).toHaveBeenCalledWith('abc123', 'target', 'position', siblings);
expect(cb).toBeCalled();
expect(cb).toHaveBeenCalled();
const result = cb.mock.calls[0][0];
expect(result).toMatchObject({
node,
Expand Down Expand Up @@ -436,7 +436,7 @@ describe('ContentNode methods', () => {
expect(get).toHaveBeenCalledWith('abc123', false);
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).toHaveBeenCalledWith('abc123', 'target', 'position', siblings);
expect(cb).not.toBeCalled();
expect(cb).not.toHaveBeenCalled();
});
});

Expand All @@ -453,8 +453,8 @@ describe('ContentNode methods', () => {
expect(treeLock).toHaveBeenCalledWith(parent.root_id, expect.any(Function));
expect(tableGet).toHaveBeenCalledWith('abc123');
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).not.toBeCalled();
expect(cb).toBeCalled();
expect(getNewSortOrder).not.toHaveBeenCalled();
expect(cb).toHaveBeenCalled();
const result = cb.mock.calls[0][0];
expect(result).toMatchObject({
node: undefined,
Expand Down Expand Up @@ -494,7 +494,7 @@ describe('ContentNode methods', () => {
expect(tableGet).toHaveBeenCalledWith('abc123');
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).toHaveBeenCalledWith(null, 'target', 'position', siblings);
expect(cb).toBeCalled();
expect(cb).toHaveBeenCalled();
const result = cb.mock.calls[0][0];
expect(result).toMatchObject({
node: undefined,
Expand Down Expand Up @@ -534,7 +534,7 @@ describe('ContentNode methods', () => {
expect(tableGet).toHaveBeenCalledWith('abc123');
expect(where).toHaveBeenCalledWith({ parent: parent.id }, false);
expect(getNewSortOrder).toHaveBeenCalledWith(null, 'target', 'position', siblings);
expect(cb).not.toBeCalled();
expect(cb).not.toHaveBeenCalled();
});
});
});
Expand Down Expand Up @@ -576,7 +576,7 @@ describe('ContentNode methods', () => {
node.parent = parent.id;
await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toBe(payload);
expect(table.update).toHaveBeenCalledWith(node.id, payload);
expect(table.put).not.toBeCalled();
expect(table.put).not.toHaveBeenCalled();
expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true });
});

Expand All @@ -597,7 +597,7 @@ describe('ContentNode methods', () => {
payload,
);
expect(table.update).toHaveBeenCalledWith(node.id, payload);
expect(table.put).not.toBeCalled();
expect(table.put).not.toHaveBeenCalled();
expect(table.update).toHaveBeenCalledWith(node.parent, { changed: true });
});

Expand Down Expand Up @@ -709,7 +709,7 @@ describe('ContentNode methods', () => {
node,
);
expect(table.get).toHaveBeenCalledWith({ '[node_id+channel_id]': [node_id, channel_id] });
expect(fetchCollection).not.toBeCalled();
expect(fetchCollection).not.toHaveBeenCalled();
});

it('should use call fetchCollection when missing locally', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ describe('channelEdit utils', () => {
describe('isNodeComplete', () => {
describe('for all kinds of nodes', () => {
it('throws a reference error if node details are not defined', () => {
expect(() => isNodeComplete({ nodeDetails: undefined })).toThrowError(
expect(() => isNodeComplete({ nodeDetails: undefined })).toThrow(
new ReferenceError('node details must be defined'),
);
expect(() => isNodeComplete({ nodeDetails: null })).toThrowError(
expect(() => isNodeComplete({ nodeDetails: null })).toThrow(
new ReferenceError('node details must be defined'),
);
});
Expand Down Expand Up @@ -417,10 +417,8 @@ describe('channelEdit utils', () => {

it('throws a reference error if assessment items are not defined', () => {
const error = new ReferenceError('assessment items must be defined for exercises');
expect(() => isNodeComplete({ nodeDetails, assessmentItems: undefined })).toThrowError(
error,
);
expect(() => isNodeComplete({ nodeDetails, assessmentItems: null })).toThrowError(error);
expect(() => isNodeComplete({ nodeDetails, assessmentItems: undefined })).toThrow(error);
expect(() => isNodeComplete({ nodeDetails, assessmentItems: null })).toThrow(error);
});

it('returns false if node details are not valid', () => {
Expand Down Expand Up @@ -528,8 +526,8 @@ describe('channelEdit utils', () => {
const error = new ReferenceError(
'files must be defined for a node other than topic or exercise',
);
expect(() => isNodeComplete({ nodeDetails, files: undefined })).toThrowError(error);
expect(() => isNodeComplete({ nodeDetails, files: null })).toThrowError(error);
expect(() => isNodeComplete({ nodeDetails, files: undefined })).toThrow(error);
expect(() => isNodeComplete({ nodeDetails, files: null })).toThrow(error);
});

it('returns false if node details are not valid', () => {
Expand Down
Loading
Loading