-
Notifications
You must be signed in to change notification settings - Fork 351
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 Table widget (#2189)
Issue: https://khanacademy.atlassian.net/browse/LEMS-2766 ## Test plan: `yarn test` Author: benchristel Reviewers: Myranae, benchristel, 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 for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2189
- Loading branch information
1 parent
10ee67a
commit 3ba74d1
Showing
6 changed files
with
50 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 Table 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
25 changes: 25 additions & 0 deletions
25
packages/perseus-core/src/widgets/table/table-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,25 @@ | ||
import getTablePublicWidgetOptions from "./table-util"; | ||
|
||
import type {PerseusTableWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
describe("getTablePublicWidgetOptions", () => { | ||
it("removes the answers", () => { | ||
const options: PerseusTableWidgetOptions = { | ||
headers: ["a", "b"], | ||
answers: [ | ||
["1", "2"], | ||
["3", "4"], | ||
], | ||
columns: 2, | ||
rows: 2, | ||
}; | ||
|
||
const publicOptions = getTablePublicWidgetOptions(options); | ||
|
||
expect(publicOptions).toEqual({ | ||
headers: ["a", "b"], | ||
columns: 2, | ||
rows: 2, | ||
}); | ||
}); | ||
}); |
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 {PerseusTableWidgetOptions} from "@khanacademy/perseus-core"; | ||
|
||
type TablePublicWidgetOptions = Pick< | ||
PerseusTableWidgetOptions, | ||
"headers" | "rows" | "columns" | ||
>; | ||
|
||
export default function getTablePublicWidgetOptions( | ||
options: PerseusTableWidgetOptions, | ||
): TablePublicWidgetOptions { | ||
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