@@ -33,20 +33,21 @@ define([
3333 } ,
3434 component ,
3535 dataScope = 'dataScope' ,
36- originalJQuery = jQuery . fn ;
36+ originalJQuery = jQuery . fn ,
37+ params = {
38+ provider : 'provName' ,
39+ name : '' ,
40+ index : '' ,
41+ dataScope : dataScope
42+ } ;
3743
3844 beforeEach ( function ( done ) {
3945 injector . mock ( mocks ) ;
4046 injector . require ( [
4147 'Magento_Ui/js/form/element/file-uploader' ,
4248 'knockoutjs/knockout-es5'
4349 ] , function ( Constr ) {
44- component = new Constr ( {
45- provider : 'provName' ,
46- name : '' ,
47- index : '' ,
48- dataScope : dataScope
49- } ) ;
50+ component = new Constr ( params ) ;
5051
5152 done ( ) ;
5253 } ) ;
@@ -69,6 +70,40 @@ define([
6970 } ) ;
7071 } ) ;
7172
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+
72107 describe ( 'isFileAllowed method' , function ( ) {
73108 var invalidFile ,
74109 validFile ;
0 commit comments