Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tayyabataimur committed Jan 24, 2025
1 parent 1f3ae76 commit b72ca24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 108 deletions.
93 changes: 0 additions & 93 deletions packages/lab/src/__tests__/slider/utils.spec.tsx

This file was deleted.

13 changes: 4 additions & 9 deletions packages/lab/stories/slider/slider.qa.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const BottomLabel: StoryFn<QAContainerProps> = (props) => {
width={1200}
{...props}
>
<Slider style={{ width: "300px" }} marks="bottom" defaultValue={[5]} />
<Slider style={{ width: "300px" }} defaultValue={5} />
</QAContainer>
);
};
Expand All @@ -55,12 +55,7 @@ export const WithMarks: StoryFn<QAContainerProps> = (props) => {
width={1200}
{...props}
>
<Slider
style={{ width: "300px" }}
marks="all"
step={2}
defaultValue={[4]}
/>
<Slider style={{ width: "300px" }} step={2} defaultValue={4} />
</QAContainer>
);
};
Expand All @@ -81,11 +76,11 @@ export const Range: StoryFn<QAContainerProps> = (props) => {
>
<Slider
style={{ width: "300px" }}
marks="bottom"
labelPosition="bottom"
step={2}
min={0}
max={50}
defaultValue={[10, 40]}
defaultValue={40}
/>
</QAContainer>
);
Expand Down
12 changes: 6 additions & 6 deletions packages/lab/stories/slider/slider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Slider, type SliderProps } from "@salt-ds/lab";
import type { StoryFn } from "@storybook/react";
import { type ChangeEvent, useEffect, useState } from "react";

const validateSingle = (value: string, bounds: [number, number]) => {
const validateSingle = (value: number, bounds: [number, number]) => {
if (Number.isNaN(Number(value))) return false;
if (Number(value) < bounds[0] || Number(value) > bounds[1]) return false;
return true;
Expand Down Expand Up @@ -68,7 +68,7 @@ export const CustomStep = () => (
</FormField>
<FormField>
<FormFieldLabel>Step: 0.3 (not multiple of total range)</FormFieldLabel>
<Slider min={0} max={1} step={0.3} defaultValue={"0.9"} />
<Slider min={0} max={1} step={0.3} defaultValue={0.9} />
</FormField>
</StackLayout>
);
Expand All @@ -88,7 +88,7 @@ WithMarks.args = {
};

export const WithInput = () => {
const [value, setValue] = useState("5");
const [value, setValue] = useState(5);
const [inputValue, setInputValue] = useState(value);
const [validationStatus, setValidationStatus] = useState<undefined | "error">(
undefined,
Expand All @@ -97,13 +97,13 @@ export const WithInput = () => {

const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
const inputValue = event.target.value;
setInputValue(inputValue);
setInputValue(Number.parseFloat(inputValue));
if (Number.isNaN(Number(inputValue))) return;
setValue(inputValue);
setValue(Number.parseFloat(inputValue));
};

const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
setInputValue(event.target.value);
setInputValue(Number.parseFloat(event.target.value));
setValue(inputValue);
};

Expand Down

0 comments on commit b72ca24

Please sign in to comment.