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 9
9
] , function ( $ ) {
10
10
'use strict' ;
11
11
12
+ var isToolbarInitialized = false ;
13
+
12
14
/**
13
15
* ProductListToolbarForm Widget - this widget is setting cookie and submitting form according to toolbar controls
14
16
*/
@@ -30,20 +32,19 @@ define([
30
32
limitDefault : '9' ,
31
33
url : '' ,
32
34
formKey : '' ,
33
- post : false ,
34
- isToolbarInitialized : false
35
+ post : false
35
36
} ,
36
37
37
38
/** @inheritdoc */
38
39
_create : function ( ) {
39
- if ( this . options . isToolbarInitialized ) {
40
- return ;
40
+ if ( isToolbarInitialized ) {
41
+ return false ;
41
42
}
42
43
this . _bind ( $ ( this . options . modeControl ) , this . options . mode , this . options . modeDefault ) ;
43
44
this . _bind ( $ ( this . options . directionControl ) , this . options . direction , this . options . directionDefault ) ;
44
45
this . _bind ( $ ( this . options . orderControl ) , this . options . order , this . options . orderDefault ) ;
45
46
this . _bind ( $ ( this . options . limitControl ) , this . options . limit , this . options . limitDefault ) ;
46
- this . options . isToolbarInitialized = true ;
47
+ isToolbarInitialized = true ;
47
48
} ,
48
49
49
50
/** @inheritdoc */
Original file line number Diff line number Diff line change @@ -10,24 +10,20 @@ define([
10
10
'use strict' ;
11
11
12
12
describe ( 'Magento_Catalog/js/product/list/toolbar' , function ( ) {
13
- var widget ,
14
- wdContainer ;
13
+ var widget ;
15
14
16
15
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 ( ) ;
23
17
} ) ;
24
18
25
19
it ( 'Widget extends jQuery object' , function ( ) {
26
- expect ( $ . fn . productListToolbarForm ) . toBeDefined ( ) ;
20
+ expect ( $ . mage . productListToolbarForm ) . toBeDefined ( ) ;
27
21
} ) ;
28
22
29
23
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 ( ) ;
31
27
} ) ;
32
28
} ) ;
33
29
} ) ;
You can’t perform that action at this time.
0 commit comments