Skip to content

Commit

Permalink
fix: fix rendering of DatePickerFooter when show_reset_button is prov…
Browse files Browse the repository at this point in the history
…ided (#1197)
  • Loading branch information
langz authored Jan 14, 2022
1 parent e50fb6f commit d7d4507
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export default class DatePickerFooter extends React.PureComponent {
if (
!isRange &&
!isTrue(show_submit_button) &&
!isTrue(show_cancel_button)
!isTrue(show_cancel_button) &&
!isTrue(show_reset_button)
) {
return <></>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ describe('DatePicker component', () => {

const Comp = mount(
<Component
range
opened
no_animation
show_reset_button
Expand All @@ -374,6 +373,54 @@ describe('DatePicker component', () => {
expect(resetElem.text()).toMatch(reset_button_text)
})

it('footer is rendered when show_reset_button is provided', () => {
const Comp = mount(<Component opened no_animation show_reset_button />)

const datePickerFooter = Comp.find('.dnb-date-picker__footer')
expect(datePickerFooter.exists()).toBe(true)
})

it('footer is rendered when show_cancel_button is provided', () => {
const Comp = mount(
<Component opened no_animation show_cancel_button />
)

const datePickerFooter = Comp.find('.dnb-date-picker__footer')
expect(datePickerFooter.exists()).toBe(true)
})

it('footer is rendered when show_submit_button is provided', () => {
const Comp = mount(
<Component opened no_animation show_submit_button />
)

const datePickerFooter = Comp.find('.dnb-date-picker__footer')
expect(datePickerFooter.exists()).toBe(true)
})

it('footer is rendered when range is provided', () => {
const Comp = mount(<Component opened no_animation range />)

const datePickerFooter = Comp.find('.dnb-date-picker__footer')
expect(datePickerFooter.exists()).toBe(true)
})

it('footer is not rendered', () => {
const Comp = mount(
<Component
opened
no_animation
show_reset_button={false}
show_cancel_button={false}
show_submit_button={false}
range={false}
/>
)

const datePickerFooter = Comp.find('.dnb-date-picker__footer')
expect(datePickerFooter.exists()).toBe(false)
})

it('has a working month correction', () => {
const Comp = mount(<Component show_input />)

Expand Down

0 comments on commit d7d4507

Please sign in to comment.