Simon Egersand
2018-02-11 d4bf16e299f8ea25477ed9c15a336bce36affe4b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import * as React from "react";
import { Moment } from "moment";
import * as moment from "moment";
import * as ReactDatetime from "react-datetime";
 
/*
 Test the datetime picker.
 */
 
const TEST_BASIC_USAGE: JSX.Element = <ReactDatetime />;
 
/*
 Test date properties
 */
 
const TEST_DATE_PROPS_FOR_VALUE: JSX.Element = <ReactDatetime
        value={ new Date() }
    />;
 
const TEST_DATE_PROPS_FOR_DEFAULT_VALUE: JSX.Element = <ReactDatetime
        defaultValue={ new Date() }
    />;
 
const TEST_DATE_PROPS_FOR_VALUE_AS_MOMENT: JSX.Element = <ReactDatetime
        value={ moment() }
    />;
 
const TEST_DATE_PROPS_FOR_VALUE_AS_STRING: JSX.Element = <ReactDatetime
        value={ '1995-12-25' }
    />;
 
const TEST_DATE_PROPS_FOR_DEFAULT_VALUE_AS_MOMENT: JSX.Element = <ReactDatetime
        defaultValue={ moment() }
    />;
 
const TEST_DATE_PROPS_FOR_DEFAULT_VALUE_AS_STRING: JSX.Element = <ReactDatetime
        defaultValue={ '1995-12-25' }
    />;
 
/*
 Test formats
 */
 
const TEST_FORMAT_PROPS_AS_STRINGS: JSX.Element = <ReactDatetime
        dateFormat='mm/dd/yyyy'
        timeFormat='hh:mm:ss'
    />;
 
const TEST_FORMAT_PROPS_AS_BOOLEANS: JSX.Element = <ReactDatetime
        dateFormat={ false }
        timeFormat={ false }
    />;
 
/*
 Test boolean options
 */
 
const TEST_BOOLEAN_PROPS: JSX.Element = <ReactDatetime
        input={ false }
        open={ false }
        strictParsing={ false }
        closeOnSelect={ false }
        disableOnClickOutside={ false }
        utc={ false }
    />;
 
/*
 Test locale options
 */
 
const TEST_LOCALE_PROPS: JSX.Element = <ReactDatetime
        locale='en-us'
    />;
 
/*
 Test input props
 */
 
const TEST_INPUT_PROPS: JSX.Element = <ReactDatetime
        inputProps={
            {
                'placeholder': 'mm/dd/yyyy'
            }
        }
    />;
 
/*
 Test Event handlers
 */
 
 const TEST_EVENT_HANDLERS_WITH_STRINGS: JSX.Element = <ReactDatetime
         onChange={
             (momentOrInputString:string) => {}
         }
        onFocus={
            () => {}
        }
        onBlur={
            (momentOrInputString:string) => {}
        }
        onViewModeChange={
             (viewMode:string) => {}
         }
     />;
 
const TEST_EVENT_HANDLERS_WITH_MOMENT: JSX.Element = <ReactDatetime
        onChange={
            (momentOrInputString:Moment) => {}
        }
        onBlur={
            (momentOrInputString:Moment) => {}
        }
    />;
 
/*
 Test view mode and className
 */
 
const TEST_VIEW_MODE_AND_CLASS_PROPS: JSX.Element = <ReactDatetime
        viewMode='days'
        className='rdt'
    />;
 
/*
 Test date validator
 */
 
const TEST_DATE_VALIDATOR_PROP: JSX.Element = <ReactDatetime
        isValidDate={ (currentDate:any, selectedDate:any) => {
            return true;
        } }
    />;
 
/*
 Test customizable components
 */
 
const TEST_CUSTOMIZABLE_COMPONENT_PROPS: JSX.Element = <ReactDatetime
        renderDay={ (props: any, currentDate: any, selectedDate: any) => {
            return <td {...props}>{ '0' + currentDate.date() }</td>;
        } }
        renderMonth={ (props: any, month: any, year: any, selectedDate: any) => {
            return <td {...props}>{ month }</td>;
        } }
        renderYear={ (props: any, year: any, selectedDate: any) => {
            return <td {...props}>{ year % 100 }</td>;
        } }
    />;
 
/*
 Test time constraints.
 */
 
const TEST_BASIC_TIME_CONSTRAINTS: JSX.Element = <ReactDatetime
        timeConstraints={ {} }
    />;
 
const TEST_TIME_CONSTRAINTS_WITH_ONE: JSX.Element = <ReactDatetime
        timeConstraints={ {
            'hours': {
                'min': 0,
                'max': 23,
                'step': 1
            }
        } }
    />;
 
const TEST_TIME_CONSTRAINTS_WITH_ALL: JSX.Element = <ReactDatetime
        timeConstraints={ {
            'hours': {
                'min': 0,
                'max': 23,
                'step': 1
            },
            'minutes': {
                'min': 0,
                'max': 59,
                'step': 1
            },
            'seconds': {
                'min': 0,
                'max': 59,
                'step': 1,
            },
            'milliseconds': {
                'min': 0,
                'max': 999,
                'step': 1
            }
        } }
    />;