-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #875 from concord-consortium/181914428-movable-val…
…ues-can-be-placed-on-a-dot-plot feat: Movable values can be placed on a dot plot (PT-185758373)
- Loading branch information
Showing
19 changed files
with
644 additions
and
128 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
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
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
71 changes: 63 additions & 8 deletions
71
v3/src/components/graph/adornments/movable-value/movable-value-model.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 |
---|---|---|
@@ -1,13 +1,68 @@ | ||
import { MovableValueModel } from "./movable-value-model" | ||
|
||
describe("MovableValueModel", () => { | ||
it("can be created with a value", () => { | ||
const movableValue = MovableValueModel.create({value: 1}) | ||
expect(movableValue.value).toEqual(1) | ||
}) | ||
it("can have its value changed", () => { | ||
const movableValue = MovableValueModel.create({value: 1}) | ||
movableValue.setValue(2) | ||
expect(movableValue.value).toEqual(2) | ||
it("can be created with a value and have that value changed", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
expect(movableValue.values.get("{}")).toEqual([5]) | ||
movableValue.replaceValue(10, "{}") | ||
expect(movableValue.values.get("{}")).toEqual([10]) | ||
}) | ||
it("can be created with a value and have another value added", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
expect(movableValue.values.get("{}")).toEqual([5]) | ||
movableValue.addValue(10) | ||
expect(movableValue.values.get("{}")).toEqual([5, 10]) | ||
}) | ||
it("can delete a value in a set given that value's index number in the array of values", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
movableValue.addValue(10) | ||
expect(movableValue.values.get("{}")).toEqual([5, 10]) | ||
movableValue.deleteValue() | ||
expect(movableValue.values.get("{}")).toEqual([5]) | ||
}) | ||
it("can delete a value set", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
expect(movableValue.values.get("{}")).toEqual([5]) | ||
movableValue.deleteAllValues() | ||
expect(movableValue.values.get("{}")).toEqual([]) | ||
}) | ||
it("can provide a sorted list of values", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
movableValue.addValue(10) | ||
movableValue.addValue(2) | ||
expect(movableValue.sortedValues("{}")).toEqual([2, 5, 10]) | ||
}) | ||
it("can provide a list of values that has been updated with a current drag value", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
movableValue.addValue(10) | ||
movableValue.addValue(2) | ||
movableValue.updateDrag(7, "{}", 0) | ||
expect(movableValue.valuesForKey("{}")).toEqual([7, 10, 2]) | ||
movableValue.endDrag(7, "{}", 0) | ||
expect(movableValue.valuesForKey("{}")).toEqual([7, 10, 2]) | ||
}) | ||
it("can provide a sorted list of values that has been updated with a current drag value", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setInitialValue(5, "{}") | ||
movableValue.addValue(10) | ||
movableValue.addValue(2) | ||
movableValue.updateDrag(7, "{}", 0) | ||
expect(movableValue.sortedValues("{}")).toEqual([2, 7, 10]) | ||
movableValue.endDrag(7, "{}", 0) | ||
expect(movableValue.sortedValues("{}")).toEqual([2, 7, 10]) | ||
}) | ||
it("can provide a new value that is 1/3 into the largest gap between values", () => { | ||
const movableValue = MovableValueModel.create() | ||
movableValue.setAxisMin(0) | ||
movableValue.setAxisMax(20) | ||
movableValue.setInitialValue(10, "{}") | ||
movableValue.addValue(15) | ||
expect(movableValue.newValue("{}")).toEqual(3.3333333333333335) | ||
}) | ||
}) |
141 changes: 137 additions & 4 deletions
141
v3/src/components/graph/adornments/movable-value/movable-value-model.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
19 changes: 19 additions & 0 deletions
19
v3/src/components/graph/adornments/movable-value/movable-value-registration.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,19 @@ | ||
import { getAdornmentComponentInfo } from "../adornment-component-info" | ||
import { getAdornmentContentInfo } from "../adornment-content-info" | ||
import { kMovableValueClass, kMovableValuePrefix, kMovableValueType } from "./movable-value-types" | ||
import "./movable-value-registration" | ||
|
||
describe("Movable value registration", () => { | ||
it("Registers content and component info", () => { | ||
const movableValueContentInfo = getAdornmentContentInfo(kMovableValueType) | ||
expect(movableValueContentInfo).toBeDefined() | ||
expect(movableValueContentInfo?.type).toBe(kMovableValueType) | ||
expect(movableValueContentInfo?.modelClass).toBeDefined() | ||
expect(movableValueContentInfo?.prefix).toBe(kMovableValuePrefix) | ||
const movableValueComponentInfo = getAdornmentComponentInfo(kMovableValueType) | ||
expect(movableValueComponentInfo).toBeDefined() | ||
expect(movableValueComponentInfo?.adornmentEltClass).toBe(kMovableValueClass) | ||
expect(movableValueComponentInfo?.Component).toBeDefined() | ||
expect(movableValueComponentInfo?.type).toBe(kMovableValueType) | ||
}) | ||
}) |
Oops, something went wrong.