Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
MathyouMB committed Aug 5, 2024
1 parent 762d4ed commit aa219d2
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { describe, expect } from "@jest/globals";
import Generator from "./generator";

describe("comp2804/2019-winter-final/1", () => {
describe("createSetSizes", () => {
it("will make sizeA smaller than sizeB", () => {
const generator = new Generator();

const [sizeA, sizeB] = generator.createSetSizes();

expect(sizeA).toBeLessThanOrEqual(sizeB);
});
});

describe("createOptions", () => {
it("will return four options", () => {
const generator = new Generator();

const options = generator.createOptions(1, 2);

expect(options).toHaveLength(4);
});

it("will have exactly one correct option", () => {
const generator = new Generator();

const options = generator.createOptions(1, 2);
const correctOptions = options.filter((option) => option.correct);

expect(correctOptions).toHaveLength(1);
});
});

describe("createCorrectOption", () => {
it("will return the correct option", () => {
const generator = new Generator();

const option = generator.createCorrectOption(7, 13);

expect(option.label).toBe("$\\frac{13!}{6!}$");
expect(option.correct).toBe(true);
});
});

describe("createIncorrectOption1", () => {
it("will return an option where the numerator and delimeter are flipped", () => {
const generator = new Generator();

const option = generator.createIncorrectOption1(7, 13);

expect(option.label).toBe("$\\frac{6!}{13!}$");
expect(option.correct).toBe(false);
});
});

describe("createIncorrectOption2", () => {
it("will return an option where the delimeter is one less than the correct option", () => {
const generator = new Generator();

const option = generator.createIncorrectOption2(7, 13);

expect(option.label).toBe("$\\frac{13!}{5!}$");
expect(option.correct).toBe(false);
});
});

describe("createIncorrectOption3", () => {
it("will return an option where the numerator is one less than the correct option and the delimeter is one more than the correct option", () => {
const generator = new Generator();

const option = generator.createIncorrectOption3(7, 13);

expect(option.label).toBe("$\\frac{12!}{7!}$");
expect(option.correct).toBe(false);
});
});
});
33 changes: 33 additions & 0 deletions src/content/questions/comp2804/2022-winter-final/1/generator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MultipleChoiceQuestionGenerator } from "@common/MultipleChoiceQuestionGenerator";
import type {
MultipleChoiceQuestion,
MultipleChoiceQuestionOption,
} from "@common/MultipleChoiceQuestionGenerator";

class Generator extends MultipleChoiceQuestionGenerator {
generateQuestion(): MultipleChoiceQuestion {
return {
body: "example body",
options: [
{
label: "option1",
correct: true,
},
{
label: "option2",
correct: false,
},
{
label: "option3",
correct: false,
},
{
label: "option4",
correct: false,
},
],
};
}
}

export default Generator;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type: multiple-choice
author: Michiel Smid
question: comp2804/2022-winter-final/1/question.ts
solution: comp2804/2022-winter-final/1/solution.md
generator: comp2804/2022-winter-final/1/generator.ts
tags:
- comp2804
- comp2804-final
Expand Down

0 comments on commit aa219d2

Please sign in to comment.