4
4
*/
5
5
6
6
/* eslint-disable max-nested-callbacks */
7
+ /*jscs:disable jsDoc*/
7
8
define ( [ 'Magento_Customer/js/form/components/insert-listing' ] , function ( Constr ) {
8
9
'use strict' ;
9
10
@@ -15,10 +16,18 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
15
16
data : {
16
17
selected : ids
17
18
}
19
+ } ,
20
+ selectionsProvider = {
21
+ selected : jasmine . createSpy ( ) . and . returnValue ( ids )
18
22
} ;
19
23
20
24
beforeEach ( function ( ) {
21
- obj = new Constr ( { } ) ;
25
+ obj = new Constr ( {
26
+ name : 'content_name' ,
27
+ selections : function ( ) {
28
+ return selectionsProvider ;
29
+ }
30
+ } ) ;
22
31
} ) ;
23
32
24
33
describe ( 'Check delete massaction process' , function ( ) {
@@ -34,20 +43,14 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
34
43
} ) ;
35
44
36
45
it ( 'Check ids are retrieved from selections provider if they are NOT in data' , function ( ) {
37
- var selectionsProvider = {
38
- selected : jasmine . createSpy ( ) . and . returnValue ( ids )
39
- } ;
40
-
41
- obj . selections = function ( ) { // jscs:ignore jsDoc
42
- return selectionsProvider ;
43
- } ;
44
46
obj . _delete = jasmine . createSpy ( ) ;
45
47
obj . onMassAction ( {
46
48
action : 'delete' ,
47
49
data : { }
48
50
} ) ;
49
51
50
52
expect ( selectionsProvider . selected ) . toHaveBeenCalled ( ) ;
53
+ selectionsProvider . selected . calls . reset ( ) ;
51
54
expect ( obj . _delete ) . toHaveBeenCalledWith ( [ 1 , 2 ] ) ;
52
55
} ) ;
53
56
@@ -58,6 +61,7 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
58
61
} ;
59
62
obj . onMassAction ( data ) ;
60
63
64
+ expect ( selectionsProvider . selected ) . not . toHaveBeenCalled ( ) ;
61
65
expect ( obj . source . get . calls . count ( ) ) . toEqual ( 2 ) ;
62
66
expect ( obj . source . set . calls . count ( ) ) . toEqual ( 1 ) ;
63
67
} ) ;
0 commit comments