-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added: intial tests for random question function handlers
- Loading branch information
Showing
2 changed files
with
58 additions
and
15 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
58 changes: 58 additions & 0 deletions
58
packages/api/src/functions/tests/randomQuestionHandlers.test.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,58 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { | ||
questionFormatGenerators, | ||
generateCombinedQuestionPrompts, | ||
processGeneratedQuestions, | ||
} from "../randomQuestionsHandlers"; | ||
|
||
import { generateChoicesPrompt, timeAndPointsPrompt } from "../gptHandlers"; | ||
|
||
describe("questionFormatGenerators", () => { | ||
it("It should generate format for multiple choice question/s", () => { | ||
const mcqFormat = questionFormatGenerators["multipleChoice"]; | ||
const output = `separator\nQuestion: [Your question here, max 100 characters] | ||
${generateChoicesPrompt( | ||
4, | ||
)}\nCorrect Answer: Option [Correct option number] ${timeAndPointsPrompt}`; | ||
|
||
expect(mcqFormat()).toEqual(output); | ||
}); | ||
|
||
it("It should generate format for multiselect question/s", () => { | ||
const multiselectFormat = questionFormatGenerators["multiselect"]; | ||
|
||
const output = `separator\nQuestion: [Your question here, max 100 characters] | ||
${generateChoicesPrompt( | ||
4, | ||
)}\nAll Correct Answers: Options [Correct option numbers separated by commas, e.g., 1,3] ${timeAndPointsPrompt}`; | ||
|
||
expect(multiselectFormat()).toEqual(output); | ||
}); | ||
|
||
it("It should generate format for identification question/s", () => { | ||
const identicationFormat = questionFormatGenerators["identification"]; | ||
|
||
const output = `separator\nQuestion: [Your question here, max 100 characters]\nAnswer: [Your answer here, max 68 characters] ${timeAndPointsPrompt}`; | ||
|
||
expect(identicationFormat()).toEqual(output); | ||
}); | ||
|
||
it("It should generate format for true or false question/s", () => { | ||
const tofFormat = questionFormatGenerators["trueOrFalse"]; | ||
|
||
const output = `separator\nQuestion: [Your question here, max 100 characters]\nAnswer: [True/False] ${timeAndPointsPrompt}`; | ||
|
||
expect(tofFormat()).toEqual(output); | ||
}); | ||
}); | ||
|
||
describe("generateCombinedQuestionPrompts", () => { | ||
it("should generate correct prompt for a single question", () => { | ||
const combinedPrompts = generateCombinedQuestionPrompts( | ||
1, | ||
"Sample message", | ||
); | ||
expect(combinedPrompts).toContain("Sample message"); | ||
expect(combinedPrompts).toContain("separator"); | ||
}); | ||
}); |