@@ -33,20 +33,21 @@ define([
33
33
} ,
34
34
component ,
35
35
dataScope = 'dataScope' ,
36
- originalJQuery = jQuery . fn ;
36
+ originalJQuery = jQuery . fn ,
37
+ params = {
38
+ provider : 'provName' ,
39
+ name : '' ,
40
+ index : '' ,
41
+ dataScope : dataScope
42
+ } ;
37
43
38
44
beforeEach ( function ( done ) {
39
45
injector . mock ( mocks ) ;
40
46
injector . require ( [
41
47
'Magento_Ui/js/form/element/file-uploader' ,
42
48
'knockoutjs/knockout-es5'
43
49
] , function ( Constr ) {
44
- component = new Constr ( {
45
- provider : 'provName' ,
46
- name : '' ,
47
- index : '' ,
48
- dataScope : dataScope
49
- } ) ;
50
+ component = new Constr ( params ) ;
50
51
51
52
done ( ) ;
52
53
} ) ;
@@ -69,6 +70,40 @@ define([
69
70
} ) ;
70
71
} ) ;
71
72
73
+ describe ( 'setInitialValue method' , function ( ) {
74
+
75
+ it ( 'check for chainable' , function ( ) {
76
+ expect ( component . setInitialValue ( ) ) . toEqual ( component ) ;
77
+ } ) ;
78
+ it ( 'check for set value' , function ( ) {
79
+ var initialValue = [
80
+ {
81
+ 'name' : 'test.png' ,
82
+ 'size' : 0 ,
83
+ 'type' : 'image/png' ,
84
+ 'url' : 'http://localhost:8000/media/wysiwyg/test.png'
85
+ }
86
+ ] , expectedValue = [
87
+ {
88
+ 'name' : 'test.png' ,
89
+ 'size' : 2000 ,
90
+ 'type' : 'image/png' ,
91
+ 'url' : 'http://localhost:8000/media/wysiwyg/test.png'
92
+ }
93
+ ] ;
94
+
95
+ spyOn ( component , 'setImageSize' ) . and . callFake ( function ( ) {
96
+ component . value ( ) . size = 2000 ;
97
+ } ) ;
98
+ spyOn ( component , 'getInitialValue' ) . and . returnValue ( initialValue ) ;
99
+ component . service = true ;
100
+ expect ( component . setInitialValue ( ) ) . toEqual ( component ) ;
101
+ expect ( component . getInitialValue ) . toHaveBeenCalled ( ) ;
102
+ component . setImageSize ( initialValue ) ;
103
+ expect ( component . value ( ) . size ) . toEqual ( expectedValue [ 0 ] . size ) ;
104
+ } ) ;
105
+ } ) ;
106
+
72
107
describe ( 'isFileAllowed method' , function ( ) {
73
108
var invalidFile ,
74
109
validFile ;
0 commit comments