Skip to content

Commit

Permalink
chore: add unavailableDates to useDate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rares Crisan authored and Rares Crisan committed Dec 21, 2019
1 parent 9cff2ef commit c8a31fc
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/hooks/src/useDay/useDay.test.ts
Expand Up @@ -24,6 +24,7 @@ test('should execute onClick callback', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand All @@ -50,6 +51,35 @@ test('should not execute onClick callback, because day is disabled', () => {
isDateBlocked: () => true,
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

act(() => {
result.current.onClick()
})

expect(result.current.disabledDate).toBe(true)
expect(onDateSelect).not.toBeCalled()
})

test('should not allow date to be selected when supplied as unavailable', () => {
const onDateSelect = jest.fn()
const {result} = renderHook(() =>
useDay({
date,
// @ts-ignore
dayRef,
onDateSelect,
focusedDate: null,
isDateSelected: jest.fn(),
isDateFocused: jest.fn(),
isFirstOrLastSelectedDate: jest.fn(),
isDateHovered: jest.fn(),
isDateBlocked: () => true,
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [new Date()],
}),
)

Expand All @@ -76,6 +106,7 @@ test('should be active', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand All @@ -97,6 +128,7 @@ test('should be active first or last day', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand All @@ -118,6 +150,7 @@ test('should be within range', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand All @@ -139,6 +172,7 @@ test('tabIndex should be 0', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand All @@ -160,6 +194,7 @@ test('should be unfocused', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand All @@ -181,6 +216,7 @@ test('should be focused', () => {
isDateBlocked: jest.fn(),
onDateFocus: jest.fn(),
onDateHover: jest.fn(),
unavailableDates: [],
}),
)

Expand Down

0 comments on commit c8a31fc

Please sign in to comment.