-
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.
[benc/split-number-line-widget] Create getNumberLinePublicWidgetOptions
- Loading branch information
1 parent
67e5e6c
commit 8489c6b
Showing
5 changed files
with
71 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
41 changes: 41 additions & 0 deletions
41
packages/perseus-core/src/widgets/number-line/number-line-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,41 @@ | ||
import getNumberLinePublicWidgetOptions from "./number-line-util"; | ||
|
||
import type {PerseusNumberLineWidgetOptions} from "../../data-schema" | ||
|
||
describe("getNumberLinePublicWidgetOptions", () => { | ||
it("removes correctX and correctRel", () => { | ||
const options: PerseusNumberLineWidgetOptions = { | ||
correctRel: "lt", | ||
correctX: 42, | ||
range: [0, 100], | ||
numDivisions: 5, | ||
tickStep: 6, | ||
divisionRange: [], | ||
initialX: 3, | ||
labelRange: [], | ||
labelStyle: "", | ||
labelTicks: false, | ||
snapDivisions: 0, | ||
isTickCtrl: false, | ||
showTooltips: false, | ||
static: false, | ||
}; | ||
|
||
const publicOptions = getNumberLinePublicWidgetOptions(options); | ||
|
||
expect(publicOptions).toEqual({ | ||
range: [0, 100], | ||
numDivisions: 5, | ||
tickStep: 6, | ||
divisionRange: [], | ||
initialX: 3, | ||
labelRange: [], | ||
labelStyle: "", | ||
labelTicks: false, | ||
snapDivisions: 0, | ||
isTickCtrl: false, | ||
showTooltips: false, | ||
static: false, | ||
}) | ||
}) | ||
}) |
24 changes: 24 additions & 0 deletions
24
packages/perseus-core/src/widgets/number-line/number-line-util.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,24 @@ | ||
import type {PerseusNumberLineWidgetOptions} from "../../data-schema"; | ||
|
||
type NumberLinePublicWidgetOptions = Pick< | ||
PerseusNumberLineWidgetOptions, | ||
| "range" | ||
| "labelRange" | ||
| "labelStyle" | ||
| "labelTicks" | ||
| "isTickCtrl" | ||
| "divisionRange" | ||
| "numDivisions" | ||
| "snapDivisions" | ||
| "tickStep" | ||
| "initialX" | ||
| "showTooltips" | ||
| "static" | ||
>; | ||
|
||
export default function getNumberLinePublicWidgetOptions( | ||
options: PerseusNumberLineWidgetOptions, | ||
): NumberLinePublicWidgetOptions { | ||
const {correctX: _, correctRel: __, ...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