-
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.
Merge branch 'THR-18-dev-feature-h5p-editor' of https://github.com/hp…
…i-schul-cloud/schulcloud-server into THR-18-dev-feature-h5p-editor
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
apps/server/src/modules/h5p-editor/entity/h5p-content.entity.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,42 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { ContentMetadata, H5PContent, H5PContentParentType, IH5PContentProperties } from './h5p-content.entity'; | ||
|
||
describe('H5PContent class', () => { | ||
describe('when an H5PContent instance is created', () => { | ||
const setup = () => { | ||
const dummyIH5PContentProperties: IH5PContentProperties = { | ||
creatorId: '507f1f77bcf86cd799439011', | ||
parentType: H5PContentParentType.Lesson, | ||
parentId: '507f1f77bcf86cd799439012', | ||
schoolId: '507f1f77bcf86cd799439013', | ||
metadata: new ContentMetadata({ | ||
embedTypes: ['iframe'], | ||
language: 'en', | ||
mainLibrary: 'mainLibrary123', | ||
defaultLanguage: 'en', | ||
license: 'MIT', | ||
title: 'Title Example', | ||
preloadedDependencies: [], | ||
dynamicDependencies: [], | ||
editorDependencies: [], | ||
}), | ||
content: {}, | ||
}; | ||
|
||
const h5pContent = new H5PContent(dummyIH5PContentProperties); | ||
return { h5pContent, dummyIH5PContentProperties }; | ||
}; | ||
|
||
it('should correctly return the creatorId', () => { | ||
const { h5pContent, dummyIH5PContentProperties } = setup(); | ||
const expectedCreatorId = new ObjectId(dummyIH5PContentProperties.creatorId).toHexString(); | ||
expect(h5pContent.creatorId).toBe(expectedCreatorId); | ||
}); | ||
|
||
it('should correctly return the schoolId', () => { | ||
const { h5pContent, dummyIH5PContentProperties } = setup(); | ||
const expectedSchoolId = new ObjectId(dummyIH5PContentProperties.schoolId).toHexString(); | ||
expect(h5pContent.schoolId).toBe(expectedSchoolId); | ||
}); | ||
}); | ||
}); |