mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
starting quiz tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { LocalCoursePage } from "../../page/localCoursePage";
|
||||
import { pageMarkdown } from "../../page/pageMarkdown";
|
||||
import { pageMarkdownUtils } from "../../page/pageMarkdownUtils";
|
||||
|
||||
describe("PageMarkdownTests", () => {
|
||||
it("can parse page", () => {
|
||||
@@ -10,9 +10,9 @@ describe("PageMarkdownTests", () => {
|
||||
dueAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
const pageMarkdownString = pageMarkdown.toMarkdown(page);
|
||||
const pageMarkdownString = pageMarkdownUtils.toMarkdown(page);
|
||||
|
||||
const parsedPage = pageMarkdown.parseMarkdown(pageMarkdownString);
|
||||
const parsedPage = pageMarkdownUtils.parseMarkdown(pageMarkdownString);
|
||||
|
||||
expect(parsedPage).toEqual(page);
|
||||
});
|
||||
|
||||
110
nextjs/src/models/local/tests/markdown/quiz/testAnswer.test.ts
Normal file
110
nextjs/src/models/local/tests/markdown/quiz/testAnswer.test.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import { QuestionType } from '../../../../../models/local/quiz/localQuizQuestion';
|
||||
import { quizMarkdownUtils } from '../../../../../models/local/quiz/utils/quizMarkdownUtils';
|
||||
import { quizQuestionMarkdownUtils } from '../../../../../models/local/quiz/utils/quizQuestionMarkdownUtils';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('TextAnswerTests', () => {
|
||||
it('can parse essay', () => {
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 2023-08-21T23:59:00
|
||||
LockAt: 2023-08-21T23:59:00
|
||||
AssignmentGroup: Assignments
|
||||
AllowedAttempts: -1
|
||||
Description: this is the
|
||||
multi line
|
||||
description
|
||||
---
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
essay
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.points).toBe(1);
|
||||
expect(firstQuestion.questionType).toBe(QuestionType.ESSAY);
|
||||
expect(firstQuestion.text).not.toContain('essay');
|
||||
});
|
||||
|
||||
it('can parse short answer', () => {
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 2023-08-21T23:59:00
|
||||
LockAt: 2023-08-21T23:59:00
|
||||
AssignmentGroup: Assignments
|
||||
AllowedAttempts: -1
|
||||
Description: this is the
|
||||
multi line
|
||||
description
|
||||
---
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.points).toBe(1);
|
||||
expect(firstQuestion.questionType).toBe(QuestionType.SHORT_ANSWER);
|
||||
expect(firstQuestion.text).not.toContain('short answer');
|
||||
});
|
||||
|
||||
it('short answer to markdown is correct', () => {
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 2023-08-21T23:59:00
|
||||
LockAt: 2023-08-21T23:59:00
|
||||
AssignmentGroup: Assignments
|
||||
AllowedAttempts: -1
|
||||
Description: this is the
|
||||
multi line
|
||||
description
|
||||
---
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
const questionMarkdown = quizQuestionMarkdownUtils.toMarkdown(firstQuestion);
|
||||
const expectedMarkdown = `Points: 1
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
short_answer`;
|
||||
expect(questionMarkdown).toContain(expectedMarkdown);
|
||||
});
|
||||
|
||||
it('essay question to markdown is correct', () => {
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 2023-08-21T23:59:00
|
||||
LockAt: 2023-08-21T23:59:00
|
||||
AssignmentGroup: Assignments
|
||||
AllowedAttempts: -1
|
||||
Description: this is the
|
||||
multi line
|
||||
description
|
||||
---
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
essay
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
const questionMarkdown = quizQuestionMarkdownUtils.toMarkdown(firstQuestion);
|
||||
const expectedMarkdown = `Points: 1
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
essay`;
|
||||
expect(questionMarkdown).toContain(expectedMarkdown);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user