File tree Expand file tree Collapse file tree 2 files changed +51
-5
lines changed
app/code/Magento/Ui/view/base/web/js/grid/columns
dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ define([
27
27
values = values . split ( ',' ) ;
28
28
}
29
29
30
- if ( ! Array . isArray ( values ) ) {
30
+ if ( ! _ . isArray ( values ) ) {
31
31
values = [ values ] ;
32
32
}
33
33
@@ -55,6 +55,10 @@ define([
55
55
flatOptions : function ( options ) {
56
56
var self = this ;
57
57
58
+ if ( ! _ . isArray ( options ) ) {
59
+ options = _ . values ( options ) ;
60
+ }
61
+
58
62
return options . reduce ( function ( opts , option ) {
59
63
if ( _ . isArray ( option . value ) ) {
60
64
opts = opts . concat ( self . flatOptions ( option . value ) ) ;
Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright © Magento, Inc . All rights reserved.
2
+ * Copyright © 2016 Magento . All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
5
5
/*eslint max-nested-callbacks: 0*/
@@ -10,15 +10,57 @@ define([
10
10
'use strict' ;
11
11
12
12
describe ( 'Ui/js/grid/columns/select' , function ( ) {
13
- var select ;
13
+ var fieldName = 'selectField' ,
14
+ opts = [ {
15
+ label : 'a' , value : 1
16
+ } , {
17
+ label : 'b' , value : 2
18
+ } ] ,
19
+ optsAsObject = {
20
+ 1 : {
21
+ label : 'a' , value : 1
22
+ } ,
23
+ 2 : {
24
+ label : 'b' , value : 2
25
+ } ,
26
+ 4 : {
27
+ label : 'c' , value : 3
28
+ }
29
+ } ,
30
+ select ;
14
31
15
32
beforeEach ( function ( ) {
16
- select = new Select ( ) ;
33
+ select = new Select ( {
34
+ index : fieldName
35
+ } ) ;
17
36
} ) ;
18
37
19
38
describe ( 'getLabel method' , function ( ) {
20
39
it ( 'get label while options empty' , function ( ) {
21
- expect ( select . getLabel ( 2 ) ) . toBe ( '' ) ;
40
+ expect ( select . getLabel ( {
41
+ selectField : '2'
42
+ } ) ) . toBe ( '' ) ;
43
+ } ) ;
44
+
45
+ it ( 'get label for existed value' , function ( ) {
46
+ select . options = opts ;
47
+ expect ( select . getLabel ( {
48
+ selectField : '2'
49
+ } ) ) . toBe ( 'b' ) ;
50
+ } ) ;
51
+
52
+ it ( 'get label for existed value in case the options are initialized as an object' , function ( ) {
53
+ select . options = optsAsObject ;
54
+ expect ( select . getLabel ( {
55
+ selectField : '3'
56
+ } ) ) . toBe ( 'c' ) ;
57
+ } ) ;
58
+
59
+ it ( 'get labels for existed values in case the options are initialized as an object' , function ( ) {
60
+ select . options = optsAsObject ;
61
+ expect ( select . getLabel ( {
62
+ selectField : '1,3'
63
+ } ) ) . toBe ( 'a, c' ) ;
22
64
} ) ;
23
65
} ) ;
24
66
} ) ;
You can’t perform that action at this time.
0 commit comments