File tree Expand file tree Collapse file tree 2 files changed +12
-15
lines changed
app/code/Magento/Catalog/view/frontend/web/js/product/list
dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/list Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change 99] , function ( $ ) {
1010 'use strict' ;
1111
12+ var isToolbarInitialized = false ;
13+
1214 /**
1315 * ProductListToolbarForm Widget - this widget is setting cookie and submitting form according to toolbar controls
1416 */
@@ -30,20 +32,19 @@ define([
3032 limitDefault : '9' ,
3133 url : '' ,
3234 formKey : '' ,
33- post : false ,
34- isToolbarInitialized : false
35+ post : false
3536 } ,
3637
3738 /** @inheritdoc */
3839 _create : function ( ) {
39- if ( this . options . isToolbarInitialized ) {
40- return ;
40+ if ( isToolbarInitialized ) {
41+ return false ;
4142 }
4243 this . _bind ( $ ( this . options . modeControl ) , this . options . mode , this . options . modeDefault ) ;
4344 this . _bind ( $ ( this . options . directionControl ) , this . options . direction , this . options . directionDefault ) ;
4445 this . _bind ( $ ( this . options . orderControl ) , this . options . order , this . options . orderDefault ) ;
4546 this . _bind ( $ ( this . options . limitControl ) , this . options . limit , this . options . limitDefault ) ;
46- this . options . isToolbarInitialized = true ;
47+ isToolbarInitialized = true ;
4748 } ,
4849
4950 /** @inheritdoc */
Original file line number Diff line number Diff line change @@ -10,24 +10,20 @@ define([
1010 'use strict' ;
1111
1212 describe ( 'Magento_Catalog/js/product/list/toolbar' , function ( ) {
13- var widget ,
14- wdContainer ;
13+ var widget ;
1514
1615 beforeEach ( function ( ) {
17- wdContainer = $ ( '<div class="toolbar toolbar-products"></div>' ) ;
18- widget = wdContainer . productListToolbarForm ( ) ;
19- } ) ;
20-
21- afterEach ( function ( ) {
22- $ ( wdContainer ) . remove ( ) ;
16+ widget = new productListToolbarForm ( ) ;
2317 } ) ;
2418
2519 it ( 'Widget extends jQuery object' , function ( ) {
26- expect ( $ . fn . productListToolbarForm ) . toBeDefined ( ) ;
20+ expect ( $ . mage . productListToolbarForm ) . toBeDefined ( ) ;
2721 } ) ;
2822
2923 it ( 'Toolbar is initialized' , function ( ) {
30- expect ( wdContainer . productListToolbarForm ( 'option' , 'isToolbarInitialized' ) ) . not . toBe ( false ) ;
24+ spyOn ( widget , '_create' ) ;
25+ widget . _create ( ) ;
26+ expect ( widget . _create ) . toHaveBeenCalled ( ) ;
3127 } ) ;
3228 } ) ;
3329} ) ;
You can’t perform that action at this time.
0 commit comments