-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numeric-Input: Extract validation from scorer #1882
Numeric-Input: Extract validation from scorer #1882
Conversation
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (6a26500) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1882 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1882 |
Size Change: -9 B (0%) Total Size: 1.29 MB
ℹ️ View Unchanged
|
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
packages/perseus/src/widgets/numeric-input/validate-numeric-input.ts
Outdated
Show resolved
Hide resolved
const mockValidator = jest | ||
.spyOn(NumericInputValidator, "default") | ||
.mockReturnValue(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to mock the validator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed my mind. The numeric-input
allows an empty string to be correct for answers that have coefficient
set to true.
// A coefficient style number allows the student to use - for -1 and an empty string to mean 1.
coefficient: boolean;
I'm going to revert the validator entirely and delete it as marking an empty string as "invalid"
is going to cause false-negative results.
…put.ts Co-authored-by: Matthew <[email protected]>
7a5ac63
to
6a26500
Compare
Summary:
This PR extracts validation from the
numeric-input
's scorer function. In reality, it's an empty function, but it follows our conventions for having the scorer call a validator first. I've created the standard tests to ensure that scorer calls the validator.Issue: LEMS-2607
Test plan:
yarn test
yarn typecheck