1
1
import { FileCourseRepository } from '../../../../../src/Contexts/Mooc/Courses/infrastructure/FileCourseRepository' ;
2
- import { Course } from '../../../../../src/Contexts/Mooc/Courses/domain/Course' ;
3
- import { CourseId } from '../../../../../src/Contexts/Mooc/Shared/domain/Courses/CourseId' ;
4
- import { CourseName } from '../../../../../src/Contexts/Mooc/Courses/domain/CourseName' ;
5
- import { CourseDuration } from '../../../../../src/Contexts/Mooc/Courses/domain/CourseDuration' ;
2
+ import { CourseMother } from '../../../../Mooc/Courses/domain/CourseMother' ;
6
3
7
4
describe ( 'Save Course' , ( ) => {
8
5
it ( 'should have a course' , async ( ) => {
9
6
const repository = new FileCourseRepository ( ) ;
10
- const course = new Course (
11
- new CourseId ( '0766c602-d4d4-48b6-9d50-d3253123275e' ) ,
12
- new CourseName ( 'name' ) ,
13
- new CourseDuration ( 'duration' )
14
- ) ;
7
+ const course = CourseMother . random ( ) ;
15
8
16
9
await repository . save ( course ) ;
17
10
} ) ;
@@ -20,11 +13,7 @@ describe('Save Course', () => {
20
13
describe ( 'Search Course' , ( ) => {
21
14
it ( 'should return an existing course' , async ( ) => {
22
15
const repository = new FileCourseRepository ( ) ;
23
- const course = new Course (
24
- new CourseId ( '0766c602-d4d4-48b6-9d50-d3253123275e' ) ,
25
- new CourseName ( 'name' ) ,
26
- new CourseDuration ( 'duration' )
27
- ) ;
16
+ const course = CourseMother . random ( ) ;
28
17
29
18
await repository . save ( course ) ;
30
19
@@ -34,6 +23,6 @@ describe('Search Course', () => {
34
23
it ( 'should not return a non existing course' , async ( ) => {
35
24
const repository = new FileCourseRepository ( ) ;
36
25
37
- expect ( await repository . search ( new CourseId ( 'de8c20b5-1181-415b-bb82-1f15bf1b67f1' ) ) ) . toBeFalsy ( ) ;
26
+ expect ( await repository . search ( CourseMother . random ( ) . id ) ) . toBeFalsy ( ) ;
38
27
} ) ;
39
28
} ) ;
0 commit comments