Skip to content

Commit 42a275d

Browse files
committed
Add sort function to ElasticBackofficeCourseRepository test
1 parent f3bcefd commit 42a275d

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ services:
4646
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
4747
container_name: codely-elasticsearch
4848
environment:
49-
# - cluster.name=codely-elasticsearch
5049
- node.name=codely-elasticsearch
5150
- discovery.type=single-node #Elasticsearch forms a single-node cluster
5251
- bootstrap.memory_lock=true # might cause the JVM or shell session to exit if it tries to allocate more memory than is available!

src/Contexts/Backoffice/domain/BackofficeCourse.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,4 @@ export class BackofficeCourse extends AggregateRoot {
4040
duration: this.duration.value
4141
};
4242
}
43-
44-
static sort(backofficeCourse1: BackofficeCourse, backofficeCourse2: BackofficeCourse): number {
45-
return backofficeCourse1?.id?.value.localeCompare(backofficeCourse2?.id?.value);
46-
}
4743
}

tests/Contexts/Backoffice/infrastructure/ElasticBackofficeCourseRepository.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const client = ElasticClientFactory.createClient('test');
88
const repository: ElasticBackofficeCourseRepository = new ElasticBackofficeCourseRepository(client);
99
const environmentArranger = new ElasticEnvironmentArranger(client);
1010

11+
function sort(backofficeCourse1: BackofficeCourse, backofficeCourse2: BackofficeCourse): number {
12+
return backofficeCourse1?.id?.value.localeCompare(backofficeCourse2?.id?.value);
13+
}
14+
1115
afterEach(async () => {
1216
await environmentArranger.arrange();
1317
});
@@ -21,6 +25,6 @@ describe('Search all courses', () => {
2125
const expectedCourses = await repository.searchAll();
2226

2327
expect(courses.length).toEqual(expectedCourses.length);
24-
expect(courses.sort(BackofficeCourse.sort)).toEqual(expectedCourses.sort(BackofficeCourse.sort));
28+
expect(courses.sort(sort)).toEqual(expectedCourses.sort(sort));
2529
});
2630
});

0 commit comments

Comments
 (0)