1
+ /**
2
+ * Copyright © 2015 Magento. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ define ( [
7
+ 'underscore' ,
8
+ 'Magento_Ui/js/grid/columns/actions'
9
+ ] , function ( _ , Actions ) {
10
+ 'use strict' ;
11
+
12
+ describe ( 'ui/js/grid/columns/actions' , function ( ) {
13
+ var model ,
14
+ action ;
15
+
16
+ beforeEach ( function ( ) {
17
+ model = new Actions ( {
18
+ index : 'actions' ,
19
+ name : 'listing_action' ,
20
+ indexField : 'id' ,
21
+ dataScope : '' ,
22
+ rows : [ {
23
+ identifier : 'row'
24
+ } ]
25
+ } ) ;
26
+ action = {
27
+ index : 'delete' ,
28
+ hidden : true ,
29
+ rowIndex : 0 ,
30
+ callback : function ( ) {
31
+ return true ;
32
+ }
33
+ } ;
34
+ } ) ;
35
+
36
+ it ( 'Check addAction function' , function ( ) {
37
+ expect ( model . addAction ( 'delete' , action ) ) . toBe ( model ) ;
38
+ } ) ;
39
+
40
+ it ( 'Check getAction function' , function ( ) {
41
+ var someAction = _ . clone ( action ) ;
42
+
43
+ someAction . index = 'edit' ;
44
+ model . addAction ( 'edit' , someAction ) ;
45
+ expect ( model . getAction ( 0 , 'edit' ) ) . toEqual ( someAction ) ;
46
+ } ) ;
47
+
48
+ it ( 'Check getVisibleActions function' , function ( ) {
49
+ var someAction = _ . clone ( action ) ;
50
+
51
+ someAction . hidden = false ;
52
+ someAction . index = 'view' ;
53
+ model . addAction ( 'delete' , action ) ;
54
+ model . addAction ( 'view' , someAction ) ;
55
+ expect ( model . getVisibleActions ( '0' ) ) . toEqual ( [ someAction ] ) ;
56
+ } ) ;
57
+
58
+ it ( 'Check updateActions function' , function ( ) {
59
+ expect ( model . updateActions ( ) ) . toEqual ( model ) ;
60
+ } ) ;
61
+
62
+ it ( 'Check applyAction function' , function ( ) {
63
+ model . addAction ( 'delete' , action ) ;
64
+ expect ( model . applyAction ( 'delete' , 0 ) ) . toEqual ( model ) ;
65
+ } ) ;
66
+
67
+ it ( 'Check isSingle and isMultiple function' , function ( ) {
68
+ var someAction = _ . clone ( action ) ;
69
+
70
+ action . hidden = false ;
71
+ model . addAction ( 'delete' , action ) ;
72
+ expect ( model . isSingle ( 0 ) ) . toBeTruthy ( ) ;
73
+ someAction . hidden = false ;
74
+ someAction . index = 'edit' ;
75
+ model . addAction ( 'edit' , someAction ) ;
76
+ expect ( model . isSingle ( 0 ) ) . toBeFalsy ( ) ;
77
+ expect ( model . isMultiple ( 0 ) ) . toBeTruthy ( ) ;
78
+ } ) ;
79
+
80
+ it ( 'Check isActionVisible function' , function ( ) {
81
+ expect ( model . isActionVisible ( action ) ) . toBeFalsy ( ) ;
82
+ action . hidden = false ;
83
+ expect ( model . isActionVisible ( action ) ) . toBeTruthy ( ) ;
84
+ } ) ;
85
+
86
+ it ( 'Check toggleList function' , function ( ) {
87
+ model . toggleList ( 0 ) ;
88
+ expect ( model . opened ( ) ) . toEqual ( 0 ) ;
89
+ model . toggleList ( 0 ) ;
90
+ expect ( model . opened ( ) ) . toBeFalsy ( ) ;
91
+ } ) ;
92
+
93
+ it ( 'Check closeList function' , function ( ) {
94
+ model . toggleList ( 0 ) ;
95
+ expect ( model . opened ( ) ) . toEqual ( 0 ) ;
96
+ model . closeList ( 0 ) ;
97
+ expect ( model . opened ( ) ) . toBeFalsy ( ) ;
98
+ } ) ;
99
+ } ) ;
100
+ } ) ;
0 commit comments