Skip to content

Commit

Permalink
Update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
leonel authored and leonel committed Mar 8, 2024
1 parent d6d3e9a commit f09f806
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
15 changes: 7 additions & 8 deletions src/commands/__test__/tarea.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,20 @@ describe('tareaCommandFunction', () => {
});

it("should not send a cheatsheet as part of the response if the lesson doesn't have one", async () => {
const typeCodeText = 'console.log("Hello World!!!")';
const fullMessage =
'Hola, aca dejo la tarea\n\n```console.log("Hello World!!!")```';
const typeLinkText = 'https://github.com/r-argentina-programa/robotina';
const fullMessage = `Hola, aca dejo la tarea ${typeLinkText}`;

commandMock.command = {
text: fullMessage,
channel_name: 'clase-3',
channel_name: 'clase-9999',
user_id: 'mockId',
};

const submissionResponseMock = {
completed: false,
delivery: typeCodeText,
delivery: typeLinkText,
fkStudentId: 1,
fkTaskId: 3,
fkTaskId: 9999,
id: 1,
isActive: true,
viewer: undefined,
Expand Down Expand Up @@ -164,8 +163,8 @@ describe('tareaCommandFunction', () => {

expect(uploadTareaMock).toBeCalledTimes(1);
expect(uploadTareaMock).toHaveBeenCalledWith({
classNumber: '3',
delivery: typeCodeText,
classNumber: '9999',
delivery: typeLinkText,
slackId: usersInfoResponse.user.id,
firstName: usersInfoResponse.user.profile.first_name,
lastName: usersInfoResponse.user.profile.last_name,
Expand Down
28 changes: 17 additions & 11 deletions src/events/reaction/__test__/handleRobotFaceReaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,22 +277,28 @@ describe('handleRobotFaceReaction', () => {
});

it("should not send a cheatsheet as part of the response if the lesson doesn't have one", async () => {
const typeCodeText = 'console.log("Hello World!!!")';
const typeLinkText = 'https://github.com/r-argentina-programa/robotina';

const submissionResponseMock = {
completed: false,
delivery: typeCodeText,
delivery: typeLinkText,
studentId: 1,
taskId: 3,
taskId: 9999,
id: 1,
isActive: true,
viewer: undefined,
} as ISubmissionResponse;

clientMock.conversations.history.mockResolvedValueOnce(
// @ts-ignore
conversationsHistoryResponse
);
clientMock.conversations.history.mockResolvedValueOnce({
...conversationsHistoryResponse,
messages: [
// @ts-ignore
{
...conversationsHistoryResponse.messages[0],
text: `Hola, aca dejo la tarea ${typeLinkText}`,
},
],
});

clientMock.users.info.mockResolvedValueOnce(
// @ts-ignore
Expand All @@ -304,8 +310,8 @@ describe('handleRobotFaceReaction', () => {
{
channel: {
...conversationsInfoResponse,
name: 'clase-3',
name_normalized: 'clase-3',
name: 'clase-9999',
name_normalized: 'clase-9999',
},
}
);
Expand All @@ -331,8 +337,8 @@ describe('handleRobotFaceReaction', () => {

expect(uploadTareaMock).toBeCalledTimes(1);
expect(uploadTareaMock).toHaveBeenCalledWith({
classNumber: '3',
delivery: typeCodeText,
classNumber: '9999',
delivery: typeLinkText,
slackId: messageAuthorEvent.item_user,
firstName: usersInfoResponse.user.profile.first_name,
lastName: usersInfoResponse.user.profile.last_name,
Expand Down

0 comments on commit f09f806

Please sign in to comment.