@@ -20,14 +20,14 @@ describe('search-box()', () => {
20
20
21
21
let ReactDOM ;
22
22
let container ;
23
- let initialState ;
23
+ let state ;
24
24
let helper ;
25
25
let widget ;
26
26
27
27
beforeEach ( ( ) => {
28
28
ReactDOM = { render : sinon . spy ( ) } ;
29
29
searchBox . __Rewire__ ( 'ReactDOM' , ReactDOM ) ;
30
- initialState = {
30
+ state = {
31
31
query : ''
32
32
} ;
33
33
helper = {
@@ -59,13 +59,13 @@ describe('search-box()', () => {
59
59
} ) ;
60
60
61
61
it ( 'adds an input inside the div' , ( ) => {
62
- widget . init ( initialState , helper ) ;
62
+ widget . init ( { state , helper} ) ;
63
63
let inputs = container . getElementsByTagName ( 'input' ) ;
64
64
expect ( inputs . length ) . toEqual ( 1 ) ;
65
65
} ) ;
66
66
67
67
it ( 'sets default HTML attribute to the input' , ( ) => {
68
- widget . init ( initialState , helper ) ;
68
+ widget . init ( { state , helper} ) ;
69
69
let input = container . getElementsByTagName ( 'input' ) [ 0 ] ;
70
70
expect ( input . getAttribute ( 'autocapitalize' ) ) . toEqual ( 'off' ) ;
71
71
expect ( input . getAttribute ( 'autocomplete' ) ) . toEqual ( 'off' ) ;
@@ -82,7 +82,7 @@ describe('search-box()', () => {
82
82
it ( 'reuse the existing input' , ( ) => {
83
83
container = createHTMLNodeFromString ( '<input />' ) ;
84
84
widget = searchBox ( { container} ) ;
85
- widget . init ( initialState , helper ) ;
85
+ widget . init ( { state , helper} ) ;
86
86
expect ( container . tagName ) . toEqual ( 'INPUT' ) ;
87
87
expect ( container . getAttribute ( 'autocapitalize' ) ) . toEqual ( 'off' ) ;
88
88
expect ( container . getAttribute ( 'autocomplete' ) ) . toEqual ( 'off' ) ;
@@ -97,7 +97,7 @@ describe('search-box()', () => {
97
97
it ( 'passes HTML attributes' , ( ) => {
98
98
container = createHTMLNodeFromString ( '<input id="foo" class="my-class" placeholder="Search" />' ) ;
99
99
widget = searchBox ( { container} ) ;
100
- widget . init ( initialState , helper ) ;
100
+ widget . init ( { state , helper} ) ;
101
101
expect ( container . getAttribute ( 'id' ) ) . toEqual ( 'foo' ) ;
102
102
expect ( container . getAttribute ( 'class' ) ) . toEqual ( 'my-class ais-search-box--input' ) ;
103
103
expect ( container . getAttribute ( 'placeholder' ) ) . toEqual ( 'Search' ) ;
@@ -111,7 +111,7 @@ describe('search-box()', () => {
111
111
widget = searchBox ( { container} ) ;
112
112
113
113
// When
114
- widget . init ( initialState , helper ) ;
114
+ widget . init ( { state , helper} ) ;
115
115
116
116
// Then
117
117
let wrapper = container . querySelectorAll ( 'div.ais-search-box' ) [ 0 ] ;
@@ -127,7 +127,7 @@ describe('search-box()', () => {
127
127
widget = searchBox ( { container} ) ;
128
128
129
129
// When
130
- widget . init ( initialState , helper ) ;
130
+ widget . init ( { state , helper} ) ;
131
131
132
132
// Then
133
133
let wrapper = container . parentNode ;
@@ -140,7 +140,7 @@ describe('search-box()', () => {
140
140
widget = searchBox ( { container, wrapInput : false } ) ;
141
141
142
142
// When
143
- widget . init ( initialState , helper ) ;
143
+ widget . init ( { state , helper} ) ;
144
144
145
145
// Then
146
146
let wrapper = container . querySelectorAll ( 'div.ais-search-box' ) ;
@@ -157,13 +157,13 @@ describe('search-box()', () => {
157
157
158
158
it ( 'do not add the poweredBy if not specified' , ( ) => {
159
159
widget = searchBox ( { container} ) ;
160
- widget . init ( initialState , helper ) ;
160
+ widget . init ( { state , helper} ) ;
161
161
expect ( ReactDOM . render . notCalled ) . toBe ( true ) ;
162
162
} ) ;
163
163
164
164
it ( 'add the poweredBy if specified' , ( ) => {
165
165
widget = searchBox ( { container, poweredBy : true } ) ;
166
- widget . init ( initialState , helper ) ;
166
+ widget . init ( { state , helper} ) ;
167
167
expect ( ReactDOM . render . notCalled ) . toBe ( false ) ;
168
168
} ) ;
169
169
} ) ;
@@ -180,7 +180,7 @@ describe('search-box()', () => {
180
180
// Given
181
181
helper . state . query = 'foo' ;
182
182
// When
183
- widget . init ( initialState , helper ) ;
183
+ widget . init ( { state , helper} ) ;
184
184
// Then
185
185
expect ( input . addEventListener . called ) . toEqual ( true ) ;
186
186
expect ( input . addEventListener . args [ 1 ] . length ) . toEqual ( 3 ) ;
@@ -229,7 +229,7 @@ describe('search-box()', () => {
229
229
// Given
230
230
helper . state . query = 'foo' ;
231
231
// When
232
- widget . init ( initialState , helper ) ;
232
+ widget . init ( { state , helper} ) ;
233
233
// Then
234
234
expect ( input . addEventListener . called ) . toEqual ( true ) ;
235
235
expect ( input . addEventListener . args [ 0 ] . length ) . toEqual ( 2 ) ;
@@ -290,7 +290,7 @@ describe('search-box()', () => {
290
290
// Given
291
291
helper . state . query = '' ;
292
292
// When
293
- widget . init ( initialState , helper ) ;
293
+ widget . init ( { state , helper} ) ;
294
294
// Then
295
295
expect ( input . focus . called ) . toEqual ( true ) ;
296
296
} ) ;
@@ -299,7 +299,7 @@ describe('search-box()', () => {
299
299
// Given
300
300
helper . state . query = 'foo' ;
301
301
// When
302
- widget . init ( initialState , helper ) ;
302
+ widget . init ( { state , helper} ) ;
303
303
// Then
304
304
expect ( input . focus . called ) . toEqual ( false ) ;
305
305
} ) ;
@@ -315,7 +315,7 @@ describe('search-box()', () => {
315
315
// Given
316
316
helper . state . query = '' ;
317
317
// When
318
- widget . init ( initialState , helper ) ;
318
+ widget . init ( { state , helper} ) ;
319
319
// Then
320
320
expect ( input . focus . called ) . toEqual ( true ) ;
321
321
} ) ;
@@ -324,7 +324,7 @@ describe('search-box()', () => {
324
324
// Given
325
325
helper . state . query = 'foo' ;
326
326
// When
327
- widget . init ( initialState , helper ) ;
327
+ widget . init ( { state , helper} ) ;
328
328
// Then
329
329
expect ( input . focus . called ) . toEqual ( true ) ;
330
330
} ) ;
@@ -340,7 +340,7 @@ describe('search-box()', () => {
340
340
// Given
341
341
helper . state . query = '' ;
342
342
// When
343
- widget . init ( initialState , helper ) ;
343
+ widget . init ( { state , helper} ) ;
344
344
// Then
345
345
expect ( input . focus . called ) . toEqual ( false ) ;
346
346
} ) ;
@@ -349,7 +349,7 @@ describe('search-box()', () => {
349
349
// Given
350
350
helper . state . query = 'foo' ;
351
351
// When
352
- widget . init ( initialState , helper ) ;
352
+ widget . init ( { state , helper} ) ;
353
353
// Then
354
354
expect ( input . focus . called ) . toEqual ( false ) ;
355
355
} ) ;
0 commit comments