Skip to content

Commit

Permalink
rename ColorSetting from plural
Browse files Browse the repository at this point in the history
  • Loading branch information
interim17 committed Nov 8, 2024
1 parent 7ac652e commit 9dae22e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/state/compoundSelectors/compoundSelectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getCurrentUIData } from ".";
import { initialState } from "..";
import { ColorSettings } from "../selection/types";
import { ColorSetting } from "../selection/types";

describe("getCurrentUIData", () => {
it("returns empty array if default UI data has not been entered yet", () => {
expect(getCurrentUIData(initialState)).toEqual([]);
});
it("returns selectedUIDisplayData if colorSetting is equal to ColorSettings.UserSelected", () => {
it("returns selectedUIDisplayData if colorSetting is equal to ColorSetting.UserSelected", () => {

Check failure on line 9 in src/state/compoundSelectors/compoundSelectors.test.ts

View workflow job for this annotation

GitHub Actions / Tests annotations (🧪 jest-coverage-report-action)

getCurrentUIData > returns selectedUIDisplayData if colorSetting is equal to ColorSetting.UserSelected

Error: expect(received).toEqual(expected) // deep equality - Expected - 1 + Received + 1 Array [ Object { - "color": "#000", + "color": "#bbbbbb", "displayStates": Array [], "name": "agent1", }, ] at Object.<anonymous> (/Users/runner/work/simularium-website/simularium-website/src/state/compoundSelectors/compoundSelectors.test.ts:35:11) at Promise.then.completed (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/utils.js:298:28) at new Promise (<anonymous>) at callAsyncCircusFn (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/utils.js:231:10) at _callCircusTest (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/run.js:316:40) at processTicksAndRejections (node:internal/process/task_queues:95:5) at _runTest (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/run.js:252:3) at _runTestsForDescribeBlock (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/run.js:126:9) at _runTestsForDescribeBlock (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/run.js:121:9) at run (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/run.js:71:3) at runAndTransformResultsToJestFormat (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:76:19) at runTestInternal (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/Users/runner/work/simularium-website/simularium-website/node_modules/jest-runner/build/testWorker.js:106:12)
expect(
getCurrentUIData({
...initialState,
Expand All @@ -22,7 +22,7 @@ describe("getCurrentUIData", () => {
},
selection: {
...initialState.selection,
currentColorSettings: ColorSettings.UserSelected,
current: ColorSetting.UserSelected,
selectedUIDisplayData: [
{
name: "agent1",
Expand All @@ -41,7 +41,7 @@ describe("getCurrentUIData", () => {
]);
});

it("returns defaultUIData if colorSetting is euqal to ColorSettings.Default", () => {
it("returns defaultUIData if colorSetting is euqal to ColorSetting.Default", () => {
expect(
getCurrentUIData({
...initialState,
Expand All @@ -57,7 +57,7 @@ describe("getCurrentUIData", () => {
},
selection: {
...initialState.selection,
currentColorSettings: ColorSettings.Default,
currentColorSetting: ColorSetting.Default,
selectedUIDisplayData: [
{
name: "agent1",
Expand Down
16 changes: 6 additions & 10 deletions src/state/compoundSelectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
import { createSelector } from "reselect";
import { UIDisplayData } from "@aics/simularium-viewer";

import { getDefaultUIDisplayData } from "../trajectory/selectors";
import {
getCurrentColorSettings,
getCurrentColorSetting,
getSelectedUIDisplayData,
} from "../selection/selectors";
import { ColorSettings } from "../selection/types";
import { UIDisplayData } from "@aics/simularium-viewer";
import { ColorSetting } from "../selection/types";

export const getCurrentUIData = createSelector(
[
getCurrentColorSettings,
getSelectedUIDisplayData,
getDefaultUIDisplayData,
],
[getCurrentColorSetting, getSelectedUIDisplayData, getDefaultUIDisplayData],
(
colorSetting: ColorSettings,
colorSetting: ColorSetting,
sessionData: UIDisplayData,
defaultData: UIDisplayData
) => {
const fileHasBeenParsed = defaultData.length > 0;
if (!fileHasBeenParsed) {
return [];
}
if (colorSetting === ColorSettings.UserSelected) {
if (colorSetting === ColorSetting.UserSelected) {
return sessionData;
}
return defaultData;
Expand Down
4 changes: 2 additions & 2 deletions src/state/selection/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
SetRecentColorsAction,
SetSelectedAgentMetadataAction,
SetSelectedUIDisplayDataAction,
ColorSettings,
ColorSetting,
} from "./types";

export const initialState = {
Expand All @@ -37,7 +37,7 @@ export const initialState = {
recentColors: [],
selectedAgentMetadata: {},
selectedUIDisplayData: [],
currentColorSettings: ColorSettings.Default,
currentColorSetting: ColorSetting.Default,
};

const actionToConfigMap: TypeToDescriptionMap = {
Expand Down
4 changes: 2 additions & 2 deletions src/state/selection/selectors/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export const getSelectedAgentMetadata = (state: State) =>
state.selection.selectedAgentMetadata;
export const getSelectedUIDisplayData = (state: State) =>
state.selection.selectedUIDisplayData;
export const getCurrentColorSettings = (state: State) =>
state.selection.currentColorSettings;
export const getCurrentColorSetting = (state: State) =>
state.selection.currentColorSetting;
2 changes: 1 addition & 1 deletion src/state/selection/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export interface SetSelectedUIDisplayDataAction {
type: string;
}

export enum ColorSettings {
export enum ColorSetting {
UserSelected = "userSelected",
Default = "default",
}

0 comments on commit 9dae22e

Please sign in to comment.