1
+ import React from "react" ;
2
+ import TestUtils from "react-addons-test-utils" ;
3
+
1
4
jest . dontMock ( "moment" ) ;
2
- import React from "react/addons" ;
3
5
jest . dontMock ( "../DateTimeField.js" ) ;
4
- const { TestUtils } = React . addons ;
5
6
6
7
describe ( "DateTimeField" , function ( ) {
7
8
const moment = require ( "moment" ) ;
@@ -15,7 +16,7 @@ describe("DateTimeField", function() {
15
16
it ( "shows the right date for a given dateTime and inputFormat" , function ( ) {
16
17
const component = TestUtils . renderIntoDocument ( < DateTimeField dateTime = { happyDate . format ( "x" ) } /> ) ;
17
18
const input = TestUtils . findRenderedDOMComponentWithTag ( component , "input" ) ;
18
- expect ( input . getDOMNode ( ) . value ) . toBe ( "06/05/90 7:30 AM" ) ;
19
+ expect ( input . value ) . toBe ( "06/05/90 7:30 AM" ) ;
19
20
} ) ;
20
21
21
22
} ) ;
@@ -41,25 +42,25 @@ describe("DateTimeField", function() {
41
42
it ( "changes the displayed date when dateTime changes" , function ( ) {
42
43
const Parent = createParent ( ) ;
43
44
const input = TestUtils . findRenderedDOMComponentWithTag ( Parent , "input" ) ;
44
- expect ( input . getDOMNode ( ) . value ) . toBe ( "06/05/90 7:30 AM" ) ;
45
+ expect ( input . value ) . toBe ( "06/05/90 7:30 AM" ) ;
45
46
Parent . setState ( { dateTime : moment ( "1981-06-04 05:45" ) . format ( "x" ) } ) ;
46
- expect ( input . getDOMNode ( ) . value ) . toBe ( "06/04/81 5:45 AM" ) ;
47
+ expect ( input . value ) . toBe ( "06/04/81 5:45 AM" ) ;
47
48
} ) ;
48
49
49
50
it ( "changes the displayed format when inputFormat changes" , function ( ) {
50
51
const Parent = createParent ( ) ;
51
52
const input = TestUtils . findRenderedDOMComponentWithTag ( Parent , "input" ) ;
52
- expect ( input . getDOMNode ( ) . value ) . toBe ( "06/05/90 7:30 AM" ) ;
53
+ expect ( input . value ) . toBe ( "06/05/90 7:30 AM" ) ;
53
54
Parent . setState ( { inputFormat : "x" } ) ;
54
- expect ( input . getDOMNode ( ) . value ) . toBe ( happyDate . format ( "x" ) ) ;
55
+ expect ( input . value ) . toBe ( happyDate . format ( "x" ) ) ;
55
56
} ) ;
56
57
57
58
it ( "doesn't change the defaultText if dateTime didn't change" , function ( ) {
58
59
const Parent = createParent ( { defaultText : "Pick a date" } ) ;
59
60
const input = TestUtils . findRenderedDOMComponentWithTag ( Parent , "input" ) ;
60
- expect ( input . getDOMNode ( ) . value ) . toBe ( "Pick a date" ) ;
61
+ expect ( input . value ) . toBe ( "Pick a date" ) ;
61
62
Parent . setState ( { } ) ;
62
- expect ( input . getDOMNode ( ) . value ) . toBe ( "Pick a date" ) ;
63
+ expect ( input . value ) . toBe ( "Pick a date" ) ;
63
64
} ) ;
64
65
65
66
0 commit comments