1
1
import React from 'react' ;
2
2
import {
3
- render ,
4
3
fireEvent ,
4
+ render ,
5
5
RenderAPI ,
6
6
} from 'react-native-testing-library' ;
7
7
import { ApplicationProvider } from '@kitten/theme' ;
@@ -17,7 +17,8 @@ import { CalendarRange } from '@kitten/ui/calendar/type';
17
17
18
18
jest . useFakeTimers ( ) ;
19
19
20
- const CURRENT_MONTH : number = new Date ( ) . getMonth ( ) ;
20
+ const now : Date = new Date ( ) ;
21
+ const today = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) , 0 , 0 , 0 ) ;
21
22
22
23
interface State {
23
24
range : CalendarRange < Date > ;
@@ -56,7 +57,7 @@ class TestApplication extends React.Component<TestAppProps, State> {
56
57
describe ( '@range-calendar: component checks' , ( ) => {
57
58
58
59
it ( '* start range date selected properly' , ( ) => {
59
- const expectedStartDate : Date = new Date ( 2019 , CURRENT_MONTH , 11 ) ;
60
+ const expectedStartDate : Date = new Date ( now . getFullYear ( ) , now . getMonth ( ) , 11 ) ;
60
61
const application : RenderAPI = render ( < TestApplication /> ) ;
61
62
62
63
fireEvent . press ( application . getAllByText ( '11' ) [ 0 ] ) ;
@@ -66,8 +67,8 @@ describe('@range-calendar: component checks', () => {
66
67
} ) ;
67
68
68
69
it ( '* range selected works properly' , ( ) => {
69
- const expectedStartDate : Date = new Date ( 2019 , CURRENT_MONTH , 11 ) ;
70
- const expectedEndDate : Date = new Date ( 2019 , CURRENT_MONTH , 26 ) ;
70
+ const expectedStartDate : Date = new Date ( now . getFullYear ( ) , now . getMonth ( ) , 11 ) ;
71
+ const expectedEndDate : Date = new Date ( now . getFullYear ( ) , now . getMonth ( ) , 26 ) ;
71
72
const application : RenderAPI = render ( < TestApplication /> ) ;
72
73
73
74
fireEvent . press ( application . getAllByText ( '11' ) [ 0 ] ) ;
@@ -79,7 +80,7 @@ describe('@range-calendar: component checks', () => {
79
80
} ) ;
80
81
81
82
it ( '* range re-selected properly 1' , ( ) => {
82
- const expectedStartDate : Date = new Date ( 2019 , CURRENT_MONTH , 19 ) ;
83
+ const expectedStartDate : Date = new Date ( now . getFullYear ( ) , now . getMonth ( ) , 19 ) ;
83
84
const application : RenderAPI = render ( < TestApplication /> ) ;
84
85
85
86
fireEvent . press ( application . getAllByText ( '11' ) [ 0 ] ) ;
@@ -92,7 +93,7 @@ describe('@range-calendar: component checks', () => {
92
93
} ) ;
93
94
94
95
it ( '* range re-selected properly 2' , ( ) => {
95
- const expectedStartDate : Date = new Date ( 2019 , CURRENT_MONTH , 8 ) ;
96
+ const expectedStartDate : Date = new Date ( now . getFullYear ( ) , now . getMonth ( ) , 8 ) ;
96
97
const application : RenderAPI = render ( < TestApplication /> ) ;
97
98
98
99
fireEvent . press ( application . getAllByText ( '11' ) [ 0 ] ) ;
0 commit comments