@@ -49,16 +49,36 @@ describe("<Minutes />", () => {
49
49
} ) ;
50
50
} ) ;
51
51
52
- it ( "should update when the user types a valid value" , ( ) => {
53
- let { getByRole } = ReactTestingLibrary . render (
54
- < MinutesWithState defaultValue = { 5 } />
55
- ) ;
56
- let input = getByRole ( "textbox" ) ;
52
+ describe ( "when typing a valid value into the input" , ( ) => {
53
+ it ( "should update the input" , ( ) => {
54
+ let { getByRole } = ReactTestingLibrary . render (
55
+ < MinutesWithState defaultValue = { 5 } />
56
+ ) ;
57
+ let input = getByRole ( "textbox" ) ;
57
58
58
- userEvent . type ( input , "{backspace}" ) ;
59
- userEvent . type ( input , "10" ) ;
59
+ userEvent . type ( input , "{backspace}" ) ;
60
+ userEvent . type ( input , "10" ) ;
60
61
61
- expect ( input . value ) . toBe ( String ( 10 ) ) ;
62
+ expect ( input . value ) . toBe ( String ( 10 ) ) ;
63
+ } ) ;
64
+ } ) ;
65
+
66
+ describe ( "when typing an invalid value into the input" , ( ) => {
67
+ it ( "should NOT update the input" , ( ) => {
68
+ let { getByRole } = ReactTestingLibrary . render (
69
+ < MinutesWithState defaultValue = { 5 } />
70
+ ) ;
71
+ let input = getByRole ( "textbox" ) ;
72
+
73
+ userEvent . type ( input , "{backspace}" ) ;
74
+ userEvent . type ( input , "poop" ) ;
75
+
76
+ expect ( input . value ) . toBe ( String ( 0 ) ) ;
77
+
78
+ userEvent . type ( input , "poop5 oopps" ) ;
79
+
80
+ expect ( input . value ) . toBe ( String ( 5 ) ) ;
81
+ } ) ;
62
82
} ) ;
63
83
} ) ;
64
84
} ) ;
0 commit comments