Skip to content

Commit

Permalink
LOOM-1535: minor modificationto test fo provide clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
Parisistan committed Aug 9, 2024
1 parent c113ff1 commit 889eeb5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/bpk-component-slider/src/form-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ window.ResizeObserver =
unobserve: jest.fn(),
}));

describe('BpkSlider form test', () => {
describe('BpkSlider form-test for single-thumb slider', () => {
it('should work as a form component in a form', async () => {
const Wrap = () => {
const [sliderValue, setSliderValue] = useState<number[]>([50]);
const [sliderValue, setSliderValue] = useState<number>(50); // single-thumb slider with only max value
return (
<form data-testid="form">
<BpkSlider
Expand All @@ -46,7 +46,7 @@ describe('BpkSlider form test', () => {
ariaLabel={['slider']}
ariaValuetext={['min', 'max']}
data-testid="mySlider"
onChange={(value) => setSliderValue(Array.isArray(value) ? value : [value])}
onChange={(value) => setSliderValue(value as number)}
/>
</form>
);
Expand All @@ -66,10 +66,10 @@ describe('BpkSlider form test', () => {
});
});

it('should emit change event when both sides of slider value are changed', async () => {
it('should emit change event when both sides of slider value are changed for two-thumb slider', async () => {
const handleChange = jest.fn();
const Wrap = () => {
const [sliderValue, setSliderValue] = useState<number[]>([0, 100]);
const [sliderValue, setSliderValue] = useState<number[]>([0, 100]); // two-thumb slider with min and max value
return (
<form data-testid="form">
<BpkSlider
Expand All @@ -81,9 +81,8 @@ describe('BpkSlider form test', () => {
ariaValuetext={['0', '100']}
value={sliderValue}
onChange={(value) => {
handleChange(value);
setSliderValue(Array.isArray(value) ? value : [value]);

handleChange(value as number[]);
setSliderValue(value as number[]);
}}
/>
</form>
Expand Down

0 comments on commit 889eeb5

Please sign in to comment.