import { CourseCreator } from '../../../../../src/Contexts/Mooc/Courses/application/CourseCreator' ; import { CourseMother } from '../domain/CourseMother' ; import { CourseRepositoryMock } from '../__mocks__/CourseRepositoryMock' ; import { CreateCourseRequestMother } from './CreateCourseRequestMother' ; let repository ; let creator ; beforeEach ( ( ) => { repository = new CourseRepositoryMock ( ) ; creator = new CourseCreator ( repository ) ; } ) ; describe ( 'CourseCreator' , ( ) => { it ( 'should create a valid course' , async ( ) => { const request = CreateCourseRequestMother . random ( ) ; const course = CourseMother . fromRequest ( request ) ; await creator . run ( request ) ; repository . assertLastSavedCourseIs ( course ) ; } ) ; } ) ;