File tree Expand file tree Collapse file tree 2 files changed +23
-6
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 +23
-6
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ define([
38
38
/** @inheritdoc */
39
39
_create : function ( ) {
40
40
if ( isToolbarInitialized ) {
41
- return false ;
41
+ return ;
42
42
}
43
43
this . _bind ( $ ( this . options . modeControl ) , this . options . mode , this . options . modeDefault ) ;
44
44
this . _bind ( $ ( this . options . directionControl ) , this . options . direction , this . options . directionDefault ) ;
Original file line number Diff line number Diff line change @@ -10,20 +10,37 @@ define([
10
10
'use strict' ;
11
11
12
12
describe ( 'Magento_Catalog/js/product/list/toolbar' , function ( ) {
13
- var widget ;
13
+ var toolbar ;
14
14
15
15
beforeEach ( function ( ) {
16
- widget = new productListToolbarForm ( ) ;
16
+ toolbar = $ ( '<div class="toolbar"></div>' ) ;
17
+ } ) ;
18
+
19
+ afterEach ( function ( ) {
20
+ toolbar . remove ( ) ;
17
21
} ) ;
18
22
19
23
it ( 'Widget extends jQuery object' , function ( ) {
20
24
expect ( $ . mage . productListToolbarForm ) . toBeDefined ( ) ;
21
25
} ) ;
22
26
23
27
it ( 'Toolbar is initialized' , function ( ) {
24
- spyOn ( widget , '_create' ) ;
25
- widget . _create ( ) ;
26
- expect ( widget . _create ) . toHaveBeenCalled ( ) ;
28
+ spyOn ( $ . mage . productListToolbarForm . prototype , '_create' ) ;
29
+
30
+ toolbar . productListToolbarForm ( ) ;
31
+
32
+ expect ( $ . mage . productListToolbarForm . prototype . _create ) . toEqual ( jasmine . any ( Function ) ) ;
33
+ expect ( $ . mage . productListToolbarForm . prototype . _create ) . toHaveBeenCalledTimes ( 1 ) ;
34
+ } ) ;
35
+
36
+ it ( 'Toolbar is initialized once' , function ( ) {
37
+ spyOn ( $ . mage . productListToolbarForm . prototype , '_bind' ) ;
38
+
39
+ toolbar . productListToolbarForm ( ) ;
40
+ var secondToolbar = $ ( '<div class="toolbar"></div>' ) ;
41
+ secondToolbar . productListToolbarForm ( ) ;
42
+
43
+ expect ( $ . mage . productListToolbarForm . prototype . _bind ) . toHaveBeenCalledTimes ( 4 ) ;
27
44
} ) ;
28
45
} ) ;
29
46
} ) ;
You can’t perform that action at this time.
0 commit comments