-
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.
Add tests for propUpgrades functions (#1914)
## Summary: Only 3 widgets seem to use the `propUpgrades` mechanism: - Radio - Expression - Measurer None of them seemed to have tests (at least not direct tests), so this adds them. I also took out underscore after I wrote the tests. ## Test plan: This is the test plan Author: handeyeco Reviewers: jeremywiebe, handeyeco Required Reviewers: Approved By: jeremywiebe Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (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), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1914
- Loading branch information
Showing
6 changed files
with
138 additions
and
27 deletions.
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,5 @@ | ||
--- | ||
"@khanacademy/perseus": patch | ||
--- | ||
|
||
Add tests for propUpgrades functions (and remove underscore usage) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import MeasurerWidgetExport from "./measurer"; | ||
|
||
import type {PerseusMeasurerWidgetOptions} from "../../perseus-types"; | ||
|
||
describe("measurer", () => { | ||
describe("propUpgrades", () => { | ||
it("can upgrade from v0 to v1", () => { | ||
const v0props = { | ||
imageUrl: "url", | ||
imageTop: 42, | ||
imageLeft: 42, | ||
showProtractor: false, | ||
showRuler: false, | ||
rulerLabel: "test", | ||
rulerTicks: 4, | ||
rulerPixels: 4, | ||
rulerLength: 4, | ||
box: [4, 4], | ||
static: false, | ||
}; | ||
|
||
const expected: PerseusMeasurerWidgetOptions = { | ||
image: { | ||
url: "url", | ||
top: 42, | ||
left: 42, | ||
}, | ||
showProtractor: false, | ||
showRuler: false, | ||
rulerLabel: "test", | ||
rulerTicks: 4, | ||
rulerPixels: 4, | ||
rulerLength: 4, | ||
box: [4, 4], | ||
static: false, | ||
}; | ||
|
||
const result: PerseusMeasurerWidgetOptions = | ||
MeasurerWidgetExport.propUpgrades["1"](v0props); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
}); |
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
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