-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utilize new status writer for settings and view + bug fix
- Improve usage of status writer for settings and view - Fix bug: Render `ContentError` in view withing wrapperDivRef to ensure correct sizing.
- Loading branch information
1 parent
9f94ec6
commit 6c58497
Showing
4 changed files
with
82 additions
and
19 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
12 changes: 12 additions & 0 deletions
12
frontend/src/modules/SimulationTimeSeriesMatrix/utils/stringUtils.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,12 @@ | ||
/** | ||
* Utility function to make a display friendly string from an array of strings. | ||
* | ||
* Example: ["a", "b", "c"] -> "a, b and c" | ||
*/ | ||
export function makeDisplayStringFromStringArray(stringArray: string[]): string { | ||
return stringArray.length === 0 | ||
? "" | ||
: stringArray.length === 1 | ||
? stringArray[0] | ||
: stringArray.slice(0, -1).join(", ") + " and " + stringArray[stringArray.length - 1]; | ||
} |
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
11 changes: 11 additions & 0 deletions
11
frontend/tests/unit-tests/SimulationTimeSeriesMatrixUtils.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,11 @@ | ||
// import { scaleHexColorLightness } from "@modules/SimulationTimeSeriesMatrix/utils/colorUtils"; | ||
import { makeDisplayStringFromStringArray } from "@modules/SimulationTimeSeriesMatrix/utils/stringUtils"; | ||
|
||
describe("Test of utility functions for SimulationTimeSeriesMatrix module", () => { | ||
test("Test make display string from string array", () => { | ||
expect(makeDisplayStringFromStringArray(["a", "b", "c"])).toBe("a, b and c"); | ||
expect(makeDisplayStringFromStringArray(["a"])).toBe("a"); | ||
expect(makeDisplayStringFromStringArray([])).toBe(""); | ||
expect(makeDisplayStringFromStringArray(["a", "b"])).toBe("a and b"); | ||
}); | ||
}); |