Skip to content

Commit da3af25

Browse files
committed
Sort courses
1 parent ddb4d63 commit da3af25

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/Contexts/Backoffice/Shared/infrastructure/MongoBackofficeCourseRepository.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import container from '../../../../../src/apps/backoffice/backend/config/dependency-injection';
2+
import { BackofficeCourse } from '../../../../../src/Contexts/Backoffice/Courses/domain/BackofficeCourse';
23
import { MongoBackofficeCourseRepository } from '../../../../../src/Contexts/Backoffice/Shared/infrastructure/MongoBackofficeCourseRepository';
34
import { EnvironmentArranger } from '../../../Shared/infrastructure/arranger/EnvironmentArranger';
45
import { BackofficeCourseMother } from '../../Courses/domain/BackofficeCourseMother';
@@ -8,6 +9,10 @@ const repository: MongoBackofficeCourseRepository = container.get(
89
);
910
const environmentArranger: Promise<EnvironmentArranger> = container.get('Backoffice.Backend.EnvironmentArranger');
1011

12+
function sort(backofficeCourse1: BackofficeCourse, backofficeCourse2: BackofficeCourse): number {
13+
return backofficeCourse1?.id?.value.localeCompare(backofficeCourse2?.id?.value);
14+
}
15+
1116
beforeEach(async () => {
1217
await (await environmentArranger).arrange();
1318
});
@@ -23,7 +28,7 @@ describe('Mongo BackofficeCourse Repository', () => {
2328
await Promise.all(courses.map(course => repository.save(course)));
2429

2530
const expectedCourses = await repository.searchAll();
26-
expect(courses.sort()).toStrictEqual(expectedCourses.sort());
31+
expect(courses.sort(sort)).toStrictEqual(expectedCourses.sort(sort));
2732
});
2833

2934
it('should save a course', async () => {

0 commit comments

Comments
 (0)