File tree Expand file tree Collapse file tree 2 files changed +39
-1
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 +39
-1
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,20 @@ define([
30
30
limitDefault : '9' ,
31
31
url : '' ,
32
32
formKey : '' ,
33
- post : false
33
+ post : false ,
34
+ isToolbarInitialized : false
34
35
} ,
35
36
36
37
/** @inheritdoc */
37
38
_create : function ( ) {
39
+ if ( this . options . isToolbarInitialized ) {
40
+ return ;
41
+ }
38
42
this . _bind ( $ ( this . options . modeControl ) , this . options . mode , this . options . modeDefault ) ;
39
43
this . _bind ( $ ( this . options . directionControl ) , this . options . direction , this . options . directionDefault ) ;
40
44
this . _bind ( $ ( this . options . orderControl ) , this . options . order , this . options . orderDefault ) ;
41
45
this . _bind ( $ ( this . options . limitControl ) , this . options . limit , this . options . limitDefault ) ;
46
+ this . options . isToolbarInitialized = true ;
42
47
} ,
43
48
44
49
/** @inheritdoc */
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ define ( [
7
+ 'jquery' ,
8
+ 'Magento_Catalog/js/product/list/toolbar'
9
+ ] , function ( $ , productListToolbarForm ) {
10
+ 'use strict' ;
11
+
12
+ describe ( 'Magento_Catalog/js/product/list/toolbar' , function ( ) {
13
+ var widget ,
14
+ wdContainer ;
15
+
16
+ beforeEach ( function ( ) {
17
+ wdContainer = $ ( '<div class="toolbar toolbar-products"></div>' ) ;
18
+ widget = wdContainer . productListToolbarForm ( ) ;
19
+ } ) ;
20
+
21
+ afterEach ( function ( ) {
22
+ $ ( wdContainer ) . remove ( ) ;
23
+ } ) ;
24
+
25
+ it ( 'Widget extends jQuery object' , function ( ) {
26
+ expect ( $ . fn . productListToolbarForm ) . toBeDefined ( ) ;
27
+ } ) ;
28
+
29
+ it ( 'Toolbar is initialized' , function ( ) {
30
+ expect ( wdContainer . productListToolbarForm ( 'option' , 'isToolbarInitialized' ) ) . not . toBe ( false ) ;
31
+ } ) ;
32
+ } ) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments