-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
bf5fec9
commit 4ad1a0e
Showing
13 changed files
with
360 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apps/server/src/modules/learnroom/domain/do/course.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { courseFactory } from '../../testing'; | ||
import { Course } from './course'; | ||
|
||
describe(Course.name, () => { | ||
describe('isTeacher', () => { | ||
describe('when the user is a teacher in the course', () => { | ||
const setup = () => { | ||
const userId = new ObjectId().toHexString(); | ||
const course = courseFactory.build({ | ||
teacherIds: [userId], | ||
}); | ||
|
||
return { | ||
course, | ||
userId, | ||
}; | ||
}; | ||
|
||
it('should return true', () => { | ||
const { course, userId } = setup(); | ||
|
||
const result = course.isTeacher(userId); | ||
|
||
expect(result).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('when the user is not a teacher in the course', () => { | ||
const setup = () => { | ||
const userId = new ObjectId().toHexString(); | ||
const course = courseFactory.build({ | ||
teacherIds: [new ObjectId().toHexString()], | ||
studentIds: [userId], | ||
substitutionTeacherIds: [userId], | ||
}); | ||
|
||
return { | ||
course, | ||
userId, | ||
}; | ||
}; | ||
|
||
it('should return false', () => { | ||
const { course, userId } = setup(); | ||
|
||
const result = course.isTeacher(userId); | ||
|
||
expect(result).toEqual(false); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.