@@ -38,10 +38,10 @@ describe('<NumberField />', () => {
38
38
it ( 'should not call onChange on blur, when clicked element is one of the spin buttons' , ( ) => {
39
39
const handleChange = jest . fn ( ) ;
40
40
41
- const { getByTestId } = renderWithTheme (
41
+ const { getByTestId, container } = renderWithTheme (
42
42
< NumberField onChange = { handleChange } value = { 0 } />
43
43
) ;
44
- const input = getByTestId ( 'input' ) ;
44
+ const input = container . querySelector ( 'input' ) ;
45
45
const incrementButton = getByTestId ( 'increment' ) ;
46
46
47
47
input . focus ( ) ;
@@ -53,21 +53,21 @@ describe('<NumberField />', () => {
53
53
} ) ;
54
54
55
55
it ( 'should reach max value' , ( ) => {
56
- const { getByTestId } = renderWithTheme (
56
+ const { getByTestId, container } = renderWithTheme (
57
57
< NumberField defaultValue = { 90 } min = { 0 } max = { 100 } step = { 10 } />
58
58
) ;
59
- const input = getByTestId ( 'input' ) ;
59
+ const input = container . querySelector ( 'input' ) ;
60
60
const incrementButton = getByTestId ( 'increment' ) ;
61
61
incrementButton . click ( ) ;
62
62
63
63
expect ( input . value ) . toBe ( '100' ) ;
64
64
} ) ;
65
65
66
66
it ( 'should reach min value' , ( ) => {
67
- const { getByTestId } = renderWithTheme (
67
+ const { getByTestId, container } = renderWithTheme (
68
68
< NumberField defaultValue = { 10 } min = { 0 } max = { 100 } step = { 10 } />
69
69
) ;
70
- const input = getByTestId ( 'input' ) ;
70
+ const input = container . querySelector ( 'input' ) ;
71
71
const decrementButton = getByTestId ( 'decrement' ) ;
72
72
decrementButton . click ( ) ;
73
73
@@ -76,30 +76,32 @@ describe('<NumberField />', () => {
76
76
77
77
describe ( 'prop: step' , ( ) => {
78
78
it ( 'should be 1 by default' , ( ) => {
79
- const { getByTestId } = renderWithTheme ( < NumberField defaultValue = { 0 } /> ) ;
80
- const input = getByTestId ( 'input' ) ;
79
+ const { getByTestId, container } = renderWithTheme (
80
+ < NumberField defaultValue = { 0 } />
81
+ ) ;
82
+ const input = container . querySelector ( 'input' ) ;
81
83
const incrementButton = getByTestId ( 'increment' ) ;
82
84
incrementButton . click ( ) ;
83
85
84
86
expect ( input . value ) . toBe ( '1' ) ;
85
87
} ) ;
86
88
87
89
it ( 'should change value by specified step' , ( ) => {
88
- const { getByTestId } = renderWithTheme (
90
+ const { getByTestId, container } = renderWithTheme (
89
91
< NumberField defaultValue = { 10 } step = { 3 } />
90
92
) ;
91
- const input = getByTestId ( 'input' ) ;
93
+ const input = container . querySelector ( 'input' ) ;
92
94
const decrementButton = getByTestId ( 'decrement' ) ;
93
95
decrementButton . click ( ) ;
94
96
95
97
expect ( input . value ) . toBe ( '7' ) ;
96
98
} ) ;
97
99
98
100
it ( 'should handle decimal step' , ( ) => {
99
- const { getByTestId } = renderWithTheme (
101
+ const { getByTestId, container } = renderWithTheme (
100
102
< NumberField defaultValue = { 10 } step = { 0.3 } />
101
103
) ;
102
- const input = getByTestId ( 'input' ) ;
104
+ const input = container . querySelector ( 'input' ) ;
103
105
const decrementButton = getByTestId ( 'decrement' ) ;
104
106
decrementButton . click ( ) ;
105
107
@@ -109,10 +111,10 @@ describe('<NumberField />', () => {
109
111
110
112
describe ( 'prop: disabled' , ( ) => {
111
113
it ( 'should render disabled' , ( ) => {
112
- const { getByTestId } = renderWithTheme (
114
+ const { getByTestId, container } = renderWithTheme (
113
115
< NumberField defaultValue = { 10 } disabled />
114
116
) ;
115
- const input = getByTestId ( 'input' ) ;
117
+ const input = container . querySelector ( 'input' ) ;
116
118
const incrementButton = getByTestId ( 'increment' ) ;
117
119
const decrementButton = getByTestId ( 'decrement' ) ;
118
120
@@ -122,10 +124,10 @@ describe('<NumberField />', () => {
122
124
} ) ;
123
125
124
126
it ( 'should not react to button clicks' , ( ) => {
125
- const { getByTestId } = renderWithTheme (
127
+ const { getByTestId, container } = renderWithTheme (
126
128
< NumberField defaultValue = { 10 } disabled />
127
129
) ;
128
- const input = getByTestId ( 'input' ) ;
130
+ const input = container . querySelector ( 'input' ) ;
129
131
const incrementButton = getByTestId ( 'increment' ) ;
130
132
const decrementButton = getByTestId ( 'decrement' ) ;
131
133
0 commit comments