@@ -433,35 +433,78 @@ Object {
433
433
) ;
434
434
} ) ;
435
435
436
- it ( 'has a fake createURL' , ( ) => {
437
- const app = new Vue ( {
438
- mixins : [
439
- createServerRootMixin ( {
440
- searchClient : createFakeClient ( ) ,
441
- indexName : 'lol' ,
442
- } ) ,
443
- ] ,
444
- } ) ;
436
+ describe ( 'createURL' , ( ) => {
437
+ it ( 'returns # if instantsearch has no routing' , ( ) => {
438
+ const app = new Vue ( {
439
+ mixins : [
440
+ createServerRootMixin ( {
441
+ searchClient : createFakeClient ( ) ,
442
+ indexName : 'lol' ,
443
+ } ) ,
444
+ ] ,
445
+ } ) ;
445
446
446
- const widget = {
447
- init : jest . fn ( ) ,
448
- render : jest . fn ( ) ,
449
- } ;
447
+ const widget = {
448
+ init : jest . fn ( ) ,
449
+ render : jest . fn ( ) ,
450
+ } ;
450
451
451
- const instantSearchInstance = app . $data . instantsearch ;
452
+ const instantSearchInstance = app . $data . instantsearch ;
452
453
453
- instantSearchInstance . hydrate ( {
454
- lol : createSerializedState ( ) ,
454
+ instantSearchInstance . hydrate ( {
455
+ lol : createSerializedState ( ) ,
456
+ } ) ;
457
+
458
+ instantSearchInstance . __forceRender (
459
+ widget ,
460
+ instantSearchInstance . mainIndex
461
+ ) ;
462
+
463
+ const renderArgs = widget . render . mock . calls [ 0 ] [ 0 ] ;
464
+
465
+ expect ( renderArgs . createURL ( ) ) . toBe ( '#' ) ;
455
466
} ) ;
456
467
457
- instantSearchInstance . __forceRender (
458
- widget ,
459
- instantSearchInstance . mainIndex
460
- ) ;
468
+ it ( 'allows for widgets without getWidgetState' , ( ) => {
469
+ const app = new Vue ( {
470
+ mixins : [
471
+ createServerRootMixin ( {
472
+ searchClient : createFakeClient ( ) ,
473
+ indexName : 'lol' ,
474
+ } ) ,
475
+ ] ,
476
+ } ) ;
477
+
478
+ const widget = {
479
+ init : jest . fn ( ) ,
480
+ render : jest . fn ( ) ,
481
+ getWidgetState ( uiState ) {
482
+ return uiState ;
483
+ } ,
484
+ } ;
461
485
462
- const renderArgs = widget . render . mock . calls [ 0 ] [ 0 ] ;
486
+ const widgetWithoutGetWidgetState = {
487
+ init : jest . fn ( ) ,
488
+ render : jest . fn ( ) ,
489
+ } ;
490
+
491
+ const instantSearchInstance = app . $data . instantsearch ;
492
+
493
+ instantSearchInstance . hydrate ( {
494
+ lol : createSerializedState ( ) ,
495
+ } ) ;
463
496
464
- expect ( renderArgs . createURL ( ) ) . toBe ( '#' ) ;
497
+ instantSearchInstance . addWidgets ( [ widget , widgetWithoutGetWidgetState ] ) ;
498
+
499
+ instantSearchInstance . __forceRender (
500
+ widget ,
501
+ instantSearchInstance . mainIndex
502
+ ) ;
503
+
504
+ const renderArgs = widget . render . mock . calls [ 0 ] [ 0 ] ;
505
+
506
+ expect ( renderArgs . createURL ( ) ) . toBe ( '#' ) ;
507
+ } ) ;
465
508
} ) ;
466
509
} ) ;
467
510
} ) ;
0 commit comments