diff --git a/packages/perseus/src/widgets/numeric-input/score-numeric-input.test.ts b/packages/perseus/src/widgets/numeric-input/score-numeric-input.test.ts index 144fc2a63b..b0ad938871 100644 --- a/packages/perseus/src/widgets/numeric-input/score-numeric-input.test.ts +++ b/packages/perseus/src/widgets/numeric-input/score-numeric-input.test.ts @@ -6,13 +6,39 @@ import scoreNumericInput, {maybeParsePercentInput} from "./score-numeric-input"; import type {PerseusNumericInputRubric} from "../../validation.types"; -describe("static function validate", () => { +describe("scoreNumericInput", () => { beforeEach(() => { jest.spyOn(Dependencies, "getDependencies").mockReturnValue( testDependencies, ); }); + it("is correct when input is empty but answer is 1 and coefficient: true", () => { + const rubric: PerseusNumericInputRubric = { + answers: [ + { + value: 1, + status: "correct", + maxError: 0, + simplify: "optional", + strict: false, + message: "", + }, + ], + coefficient: true, + }; + + const userInput = { + // Empty input being translated to "1" depends on coefficient being + // true. + currentValue: "", + }; + + const score = scoreNumericInput(userInput, rubric, mockStrings); + + expect(score).toHaveBeenAnsweredCorrectly(); + }); + it("with a simple value", () => { const rubric: PerseusNumericInputRubric = { answers: [