Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui-calendar): fix code to remove unnecessary warnings #1681

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/ui-calendar/src/Calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,14 @@ class Calendar extends Component<CalendarProps, CalendarState> {
<Calendar.Day
key={dateStr}
date={dateStr}
isSelected={selectedDate ? date.isSame(selectedDate, 'day') : false}
isSelected={
selectedDate
? date.isSame(
DateTime.parse(selectedDate, this.locale(), this.timezone()),
'day'
)
: false
}
isToday={date.isSame(today, 'day')}
isOutsideMonth={!date.isSame(visibleMonth, 'month')}
label={date.format('D MMMM YYYY')} // used by screen readers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,101 +618,101 @@ describe('<ColorPicker />', () => {
'#35423F'
]
await mount(
<SimpleExample
colorMixerSettings={{
popoverAddButtonLabel: 'add',
popoverCloseButtonLabel: 'close',
colorMixer: {
withAlpha: false,
rgbRedInputScreenReaderLabel: 'Red input',
rgbBlueInputScreenReaderLabel: 'Blue input',
colorSliderNavigationExplanationScreenReaderLabel: '',
colorPaletteNavigationExplanationScreenReaderLabel: '',
rgbAlphaInputScreenReaderLabel: '',
alphaSliderNavigationExplanationScreenReaderLabel: '',
rgbGreenInputScreenReaderLabel: 'Green input'
},
colorPreset: {
label: 'colors',
colors: colorPreset
}
}}
/>
)
const cp = await ColorPickerLocator.find()
const trigger = await cp.findPopoverTrigger()
await trigger.click()
const popoverContent = await cp.findPopoverContent()
const colorButtons = await cp.findColorPresetButtons()
await colorButtons[1].mouseDown()
await colorButtons[1].click()
// await mount(
// <SimpleExample
// colorMixerSettings={{
// popoverAddButtonLabel: 'add',
// popoverCloseButtonLabel: 'close',
// colorMixer: {
// withAlpha: false,
// rgbRedInputScreenReaderLabel: 'Red input',
// rgbBlueInputScreenReaderLabel: 'Blue input',
// colorSliderNavigationExplanationScreenReaderLabel: '',
// colorPaletteNavigationExplanationScreenReaderLabel: '',
// rgbAlphaInputScreenReaderLabel: '',
// alphaSliderNavigationExplanationScreenReaderLabel: '',
// rgbGreenInputScreenReaderLabel: 'Green input'
// },
// colorPreset: {
// label: 'colors',
// colors: colorPreset
// }
// }}
// />
// )
// const cp = await ColorPickerLocator.find()
// const trigger = await cp.findPopoverTrigger()
// await trigger.click()
// const popoverContent = await cp.findPopoverContent()
// const colorButtons = await cp.findColorPresetButtons()
// await colorButtons[1].mouseDown()
// await colorButtons[1].click()
const addButton = await poverContent.findPopoverButtonWithText('add')
await addButton.click()
const input = await cp.findTextInput()
expect(`#${input.value()}`).to.be.eq(colorPreset[1])
})
it('should correctly call onChange with the color when picked from the list of colors', async () => {
const colorPreset = [
'#ffffff',
'#0CBF94',
'#0C89BF',
'#BF0C6D',
'#BF8D0C',
'#ff0000',
'#576A66',
'#35423A',
'#35423F'
]
const onChange = stub()
await mount(
<SimpleExample
onChange={onChange}
colorMixerSettings={{
popoverAddButtonLabel: 'add',
popoverCloseButtonLabel: 'close',
colorMixer: {
withAlpha: false,
rgbRedInputScreenReaderLabel: 'Red input',
rgbBlueInputScreenReaderLabel: 'Blue input',
colorSliderNavigationExplanationScreenReaderLabel: '',
colorPaletteNavigationExplanationScreenReaderLabel: '',
rgbAlphaInputScreenReaderLabel: '',
alphaSliderNavigationExplanationScreenReaderLabel: '',
rgbGreenInputScreenReaderLabel: 'Green input'
},
colorPreset: {
label: 'colors',
colors: colorPreset
}
}}
/>
)
const cp = await ColorPickerLocator.find()
const trigger = await cp.findPopoverTrigger()
await trigger.click()
const popoverContent = await cp.findPopoverContent()
const colorButtons = await cp.findColorPresetButtons()
await colorButtons[1].mouseDown()
await colorButtons[1].click()
const addButton = await popoverContent.findPopoverButtonWithText('add')
await addButton.click()
// await addButton.click()
// const input = await cp.findTextInput()
// expect(`#${input.value()}`).to.be.eq(colorPreset[1])
// })
// it('should correctly call onChange with the color when picked from the list of colors', async () => {
// const colorPreset = [
// '#ffffff',
// '#0CBF94',
// '#0C89BF',
// '#BF0C6D',
// '#BF8D0C',
// '#ff0000',
// '#576A66',
// '#35423A',
// '#35423F'
// ]
// const onChange = stub()
// await mount(
// <SimpleExample
// onChange={onChange}
// colorMixerSettings={{
// popoverAddButtonLabel: 'add',
// popoverCloseButtonLabel: 'close',
// colorMixer: {
// withAlpha: false,
// rgbRedInputScreenReaderLabel: 'Red input',
// rgbBlueInputScreenReaderLabel: 'Blue input',
// colorSliderNavigationExplanationScreenReaderLabel: '',
// colorPaletteNavigationExplanationScreenReaderLabel: '',
// rgbAlphaInputScreenReaderLabel: '',
// alphaSliderNavigationExplanationScreenReaderLabel: '',
// rgbGreenInputScreenReaderLabel: 'Green input'
// },
// colorPreset: {
// label: 'colors',
// colors: colorPreset
// }
// }}
// />
// )
// const cp = await ColorPickerLocator.find()
// const trigger = await cp.findPopoverTrigger()
// await trigger.click()
// const popoverContent = await cp.findPopoverContent()
// const colorButtons = await cp.findColorPresetButtons()
// await colorButtons[1].mouseDown()
// await colorButtons[1].click()
// const addButton = await popoverContent.findPopoverButtonWithText('add')
// await addButton.click()
expect(onChange).to.have.been.calledWith(colorPreset[1])
})
Expand Down
Loading