Skip to content

Commit

Permalink
Code review: Michel
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Feb 28, 2024
1 parent 16dcad0 commit 5d01f83
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { expect } from 'chai';
import { screen } from '@mui-internal/test-utils';
import { adapterToUse } from 'test/utils/pickers';

const isDisable = (el: HTMLElement) => el.getAttribute('disabled') !== null;
const isDisabled = (el: HTMLElement) => el.getAttribute('disabled') !== null;

const testDisabledDate = (day: string, expectedAnswer: boolean[], isSingleCalendar: boolean) => {
expect(screen.getAllByRole('gridcell', { name: day }).map(isDisable)).to.deep.equal(
expect(screen.getAllByRole('gridcell', { name: day }).map(isDisabled)).to.deep.equal(
isSingleCalendar ? expectedAnswer.slice(0, 1) : expectedAnswer,
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const testControlledUnControlled: DescribeValueTestSuite<any, any> = (

const params = pickerParams as DescribeValueOptions<'picker', any>;

const isRangeType = ['date-range', 'date-time-range'].includes(params.type);
const isRangeType = params.type === 'date-range' || params.type === 'date-time-range';
const isDesktopRange = params.variant === 'desktop' && isRangeType;

describe('Controlled / uncontrolled value', () => {
Expand Down Expand Up @@ -257,10 +257,7 @@ export const testControlledUnControlled: DescribeValueTestSuite<any, any> = (
expect(fieldRoot).to.have.class(inputBaseClasses.error);
expect(fieldRoot).to.have.attribute('aria-invalid', 'true');

if (
(params.type === 'date-range' || params.type === 'date-time-range') &&
!params.isSingleInput
) {
if (isRangeType && !params.isSingleInput) {
const fieldRootEnd = getFieldInputRoot(1);
expect(fieldRootEnd).to.have.class(inputBaseClasses.error);
expect(fieldRootEnd).to.have.attribute('aria-invalid', 'true');
Expand Down
2 changes: 1 addition & 1 deletion test/utils/pickers/describeValue/testPickerActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const testPickerActionBar: DescribeValueTestSuite<any, 'picker'> = (
return;
}

const isRangeType = ['date-range', 'date-time-range'].includes(pickerParams.type);
const isRangeType = pickerParams.type === 'date-range' || pickerParams.type === 'date-time-range';

describe('Picker action bar', () => {
describe('clear action', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const testPickerOpenCloseLifeCycle: DescribeValueTestSuite<any, 'picker'>
return;
}

const isRangeType = ['date-range', 'date-time-range'].includes(pickerParams.type);
const isRangeType = pickerParams.type === 'date-range' || pickerParams.type === 'date-time-range';
const viewWrapperRole = isRangeType && pickerParams.variant === 'desktop' ? 'tooltip' : 'dialog';

describe('Picker open / close lifecycle', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/utils/pickers/openPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export type OpenPickerParams =
};

export const openPicker = (params: OpenPickerParams) => {
const isRangePicker = params.type === 'date-range' || params.type === 'date-time-range';
const isRangeType = params.type === 'date-range' || params.type === 'date-time-range';
const fieldSectionsContainer = getFieldSectionsContainer(
isRangePicker && !params.isSingleInput && params.initialFocus === 'end' ? 1 : 0,
isRangeType && !params.isSingleInput && params.initialFocus === 'end' ? 1 : 0,
);

if (isRangePicker) {
if (isRangeType) {
userEvent.mousePress(fieldSectionsContainer);

if (params.isSingleInput && params.initialFocus === 'end') {
Expand Down

0 comments on commit 5d01f83

Please sign in to comment.