@@ -267,7 +267,6 @@ describe('Splitter', () => {
267267 expect ( style . maxWidth ) . to . equal ( '100%' ) ;
268268 } ) ;
269269
270- // TODO: verify the attribute type, default value, reflection
271270 it ( 'should properly set default min/max values when not specified' , async ( ) => {
272271 await elementUpdated ( splitter ) ;
273272
@@ -1116,6 +1115,101 @@ describe('Splitter', () => {
11161115 expect ( sizesAfterSecondResize . endSize ) . to . equal ( totalAvailable - 100 ) ;
11171116 } ;
11181117
1118+ const testConstraintsPxAndAutoSizes = async (
1119+ orientation : SplitterOrientation
1120+ ) => {
1121+ const startMaxSize = 400 ;
1122+ const startMinSize = 100 ;
1123+ const endMaxSize = 350 ;
1124+ const endMinSize = 150 ;
1125+ const constraintSplitter = await fixture < IgcSplitterComponent > (
1126+ createTwoPanesWithSizesAndConstraints ( {
1127+ orientation,
1128+ endSize : '200px' ,
1129+ startMinSize : `${ startMinSize } px` ,
1130+ startMaxSize : `${ startMaxSize } px` ,
1131+ endMinSize : `${ endMinSize } px` ,
1132+ endMaxSize : `${ endMaxSize } px` ,
1133+ } )
1134+ ) ;
1135+ await elementUpdated ( constraintSplitter ) ;
1136+
1137+ const isX = orientation === 'horizontal' ;
1138+
1139+ const totalAvailable = getTotalSize (
1140+ constraintSplitter ,
1141+ isX ? 'width' : 'height'
1142+ ) ;
1143+
1144+ const initialSizes = getPanesSizes (
1145+ constraintSplitter ,
1146+ isX ? 'width' : 'height'
1147+ ) ;
1148+ const initialCombinedSize = initialSizes . startSize + initialSizes . endSize ;
1149+
1150+ // Try to grow start pane to max, but end pane has min (150px)
1151+ // Result: Start pane can only grow as much as end pane allows
1152+ const delta = 1000 ;
1153+ await resize ( constraintSplitter , isX ? delta : 0 , isX ? 0 : delta ) ;
1154+
1155+ const sizes = getPanesSizes ( constraintSplitter , isX ? 'width' : 'height' ) ;
1156+
1157+ // Start pane can only grow until end pane hits its minSize
1158+ expect ( sizes . startSize ) . to . equal ( totalAvailable - endMinSize ) ;
1159+ expect ( sizes . endSize ) . to . equal ( endMinSize ) ;
1160+
1161+ expect ( sizes . startSize + sizes . endSize ) . to . equal ( initialCombinedSize ) ;
1162+ expect ( sizes . startSize + sizes . endSize ) . to . be . at . most ( totalAvailable ) ;
1163+ } ;
1164+
1165+ const testConstraintsPercentAndAutoSizes = async (
1166+ orientation : SplitterOrientation
1167+ ) => {
1168+ const constraintSplitter = await fixture < IgcSplitterComponent > (
1169+ createTwoPanesWithSizesAndConstraints ( {
1170+ orientation,
1171+ endSize : '40%' ,
1172+ startMinSize : '20%' ,
1173+ startMaxSize : '80%' ,
1174+ endMinSize : '30%' ,
1175+ endMaxSize : '70%' ,
1176+ } )
1177+ ) ;
1178+ await elementUpdated ( constraintSplitter ) ;
1179+
1180+ const isX = orientation === 'horizontal' ;
1181+ const totalAvailable = getTotalSize (
1182+ constraintSplitter ,
1183+ isX ? 'width' : 'height'
1184+ ) ;
1185+
1186+ const initialSizes = getPanesSizes (
1187+ constraintSplitter ,
1188+ isX ? 'width' : 'height'
1189+ ) ;
1190+ const initialCombinedSize = initialSizes . startSize + initialSizes . endSize ;
1191+
1192+ // Try to grow start pane to max (80%), but end pane has min (30%)
1193+ // Result: Start pane can only grow as much as end pane allows
1194+ const delta = 1000 ;
1195+ await resize ( constraintSplitter , isX ? delta : 0 , isX ? 0 : delta ) ;
1196+
1197+ const sizes = getPanesSizes ( constraintSplitter , isX ? 'width' : 'height' ) ;
1198+
1199+ // Start pane can only grow until end pane hits its minSize (30% of total)
1200+ const expectedEndMin = Math . round ( ( totalAvailable * 30 ) / 100 ) ;
1201+ const expectedStartAfterResize = totalAvailable - expectedEndMin ;
1202+
1203+ expect ( sizes . startSize ) . to . be . closeTo ( expectedStartAfterResize , 2 ) ;
1204+ expect ( sizes . endSize ) . to . be . closeTo ( expectedEndMin , 2 ) ;
1205+
1206+ expect ( sizes . startSize + sizes . endSize ) . to . be . closeTo (
1207+ initialCombinedSize ,
1208+ 2
1209+ ) ;
1210+ expect ( sizes . startSize + sizes . endSize ) . to . be . at . most ( totalAvailable ) ;
1211+ } ;
1212+
11191213 describe ( 'Horizontal orientation' , ( ) => {
11201214 it ( 'should honor minSize and maxSize constraints when resizing, constraints in px' , async ( ) => {
11211215 await testMinMaxConstraintsPx ( 'horizontal' ) ;
@@ -1138,11 +1232,11 @@ describe('Splitter', () => {
11381232 } ) ;
11391233
11401234 it ( 'should handle resize with mixed % and auto size' , async ( ) => {
1141- // TODO
1235+ await testConstraintsPercentAndAutoSizes ( 'horizontal' ) ;
11421236 } ) ;
11431237
11441238 it ( 'should handle mixed px and auto size' , async ( ) => {
1145- // TODO
1239+ await testConstraintsPxAndAutoSizes ( 'horizontal' ) ;
11461240 } ) ;
11471241 } ) ;
11481242
@@ -1168,11 +1262,11 @@ describe('Splitter', () => {
11681262 } ) ;
11691263
11701264 it ( 'should handle resize with mixed % and auto size - vertical' , async ( ) => {
1171- // TODO
1265+ await testConstraintsPercentAndAutoSizes ( 'vertical' ) ;
11721266 } ) ;
11731267
11741268 it ( 'should handle resize with mixed px and auto size - vertical' , async ( ) => {
1175- // TODO
1269+ await testConstraintsPxAndAutoSizes ( 'vertical' ) ;
11761270 } ) ;
11771271 } ) ;
11781272
@@ -1285,16 +1379,83 @@ describe('Splitter', () => {
12851379 } ) ;
12861380 } ) ;
12871381
1288- describe ( 'Behavior on window resize' , ( ) => {
1289- it ( 'should maintain panes sizes in px on window resize' , async ( ) => {
1290- //TODO
1382+ describe ( 'Behavior on splitter resize' , ( ) => {
1383+ it ( 'should maintain panes sizes in px on splitter resize' , async ( ) => {
1384+ const splitter = await fixture < IgcSplitterComponent > (
1385+ createTwoPanesWithSizesAndConstraints ( {
1386+ startSize : '200px' ,
1387+ endSize : '200px' ,
1388+ splitterWidth : '600px' ,
1389+ } )
1390+ ) ;
1391+ await elementUpdated ( splitter ) ;
1392+
1393+ splitter . style . width = '800px' ;
1394+ await elementUpdated ( splitter ) ;
1395+
1396+ const newSizes = getPanesSizes ( splitter , 'width' ) ;
1397+
1398+ expect ( newSizes . startSize ) . to . equal ( 200 ) ;
1399+ expect ( newSizes . endSize ) . to . equal ( 200 ) ;
1400+ } ) ;
1401+
1402+ it ( 'should handle panes sizes in % on window resize' , async ( ) => {
1403+ const splitter = await fixture < IgcSplitterComponent > (
1404+ createTwoPanesWithSizesAndConstraints ( {
1405+ startSize : '20%' ,
1406+ endSize : '20%' ,
1407+ splitterWidth : '1000px' ,
1408+ } )
1409+ ) ;
1410+ await elementUpdated ( splitter ) ;
1411+
1412+ splitter . style . width = '800px' ;
1413+ await elementUpdated ( splitter ) ;
1414+
1415+ const newSizes = getPanesSizes ( splitter , 'width' ) ;
1416+
1417+ expect ( newSizes . startSize ) . to . equal ( 0.2 * 800 ) ;
1418+ expect ( newSizes . endSize ) . to . equal ( 0.2 * 800 ) ;
12911419 } ) ;
12921420
1293- it ( 'should maintain panes sizes in % on window resize' , async ( ) => {
1294- //TODO
1421+ it ( 'should handle panes sizes with mixed px and % on window resize' , async ( ) => {
1422+ const splitter = await fixture < IgcSplitterComponent > (
1423+ createTwoPanesWithSizesAndConstraints ( {
1424+ startSize : '200px' ,
1425+ endSize : '20%' ,
1426+ splitterWidth : '1000px' ,
1427+ } )
1428+ ) ;
1429+ await elementUpdated ( splitter ) ;
1430+
1431+ splitter . style . width = '800px' ;
1432+ await elementUpdated ( splitter ) ;
1433+
1434+ const newSizes = getPanesSizes ( splitter , 'width' ) ;
1435+ const totalAvailable = getTotalSize ( splitter , 'width' ) ;
1436+
1437+ expect ( newSizes . startSize ) . to . equal ( 200 ) ;
1438+ expect ( newSizes . endSize ) . to . be . closeTo ( totalAvailable * 0.2 , 2 ) ;
12951439 } ) ;
12961440
1297- //TODO: others
1441+ it ( 'should handle sizes on window resize with auto and % sizes' , async ( ) => {
1442+ const splitter = await fixture < IgcSplitterComponent > (
1443+ createTwoPanesWithSizesAndConstraints ( {
1444+ endSize : '30%' ,
1445+ splitterWidth : '1000px' ,
1446+ } )
1447+ ) ;
1448+ await elementUpdated ( splitter ) ;
1449+
1450+ splitter . style . width = '800px' ;
1451+ await elementUpdated ( splitter ) ;
1452+
1453+ const newSizes = getPanesSizes ( splitter , 'width' ) ;
1454+ const totalAvailable = getTotalSize ( splitter , 'width' ) ;
1455+
1456+ expect ( newSizes . endSize ) . to . be . closeTo ( totalAvailable * 0.3 , 2 ) ;
1457+ expect ( newSizes . startSize ) . to . equal ( totalAvailable - newSizes . endSize ) ;
1458+ } ) ;
12981459 } ) ;
12991460
13001461 describe ( 'RTL' , ( ) => {
@@ -1420,6 +1581,60 @@ describe('Splitter', () => {
14201581 expect ( splitter . endCollapsed ) . to . be . false ;
14211582 } ) ;
14221583
1584+ it ( 'should expand/collapse the correct pane through the expander buttons in RTL' , async ( ) => {
1585+ const startExpander = getSplitterPart ( splitter , 'start-expander' ) ;
1586+ const endExpander = getSplitterPart ( splitter , 'end-expander' ) ;
1587+
1588+ simulatePointerDown ( startExpander , { bubbles : true } ) ;
1589+ await elementUpdated ( splitter ) ;
1590+ await nextFrame ( ) ;
1591+
1592+ const totalAvailable = getTotalSize ( splitter , 'width' ) ;
1593+ let currentSizes = getPanesSizes ( splitter , 'width' ) ;
1594+
1595+ expect ( currentSizes . startSize ) . to . equal ( 0 ) ;
1596+ expect ( currentSizes . endSize ) . to . equal ( totalAvailable ) ;
1597+ expect ( splitter . startCollapsed ) . to . be . true ;
1598+ expect ( splitter . endCollapsed ) . to . be . false ;
1599+
1600+ simulatePointerDown ( startExpander , { bubbles : true } ) ;
1601+ await elementUpdated ( splitter ) ;
1602+ await nextFrame ( ) ;
1603+
1604+ currentSizes = getPanesSizes ( splitter , 'width' ) ;
1605+
1606+ expect ( currentSizes . startSize ) . to . be . greaterThan ( 0 ) ;
1607+ expect ( currentSizes . endSize ) . to . equal (
1608+ totalAvailable - currentSizes . startSize
1609+ ) ;
1610+ expect ( splitter . startCollapsed ) . to . be . false ;
1611+ expect ( splitter . endCollapsed ) . to . be . false ;
1612+
1613+ simulatePointerDown ( endExpander , { bubbles : true } ) ;
1614+ await elementUpdated ( splitter ) ;
1615+ await nextFrame ( ) ;
1616+
1617+ currentSizes = getPanesSizes ( splitter , 'width' ) ;
1618+
1619+ expect ( currentSizes . startSize ) . to . equal ( totalAvailable ) ;
1620+ expect ( currentSizes . endSize ) . to . equal ( 0 ) ;
1621+ expect ( splitter . startCollapsed ) . to . be . false ;
1622+ expect ( splitter . endCollapsed ) . to . be . true ;
1623+
1624+ simulatePointerDown ( endExpander , { bubbles : true } ) ;
1625+ await elementUpdated ( splitter ) ;
1626+ await nextFrame ( ) ;
1627+
1628+ currentSizes = getPanesSizes ( splitter , 'width' ) ;
1629+
1630+ expect ( currentSizes . startSize ) . to . equal (
1631+ totalAvailable - currentSizes . endSize
1632+ ) ;
1633+ expect ( currentSizes . endSize ) . to . be . greaterThan ( 0 ) ;
1634+ expect ( splitter . startCollapsed ) . to . be . false ;
1635+ expect ( splitter . endCollapsed ) . to . be . false ;
1636+ } ) ;
1637+
14231638 it ( 'direction should not affect interactions in vertical orientation' , async ( ) => {
14241639 splitter . orientation = 'vertical' ;
14251640 await elementUpdated ( splitter ) ;
0 commit comments