Skip to content

Commit 74327dc

Browse files
committed
Add unit test
1 parent c0ed341 commit 74327dc

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Course from '../../../../src/Mooc/Courses/domain/Course';
2+
import CreateCourse from '../../../../src/Mooc/Courses/application/CreateCourse';
3+
import CourseRepository from '../../../../src/Mooc/Courses/domain/CourseRepository';
4+
5+
describe('Create Course', () => {
6+
it('should create a valid course', async () => {
7+
const save = jest.fn();
8+
const repository: CourseRepository = {
9+
save,
10+
search: jest.fn()
11+
};
12+
13+
const createCourse = new CreateCourse(repository);
14+
15+
const id = 'some-id';
16+
const name = 'some-name';
17+
const duration = 'some-duration';
18+
19+
const course = new Course(id, name, duration);
20+
21+
await createCourse.run(id, name, duration);
22+
23+
expect(save).toHaveBeenCalledWith(course);
24+
});
25+
});

0 commit comments

Comments
 (0)