@@ -27,28 +27,15 @@ describe('configToIndex', () => {
27
27
error . mockClear ( ) ;
28
28
} ) ;
29
29
30
- it ( 'errors if element not found' , ( ) => {
31
- const elements = new Map < string , HTMLElement > ( ) ;
32
- const config = { id : 'foo' , indexName : 'bar' , name : 'Foo' , blocks : [ ] } ;
33
- const result = configToIndex ( config , elements ) ;
34
- expect ( result ) . toEqual ( [ ] ) ;
35
- expect ( error ) . toHaveBeenCalledTimes ( 1 ) ;
36
- expect ( error ) . toHaveBeenCalledWith (
37
- '[Algolia Experiences] Element with id foo not found'
38
- ) ;
39
- } ) ;
40
-
41
30
it ( 'returns index with widgets' , ( ) => {
42
- const elements = new Map < string , HTMLElement > ( [
43
- [ 'foo' , document . createElement ( 'div' ) ] ,
44
- ] ) ;
31
+ const element = document . createElement ( 'div' ) ;
45
32
const config : Configuration = {
46
33
id : 'foo' ,
47
34
indexName : 'bar' ,
48
35
name : 'Foo' ,
49
36
blocks : [ { type : 'ais.hits' , parameters : { } , children : [ ] } ] ,
50
37
} ;
51
- const result = configToIndex ( config , elements ) ;
38
+ const result = configToIndex ( config , element ) ;
52
39
expect ( result ) . toHaveLength ( 1 ) ;
53
40
expect ( result [ 0 ] . getIndexName ( ) ) . toEqual ( 'bar' ) ;
54
41
expect ( result [ 0 ] . getIndexId ( ) ) . toEqual ( 'foo' ) ;
@@ -57,9 +44,7 @@ describe('configToIndex', () => {
57
44
} ) ;
58
45
59
46
it ( 'maps to the right widget types' , ( ) => {
60
- const elements = new Map < string , HTMLElement > ( [
61
- [ 'foo' , document . createElement ( 'div' ) ] ,
62
- ] ) ;
47
+ const element = document . createElement ( 'div' ) ;
63
48
const config : Configuration = {
64
49
id : 'foo' ,
65
50
indexName : 'bar' ,
@@ -121,7 +106,7 @@ describe('configToIndex', () => {
121
106
} ,
122
107
] ,
123
108
} ;
124
- const result = configToIndex ( config , elements ) ;
109
+ const result = configToIndex ( config , element ) ;
125
110
expect ( result ) . toHaveLength ( 1 ) ;
126
111
expect ( result [ 0 ] . getWidgets ( ) ) . toHaveLength ( config . blocks . length ) ;
127
112
expect ( result [ 0 ] . getWidgets ( ) . map ( ( w ) => w . $$type ) ) . toEqual ( [
@@ -167,9 +152,7 @@ describe('configToIndex', () => {
167
152
) ,
168
153
} ) ;
169
154
const search = instantsearch ( { searchClient } ) ;
170
- const elements = new Map < string , HTMLElement > ( [
171
- [ 'foo' , document . createElement ( 'div' ) ] ,
172
- ] ) ;
155
+ const element = document . createElement ( 'div' ) ;
173
156
const config : Configuration = {
174
157
id : 'foo' ,
175
158
indexName : 'bar' ,
@@ -210,11 +193,11 @@ describe('configToIndex', () => {
210
193
} ,
211
194
] ,
212
195
} ;
213
- const result = configToIndex ( config , elements ) ;
196
+ const result = configToIndex ( config , element ) ;
214
197
expect ( result ) . toHaveLength ( 1 ) ;
215
198
expect ( result [ 0 ] . getWidgets ( ) ) . toHaveLength ( 1 ) ;
216
199
217
- expect ( elements . get ( 'foo' ) ? .innerHTML ) . toMatchInlineSnapshot ( `
200
+ expect ( element . innerHTML ) . toMatchInlineSnapshot ( `
218
201
<div>
219
202
</div>
220
203
` ) ;
@@ -223,7 +206,7 @@ describe('configToIndex', () => {
223
206
search . start ( ) ;
224
207
await wait ( 100 ) ;
225
208
226
- expect ( elements . get ( 'foo' ) ? .innerHTML ) . toMatchInlineSnapshot ( `
209
+ expect ( element . innerHTML ) . toMatchInlineSnapshot ( `
227
210
<div>
228
211
<div class="ais-Hits">
229
212
<ol class="ais-Hits-list">
@@ -276,9 +259,7 @@ describe('configToIndex', () => {
276
259
) ,
277
260
} ) ;
278
261
const search = instantsearch ( { searchClient } ) ;
279
- const elements = new Map < string , HTMLElement > ( [
280
- [ 'foo' , document . createElement ( 'div' ) ] ,
281
- ] ) ;
262
+ const element = document . createElement ( 'div' ) ;
282
263
283
264
const config : Configuration = {
284
265
id : 'foo' ,
@@ -292,12 +273,12 @@ describe('configToIndex', () => {
292
273
] ,
293
274
} ;
294
275
295
- const result = configToIndex ( config , elements ) ;
276
+ const result = configToIndex ( config , element ) ;
296
277
297
278
expect ( result ) . toHaveLength ( 1 ) ;
298
279
expect ( result [ 0 ] . getWidgets ( ) ) . toHaveLength ( 1 ) ;
299
280
300
- expect ( elements . get ( 'foo' ) ? .innerHTML ) . toMatchInlineSnapshot ( `
281
+ expect ( element . innerHTML ) . toMatchInlineSnapshot ( `
301
282
<div>
302
283
</div>
303
284
` ) ;
@@ -306,7 +287,7 @@ describe('configToIndex', () => {
306
287
search . start ( ) ;
307
288
await wait ( 100 ) ;
308
289
309
- expect ( elements . get ( 'foo' ) ? .innerHTML ) . toMatchInlineSnapshot ( `
290
+ expect ( element . innerHTML ) . toMatchInlineSnapshot ( `
310
291
<div>
311
292
<div class="ais-Panel">
312
293
<div class="ais-Panel-header">
@@ -351,9 +332,7 @@ describe('configToIndex', () => {
351
332
) ,
352
333
} ) ;
353
334
const search = instantsearch ( { searchClient } ) ;
354
- const elements = new Map < string , HTMLElement > ( [
355
- [ 'foo' , document . createElement ( 'div' ) ] ,
356
- ] ) ;
335
+ const element = document . createElement ( 'div' ) ;
357
336
358
337
const config : Configuration = {
359
338
id : 'foo' ,
@@ -367,12 +346,12 @@ describe('configToIndex', () => {
367
346
] ,
368
347
} ;
369
348
370
- const result = configToIndex ( config , elements ) ;
349
+ const result = configToIndex ( config , element ) ;
371
350
372
351
expect ( result ) . toHaveLength ( 1 ) ;
373
352
expect ( result [ 0 ] . getWidgets ( ) ) . toHaveLength ( 1 ) ;
374
353
375
- expect ( elements . get ( 'foo' ) ) . toBeEmptyDOMElement ( ) ;
354
+ expect ( element ) . toBeEmptyDOMElement ( ) ;
376
355
377
356
search . addWidgets ( result ) ;
378
357
search . start ( ) ;
@@ -400,9 +379,7 @@ describe('configToIndex', () => {
400
379
) ,
401
380
} ) ;
402
381
const search = instantsearch ( { searchClient } ) ;
403
- const elements = new Map < string , HTMLElement > ( [
404
- [ 'foo' , document . createElement ( 'div' ) ] ,
405
- ] ) ;
382
+ const element = document . createElement ( 'div' ) ;
406
383
407
384
const config : Configuration = {
408
385
id : 'foo' ,
@@ -416,12 +393,12 @@ describe('configToIndex', () => {
416
393
] ,
417
394
} ;
418
395
419
- const result = configToIndex ( config , elements ) ;
396
+ const result = configToIndex ( config , element ) ;
420
397
421
398
expect ( result ) . toHaveLength ( 1 ) ;
422
399
expect ( result [ 0 ] . getWidgets ( ) ) . toHaveLength ( 1 ) ;
423
400
424
- expect ( elements . get ( 'foo' ) ?. innerHTML ) . toMatchInlineSnapshot ( `
401
+ expect ( element ?. innerHTML ) . toMatchInlineSnapshot ( `
425
402
<div>
426
403
</div>
427
404
` ) ;
@@ -430,7 +407,7 @@ describe('configToIndex', () => {
430
407
search . start ( ) ;
431
408
await wait ( 100 ) ;
432
409
433
- expect ( elements . get ( 'foo' ) ?. innerHTML ) . toMatchInlineSnapshot ( `
410
+ expect ( element ?. innerHTML ) . toMatchInlineSnapshot ( `
434
411
<div>
435
412
<div class="ais-Pagination ais-Pagination--noRefinement">
436
413
<ul class="ais-Pagination-list">
0 commit comments