-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a function to get the public options for a Matrix widget (#2207)
Issue: https://khanacademy.atlassian.net/browse/LEMS-2762 ## Test plan: `yarn test` Author: benchristel Reviewers: Myranae, handeyeco, jeremywiebe Required Reviewers: Approved By: Myranae Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2207
- Loading branch information
1 parent
649e6b1
commit 097176a
Showing
6 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
"@khanacademy/perseus-core": minor | ||
--- | ||
|
||
Create a function to get the public options for a Matrix widget |
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
27 changes: 27 additions & 0 deletions
27
packages/perseus-core/src/widgets/matrix/matrix-util.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,27 @@ | ||
import getMatrixPublicWidgetOptions from "./matrix-util"; | ||
|
||
import type {PerseusMatrixWidgetOptions} from "../../data-schema"; | ||
|
||
describe("getMatrixPublicWidgetOptions", () => { | ||
it("removes the `answers` field", () => { | ||
const options: PerseusMatrixWidgetOptions = { | ||
answers: [ | ||
[1, 2], | ||
[3, 4], | ||
], | ||
cursorPosition: [0, 0], | ||
matrixBoardSize: [2, 2], | ||
prefix: "the prefix", | ||
suffix: "the suffix", | ||
}; | ||
|
||
const publicOptions = getMatrixPublicWidgetOptions(options); | ||
|
||
expect(publicOptions).toEqual({ | ||
cursorPosition: [0, 0], | ||
matrixBoardSize: [2, 2], | ||
prefix: "the prefix", | ||
suffix: "the suffix", | ||
}); | ||
}); | ||
}); |
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,13 @@ | ||
import type {PerseusMatrixWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
type MatrixPublicWidgetOptions = Pick< | ||
PerseusMatrixWidgetOptions, | ||
"prefix" | "suffix" | "cursorPosition" | "matrixBoardSize" | "static" | ||
>; | ||
|
||
export default function getMatrixPublicWidgetOptions( | ||
options: PerseusMatrixWidgetOptions, | ||
): MatrixPublicWidgetOptions { | ||
const {answers: _, ...publicOptions} = options; | ||
return publicOptions; | ||
} |
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
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