Skip to content

Commit

Permalink
test: create project
Browse files Browse the repository at this point in the history
  • Loading branch information
francisvaut committed Apr 11, 2024
1 parent 017864f commit b6c7b60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/src/composables/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export function useProject(): ProjectState {
score_visible: projectData.score_visible,
group_size: projectData.group_size,
zip_structure: projectData.structure_file,
course: projectData.course?.id
},
project,
Project.fromJSON,
'multipart/form-data',
);
}

Expand Down
22 changes: 17 additions & 5 deletions frontend/src/test/unit/services/project_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,25 @@ describe('project', (): void => {
expect(Array.isArray(projects.value)).toBe(true);
const prevLength = projects.value?.length ?? 0;

// await createProject(exampleProject, courseId);
// await getProjectsByCourse(courseId);
await createProject(exampleProject, courseId);
await getProjectsByCourse(courseId);

// expect(projects).not.toBeNull();
// expect(Array.isArray(projects.value)).toBe(true);
// expect(projects.value?.length).toBe(prevLength + 1);
expect(projects).not.toBeNull();
expect(Array.isArray(projects.value)).toBe(true);
expect(projects.value?.length).toBe(prevLength + 1);

// Only check for fields that are sent to the backend
expect(projects.value?.[prevLength]?.name).toBe('project_name');
expect(projects.value?.[prevLength]?.description).toBe('project_description');
expect(projects.value?.[prevLength]?.visible).toBe(true);
expect(projects.value?.[prevLength]?.archived).toBe(false);
expect(projects.value?.[prevLength]?.locked_groups).toBe(false);
expect(projects.value?.[prevLength]?.start_date).toStrictEqual(new Date('November 1, 2024 04:20:00'));
expect(projects.value?.[prevLength]?.deadline).toStrictEqual(new Date('November 2, 2024 04:20:00'));
expect(projects.value?.[prevLength]?.max_score).toBe(20);
expect(projects.value?.[prevLength]?.score_visible).toBe(false);
expect(projects.value?.[prevLength]?.group_size).toBe(5);
expect(projects.value?.[prevLength]?.structure_file).toBe(null);
expect(projects.value?.[prevLength]?.course).toBe(null);
});
});

0 comments on commit b6c7b60

Please sign in to comment.