Merge pull request #121 from SELab-2/fix/tests-werken-niet-op-dev

fix: Tests falen op `dev`
This commit is contained in:
Laure Jablonski 2025-03-18 09:36:45 +01:00 committed by GitHub
commit 9029d93e30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 5 deletions

3
backend/.env.test Normal file
View file

@ -0,0 +1,3 @@
PORT=3000
DWENGO_DB_UPDATE=true
DWENGO_DB_NAME=":memory:"

View file

@ -60,7 +60,8 @@ describe('DatabaseLearningObjectProvider', () => {
describe('getLearningObjectHTML', () => {
it('should return the correct rendering of the learning object', async () => {
const result = await databaseLearningObjectProvider.getLearningObjectHTML(exampleLearningObject);
expect(result).toEqual(example.getHTMLRendering());
// Set newlines so your tests are platform-independent.
expect(result).toEqual(example.getHTMLRendering().replace(/\r\n/g, '\n'));
});
it('should return null for a non-existing learning object', async () => {
const result = await databaseLearningObjectProvider.getLearningObjectHTML({

View file

@ -68,7 +68,8 @@ describe('LearningObjectService', () => {
it('returns the expected HTML when queried with the identifier of a learning object saved in the database', async () => {
const result = await learningObjectService.getLearningObjectHTML(exampleLearningObject);
expect(result).not.toBeNull();
expect(result).toEqual(learningObjectExample.getHTMLRendering());
// Set newlines so your tests are platform-independent.
expect(result).toEqual(learningObjectExample.getHTMLRendering().replace(/\r\n/g, '\n'));
});
it(
'returns the same HTML as the Dwengo API when queried with the identifier of a learning object that does ' +

View file

@ -8,18 +8,19 @@ describe('ProcessingService', () => {
it('renders a markdown learning object correctly', async () => {
const markdownLearningObject = mdExample.createLearningObject();
const result = await processingService.render(markdownLearningObject);
expect(result).toEqual(mdExample.getHTMLRendering());
// Set newlines so your tests are platform-independent.
expect(result).toEqual(mdExample.getHTMLRendering().replace(/\r\n/g, '\n'));
});
it('renders a multiple choice question correctly', async () => {
const multipleChoiceLearningObject = multipleChoiceExample.createLearningObject();
const result = await processingService.render(multipleChoiceLearningObject);
expect(result).toEqual(multipleChoiceExample.getHTMLRendering());
expect(result).toEqual(multipleChoiceExample.getHTMLRendering().replace(/\r\n/g, '\n'));
});
it('renders an essay question correctly', async () => {
const essayLearningObject = essayExample.createLearningObject();
const result = await processingService.render(essayLearningObject);
expect(result).toEqual(essayExample.getHTMLRendering());
expect(result).toEqual(essayExample.getHTMLRendering().replace(/\r\n/g, '\n'));
});
});