-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/selector org #606
Feature/selector org #606
Changes from 5 commits
667a0a5
25f4478
7ac652e
9dae22e
1818d54
622b3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { getCurrentUIData } from "."; | ||
import { initialState } from ".."; | ||
import { ColorSetting } from "../selection/types"; | ||
|
||
describe("getCurrentUIData", () => { | ||
it("returns empty array if default UI data has not been entered yet", () => { | ||
expect(getCurrentUIData(initialState)).toEqual([]); | ||
1; | ||
}); | ||
it("returns selectedUIDisplayData if colorSetting is equal to ColorSetting.UserSelected", () => { | ||
expect( | ||
getCurrentUIData({ | ||
...initialState, | ||
trajectory: { | ||
...initialState.trajectory, | ||
defaultUIData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#bbbbbb", | ||
}, | ||
], | ||
}, | ||
selection: { | ||
...initialState.selection, | ||
currentColorSetting: ColorSetting.UserSelected, | ||
selectedUIDisplayData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#000", | ||
}, | ||
], | ||
}, | ||
}) | ||
).toEqual([ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#000", | ||
}, | ||
]); | ||
}); | ||
|
||
it("returns defaultUIData if colorSetting is euqal to ColorSetting.Default", () => { | ||
expect( | ||
getCurrentUIData({ | ||
...initialState, | ||
trajectory: { | ||
...initialState.trajectory, | ||
defaultUIData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#bbbbbb", | ||
}, | ||
], | ||
}, | ||
selection: { | ||
...initialState.selection, | ||
currentColorSetting: ColorSetting.Default, | ||
selectedUIDisplayData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#000", | ||
}, | ||
], | ||
}, | ||
}) | ||
).toEqual([ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#bbbbbb", | ||
}, | ||
]); | ||
}); | ||
}); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a short comment at the top of this file that describes what this file is for, like you did in the PR description? I also see that the parent |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createSelector } from "reselect"; | ||
import { UIDisplayData } from "@aics/simularium-viewer"; | ||
|
||
import { getDefaultUIDisplayData } from "../trajectory/selectors"; | ||
import { | ||
getCurrentColorSetting, | ||
getSelectedUIDisplayData, | ||
} from "../selection/selectors"; | ||
import { ColorSetting } from "../selection/types"; | ||
|
||
export const getCurrentUIData = createSelector( | ||
[getCurrentColorSetting, getSelectedUIDisplayData, getDefaultUIDisplayData], | ||
( | ||
colorSetting: ColorSetting, | ||
sessionData: UIDisplayData, | ||
defaultData: UIDisplayData | ||
) => { | ||
const fileHasBeenParsed = defaultData.length > 0; | ||
if (!fileHasBeenParsed) { | ||
return []; | ||
} | ||
if (colorSetting === ColorSetting.UserSelected) { | ||
return sessionData; | ||
} | ||
return defaultData; | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved