@@ -69,13 +69,13 @@ describe('IgxSplitter', () => {
6969 splitterBarComponent . moveStart . emit ( pane1 ) ;
7070 splitterBarComponent . moving . emit ( - 100 ) ;
7171 fixture . detectChanges ( ) ;
72- expect ( pane1 . size ) . toBe ( pane1_originalSize + 100 + 'px' ) ;
73- expect ( pane2 . size ) . toBe ( pane2_originalSize - 100 + 'px' ) ;
72+ expect ( pane1 . dragSize ) . toBe ( pane1_originalSize + 100 + 'px' ) ;
73+ expect ( pane2 . dragSize ) . toBe ( pane2_originalSize - 100 + 'px' ) ;
7474
7575 splitterBarComponent . moving . emit ( 100 ) ;
7676 fixture . detectChanges ( ) ;
77- expect ( pane1 . size ) . toBe ( pane1_originalSize - 100 + 'px' ) ;
78- expect ( pane2 . size ) . toBe ( pane2_originalSize + 100 + 'px' ) ;
77+ expect ( pane1 . dragSize ) . toBe ( pane1_originalSize - 100 + 'px' ) ;
78+ expect ( pane2 . dragSize ) . toBe ( pane2_originalSize + 100 + 'px' ) ;
7979 } ) ;
8080 it ( 'should allow resizing horizontal splitter' , ( ) => {
8181 const pane1 = splitter . panes . toArray ( ) [ 0 ] ;
@@ -89,13 +89,13 @@ describe('IgxSplitter', () => {
8989 splitterBarComponent . moving . emit ( - 100 ) ;
9090 fixture . detectChanges ( ) ;
9191
92- expect ( parseFloat ( pane1 . size ) ) . toBeCloseTo ( pane1_originalSize + 100 , 0 ) ;
93- expect ( parseFloat ( pane2 . size ) ) . toBeCloseTo ( pane2_originalSize - 100 , 0 ) ;
92+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize + 100 , 0 ) ;
93+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize - 100 , 0 ) ;
9494
9595 splitterBarComponent . moving . emit ( 100 ) ;
9696 fixture . detectChanges ( ) ;
97- expect ( parseFloat ( pane1 . size ) ) . toBeCloseTo ( pane1_originalSize - 100 , 0 ) ;
98- expect ( parseFloat ( pane2 . size ) ) . toBeCloseTo ( pane2_originalSize + 100 , 0 ) ;
97+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize - 100 , 0 ) ;
98+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize + 100 , 0 ) ;
9999 } ) ;
100100 it ( 'should honor minSize/maxSize when resizing.' , ( ) => {
101101 fixture . componentInstance . type = SplitterType . Vertical ;
@@ -112,16 +112,16 @@ describe('IgxSplitter', () => {
112112 splitterBarComponent . moveStart . emit ( pane1 ) ;
113113 splitterBarComponent . moving . emit ( 100 ) ;
114114 fixture . detectChanges ( ) ;
115- expect ( pane1 . size ) . toBe ( '100px' ) ;
116- expect ( pane2 . size ) . toBe ( '300px' ) ;
115+ expect ( pane1 . dragSize ) . toBe ( '100px' ) ;
116+ expect ( pane2 . dragSize ) . toBe ( '300px' ) ;
117117
118118 splitterBarComponent . moveStart . emit ( pane1 ) ;
119119 splitterBarComponent . moving . emit ( - 200 ) ;
120120 splitterBarComponent . moveStart . emit ( pane1 ) ;
121121 splitterBarComponent . moving . emit ( - 50 ) ;
122122 fixture . detectChanges ( ) ;
123- expect ( pane1 . size ) . toBe ( '300px' ) ;
124- expect ( pane2 . size ) . toBe ( '100px' ) ;
123+ expect ( pane1 . dragSize ) . toBe ( '300px' ) ;
124+ expect ( pane2 . dragSize ) . toBe ( '100px' ) ;
125125 } ) ;
126126
127127 it ( 'should not allow drag resize if resizable is set to false.' , ( ) => {
@@ -149,20 +149,20 @@ describe('IgxSplitter', () => {
149149 splitterBarComponent . nativeElement . focus ( ) ;
150150 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowUp' , splitterBarComponent ) ;
151151 fixture . detectChanges ( ) ;
152- expect ( pane1 . size ) . toBe ( pane1_originalSize - 10 + 'px' ) ;
153- expect ( pane2 . size ) . toBe ( pane2_originalSize + 10 + 'px' ) ;
152+ expect ( pane1 . dragSize ) . toBe ( pane1_originalSize - 10 + 'px' ) ;
153+ expect ( pane2 . dragSize ) . toBe ( pane2_originalSize + 10 + 'px' ) ;
154154
155155 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , splitterBarComponent ) ;
156156 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , splitterBarComponent ) ;
157157 fixture . detectChanges ( ) ;
158- expect ( pane1 . size ) . toBe ( pane1_originalSize + 10 + 'px' ) ;
159- expect ( pane2 . size ) . toBe ( pane2_originalSize - 10 + 'px' ) ;
158+ expect ( pane1 . dragSize ) . toBe ( pane1_originalSize + 10 + 'px' ) ;
159+ expect ( pane2 . dragSize ) . toBe ( pane2_originalSize - 10 + 'px' ) ;
160160
161161 pane2 . resizable = false ;
162162 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowDown' , splitterBarComponent ) ;
163163 fixture . detectChanges ( ) ;
164- expect ( pane1 . size ) . toBe ( pane1_originalSize + 10 + 'px' ) ;
165- expect ( pane2 . size ) . toBe ( pane2_originalSize - 10 + 'px' ) ;
164+ expect ( pane1 . dragSize ) . toBe ( pane1_originalSize + 10 + 'px' ) ;
165+ expect ( pane2 . dragSize ) . toBe ( pane2_originalSize - 10 + 'px' ) ;
166166 } ) ;
167167
168168 it ( 'should allow resizing with left/right arrow keys' , ( ) => {
@@ -178,20 +178,20 @@ describe('IgxSplitter', () => {
178178 splitterBarComponent . nativeElement . focus ( ) ;
179179 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowLeft' , splitterBarComponent ) ;
180180 fixture . detectChanges ( ) ;
181- expect ( parseFloat ( pane1 . size ) ) . toBeCloseTo ( pane1_originalSize - 10 , 0 ) ;
182- expect ( parseFloat ( pane2 . size ) ) . toBeCloseTo ( pane2_originalSize + 10 , 0 ) ;
181+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize - 10 , 0 ) ;
182+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize + 10 , 0 ) ;
183183
184184 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowRight' , splitterBarComponent ) ;
185185 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowRight' , splitterBarComponent ) ;
186186 fixture . detectChanges ( ) ;
187- expect ( parseFloat ( pane1 . size ) ) . toBeCloseTo ( pane1_originalSize + 10 , 0 ) ;
188- expect ( parseFloat ( pane2 . size ) ) . toBeCloseTo ( pane2_originalSize - 10 , 0 ) ;
187+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize + 10 , 0 ) ;
188+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize - 10 , 0 ) ;
189189
190190 pane1 . resizable = false ;
191191 UIInteractions . triggerEventHandlerKeyDown ( 'ArrowRight' , splitterBarComponent ) ;
192192 fixture . detectChanges ( ) ;
193- expect ( parseFloat ( pane1 . size ) ) . toBeCloseTo ( pane1_originalSize + 10 , 0 ) ;
194- expect ( parseFloat ( pane2 . size ) ) . toBeCloseTo ( pane2_originalSize - 10 , 0 ) ;
193+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize + 10 , 0 ) ;
194+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize - 10 , 0 ) ;
195195 } ) ;
196196
197197 it ( 'should allow expand/collapse with Ctrl + up/down arrow keys' , ( ) => {
@@ -240,6 +240,60 @@ describe('IgxSplitter', () => {
240240 expect ( pane2 . collapsed ) . toBeFalsy ( ) ;
241241 } ) ;
242242
243+ it ( 'should allow resize in % when pane size is auto.' , ( ) => {
244+ const pane1 = splitter . panes . toArray ( ) [ 0 ] ;
245+ const pane2 = splitter . panes . toArray ( ) [ 1 ] ;
246+ expect ( pane1 . size ) . toBe ( 'auto' ) ;
247+ expect ( pane2 . size ) . toBe ( 'auto' ) ;
248+ const pane1_originalSize = pane1 . element . offsetWidth ;
249+ const pane2_originalSize = pane2 . element . offsetWidth ;
250+ const splitterBarComponent = fixture . debugElement . query ( By . css ( SPLITTERBAR_CLASS ) ) . context ;
251+ splitterBarComponent . moveStart . emit ( pane1 ) ;
252+ splitterBarComponent . moving . emit ( - 100 ) ;
253+ fixture . detectChanges ( ) ;
254+
255+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize + 100 , 0 ) ;
256+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize - 100 , 0 ) ;
257+
258+ // on move end convert to % value and apply to size.
259+ splitterBarComponent . movingEnd . emit ( - 100 ) ;
260+ fixture . detectChanges ( ) ;
261+
262+ expect ( pane1 . size . indexOf ( '%' ) !== - 1 ) . toBeTrue ( ) ;
263+ expect ( pane2 . size . indexOf ( '%' ) !== - 1 ) . toBeTrue ( ) ;
264+
265+ expect ( pane1 . element . offsetWidth ) . toBeCloseTo ( pane1_originalSize + 100 ) ;
266+ expect ( pane2 . element . offsetWidth ) . toBeCloseTo ( pane2_originalSize - 100 ) ;
267+ } ) ;
268+
269+ it ( 'should allow mixing % and px sizes.' , ( ) => {
270+ const pane1 = splitter . panes . toArray ( ) [ 0 ] ;
271+ const pane2 = splitter . panes . toArray ( ) [ 1 ] ;
272+ pane1 . size = '200px' ;
273+ fixture . detectChanges ( ) ;
274+
275+ const pane1_originalSize = pane1 . element . offsetWidth ;
276+ const pane2_originalSize = pane2 . element . offsetWidth ;
277+ const splitterBarComponent = fixture . debugElement . query ( By . css ( SPLITTERBAR_CLASS ) ) . context ;
278+ splitterBarComponent . moveStart . emit ( pane1 ) ;
279+ splitterBarComponent . moving . emit ( - 100 ) ;
280+ fixture . detectChanges ( ) ;
281+
282+ expect ( parseFloat ( pane1 . dragSize ) ) . toBeCloseTo ( pane1_originalSize + 100 , 0 ) ;
283+ expect ( parseFloat ( pane2 . dragSize ) ) . toBeCloseTo ( pane2_originalSize - 100 , 0 ) ;
284+
285+ // on move end convert to % value and apply to size.
286+ splitterBarComponent . movingEnd . emit ( - 100 ) ;
287+ fixture . detectChanges ( ) ;
288+
289+ // fist pane should remain in px
290+ expect ( pane1 . size ) . toBe ( '300px' ) ;
291+ expect ( pane2 . size . indexOf ( '%' ) !== - 1 ) . toBeTrue ( ) ;
292+
293+ expect ( pane1 . element . offsetWidth ) . toBeCloseTo ( pane1_originalSize + 100 ) ;
294+ expect ( pane2 . element . offsetWidth ) . toBeCloseTo ( pane2_originalSize - 100 ) ;
295+ } ) ;
296+
243297} ) ;
244298
245299describe ( 'IgxSplitter pane toggle' , ( ) => {
0 commit comments