Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Sep 5, 2023
1 parent 0de7e64 commit c5ebee4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/static/src/app/components/WodinPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default defineComponent({
watch([() => props.redrawWatches, yAxisType], () => {
if (plotStyle.value !== fadePlotStyle) {
drawPlot()
drawPlot();
}
});
Expand Down
14 changes: 6 additions & 8 deletions app/static/src/app/components/options/NumericInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default defineComponent({
// wrap tooltip props update with update to input box
// as the v-tooltip directive needs an update to actually
// hide the tooltip
textValue.value = textValue.value + " ";
textValue.value = `${textValue.value} `;
tooltipProps.value.content = "";
textValue.value = textValue.value.trim();
}
Expand Down Expand Up @@ -108,25 +108,23 @@ export default defineComponent({
if (numeric > props.maxAllowed) {
tooltipProps.value.content = `Please enter a value no greater than ${props.maxAllowed}`;
return props.maxAllowed;
} else {
tooltipProps.value.content = "";
}
tooltipProps.value.content = "";
}
if (typeof props.minAllowed === "number") {
if (numeric < props.minAllowed) {
tooltipProps.value.content = (props.minAllowed === 0)
? "Please enter a non-negative number"
: `Please enter a value no less than ${props.minAllowed}`;
return props.minAllowed
} else {
tooltipProps.value.content = "";
return props.minAllowed;
}
tooltipProps.value.content = "";
}
if (Array.isArray(props.maxAllowed) && props.maxAllowed.length > 0) {
const maxesAllowed = [...props.maxAllowed] as BoundTooltip[];
validateArray(maxesAllowed, numeric, true)
validateArray(maxesAllowed, numeric, true);
if (numeric > maxesAllowed.at(-1)!.number) {
return maxesAllowed.at(-1)!.number;
Expand Down Expand Up @@ -170,7 +168,7 @@ export default defineComponent({
const cleanedValue = newVal.replace(/,/g, "");
const numeric = parseFloat(cleanedValue);
if (!Number.isNaN(numeric)) {
let validatedNumeric = minMaxValidation(numeric);
const validatedNumeric = minMaxValidation(numeric);
lastNumericValueSet.value = validatedNumeric;
emit("update", validatedNumeric);
} else if (props.placeholder) {
Expand Down
6 changes: 3 additions & 3 deletions app/static/src/app/components/options/RunOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ export default defineComponent({
return [
{
number: maxReplicatesDisplay.value,
message: 'Individual traces will not be shown past this point',
variant: 'warning'
message: "Individual traces will not be shown past this point",
variant: "warning"
},
{
number: maxReplicatesRun.value,
message: `Please enter a value less than ${maxReplicatesRun.value}`
}
] as BoundTooltip[]
] as BoundTooltip[];
});
const updateNumberOfReplicates = (newValue: number) => {
Expand Down
4 changes: 0 additions & 4 deletions app/static/src/app/components/run/RunStochasticPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export default defineComponent({
const maxReplicatesDisplay = (store.state.config as StochasticConfig)?.maxReplicatesDisplay || 50;
const showIndividualTraces = replicates <= maxReplicatesDisplay;
console.log(replicates)
console.log(maxReplicatesDisplay)
console.log(showIndividualTraces)
return discreteSeriesSetToPlotly(
filterSeriesSet(result, selectedVariables.value),
palette.value,
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function discreteSeriesSetToPlotly(
): WodinPlotData {
const individualLegends: string[] = [];
const series = showIndividualTraces ? s.values
: s.values.filter((el) => el.description !== "Individual");
: s.values.filter((el) => el.description !== "Individual");
return series.map(
(values: OdinSeriesSetValues) => {
const isIndividual = values.description === "Individual";
Expand Down
21 changes: 20 additions & 1 deletion app/static/tests/unit/components/options/runOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ describe("RunOptions", () => {
run: {
namespaced: true,
state: {
endTime: 99
endTime: 99,
numberOfReplicates: 10
},
mutations: {
SetEndTime: mockRunSetEndTime,
Expand Down Expand Up @@ -91,6 +92,24 @@ describe("RunOptions", () => {
expect(mockSensitivitySetEndTime.mock.calls[0][1]).toBe(101);
});

it("renders number of replicates correctly", () => {
const wrapper = getWrapper(0, { appType: `${AppType.Stochastic}` });
const noOfReplicates = wrapper.find("#number-of-replicates").findComponent(NumericInput);
expect(noOfReplicates.props("value")).toBe(10);
expect(noOfReplicates.props("minAllowed")).toBe(0);
expect(noOfReplicates.props("maxAllowed")).toStrictEqual([
{
number: 50,
message: "Individual traces will not be shown past this point",
variant: "warning"
},
{
number: 1000,
message: `Please enter a value less than ${1000}`
}
]);
});

it("can render and update number of replicates", async () => {
const wrapper = getWrapper(0, { appType: `${AppType.Stochastic}` });
const noOfReplicates = wrapper.find("#number-of-replicates");
Expand Down

0 comments on commit c5ebee4

Please sign in to comment.