Skip to content

Commit c24aad1

Browse files
committed
sort function in mongo repository test for mongo 4.2 version
1 parent 80eb313 commit c24aad1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/Contexts/Backoffice/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/domain/BackofficeCourse';
23
import { MongoBackofficeCourseRepository } from '../../../../src/Contexts/Backoffice/infrastructure/MongoBackofficeCourseRepository';
34
import { EnvironmentArranger } from '../../Shared/infrastructure/arranger/EnvironmentArranger';
45
import { BackofficeCourseMother } from '../application/domain/BackofficeCourseMother';
@@ -16,14 +17,18 @@ afterAll(async () => {
1617
await (await environmentArranger).close();
1718
});
1819

20+
function sort(backofficeCourse1: BackofficeCourse, backofficeCourse2: BackofficeCourse): number {
21+
return backofficeCourse1?.id?.value.localeCompare(backofficeCourse2?.id?.value);
22+
}
23+
1924
describe('Mongo BackofficeCourse Repository', () => {
2025
it('should return the existing courses', async () => {
2126
const courses = [BackofficeCourseMother.random(), BackofficeCourseMother.random()];
2227

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)