11import { 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' ;
63
74describe ( 'Save Course' , ( ) => {
85 it ( 'should have a course' , async ( ) => {
96 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 ( ) ;
158
169 await repository . save ( course ) ;
1710 } ) ;
@@ -20,11 +13,7 @@ describe('Save Course', () => {
2013describe ( 'Search Course' , ( ) => {
2114 it ( 'should return an existing course' , async ( ) => {
2215 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 ( ) ;
2817
2918 await repository . save ( course ) ;
3019
@@ -34,6 +23,6 @@ describe('Search Course', () => {
3423 it ( 'should not return a non existing course' , async ( ) => {
3524 const repository = new FileCourseRepository ( ) ;
3625
37- expect ( await repository . search ( new CourseId ( 'de8c20b5-1181-415b-bb82-1f15bf1b67f1' ) ) ) . toBeFalsy ( ) ;
26+ expect ( await repository . search ( CourseMother . random ( ) . id ) ) . toBeFalsy ( ) ;
3827 } ) ;
3928} ) ;
0 commit comments