@@ -44,7 +44,7 @@ describe('Tile Manager component', () => {
4444 function createTileManager ( ) {
4545 const result = Array . from ( range ( 5 ) ) . map (
4646 ( i ) => html `
47- < igc-tile id ="tile ${ i } " col-span ="5 " row-span ="5 ">
47+ < igc-tile id ="tile ${ i } " col-span ="5 " row-span ="5 " position = ${ i } >
4848 < h3 slot ="title "> Tile ${ i + 1 } </ h3 >
4949
5050 < div >
@@ -56,6 +56,14 @@ describe('Tile Manager component', () => {
5656 return html `< igc-tile-manager > ${ result } </ igc-tile-manager > ` ;
5757 }
5858
59+ function createTileManagerWithPositions ( ) {
60+ return html `< igc-tile-manager >
61+ < igc-tile id ="tile1 " position ="2 " col-span ="2 " row-span ="2 "> </ igc-tile >
62+ < igc-tile id ="tile2 " position ="1 " col-start ="4 " row-start ="4 "> </ igc-tile >
63+ < igc-tile id ="tile3 "> </ igc-tile >
64+ </ igc-tile-manager > ` ;
65+ }
66+
5967 function expectSlotContent (
6068 tile : IgcTileComponent ,
6169 slotName : string ,
@@ -937,6 +945,29 @@ describe('Tile Manager component', () => {
937945 expect ( tile . style . order ) . to . equal ( index . toString ( ) ) ;
938946 } ) ;
939947 } ) ;
948+ } ) ;
949+
950+ describe ( 'Positioning' , ( ) => {
951+ beforeEach ( async ( ) => {
952+ tileManager = await fixture < IgcTileManagerComponent > (
953+ createTileManagerWithPositions ( )
954+ ) ;
955+ } ) ;
956+
957+ it ( 'should preserve pre-set positions' , async ( ) => {
958+ const tile1 = tileManager . querySelector < IgcTileComponent > ( '#tile1' ) ;
959+ const tile2 = tileManager . querySelector < IgcTileComponent > ( '#tile2' ) ;
960+ const tile3 = tileManager . querySelector < IgcTileComponent > ( '#tile3' ) ;
961+
962+ expect ( tile1 ) . to . exist ;
963+ expect ( tile1 ! . position ) . to . equal ( 2 ) ;
964+
965+ expect ( tile2 ) . to . exist ;
966+ expect ( tile2 ! . position ) . to . equal ( 1 ) ;
967+
968+ expect ( tile3 ) . to . exist ;
969+ expect ( tile3 ! . position ) . to . equal ( 0 ) ;
970+ } ) ;
940971
941972 it ( 'should correctly position tiles added dynamically after initialization' , async ( ) => {
942973 tileManager . replaceChildren ( ) ;
@@ -960,19 +991,20 @@ describe('Tile Manager component', () => {
960991 await elementUpdated ( tileManager ) ;
961992
962993 expect ( firstTile . style . order ) . to . equal ( '6' ) ;
963- expect ( tileManager . tiles [ 4 ] . position ) . to . equal ( 6 ) ;
994+ expect ( tileManager . tiles [ 2 ] . position ) . to . equal ( 6 ) ;
964995 } ) ;
965996
966997 it ( 'should properly handle tile addition with specified position' , async ( ) => {
967998 const newTile = document . createElement ( 'igc-tile' ) ;
968- newTile . position = 3 ;
999+ newTile . position = 1 ;
1000+
9691001 tileManager . append ( newTile ) ;
9701002 await elementUpdated ( tileManager ) ;
9711003
9721004 const tiles = getTiles ( ) ;
973- expect ( tiles [ 5 ] ) . to . equal ( newTile ) ;
974- expect ( tiles [ 5 ] . position ) . to . equal ( 3 ) ;
975- expect ( tiles [ 4 ] . position ) . to . equal ( 5 ) ;
1005+ expect ( tiles [ 3 ] ) . to . equal ( newTile ) ;
1006+ expect ( tiles [ 3 ] . position ) . to . equal ( 1 ) ;
1007+ expect ( tiles [ 1 ] . position ) . to . equal ( 2 ) ;
9761008 } ) ;
9771009
9781010 it ( 'should adjust positions correctly when a tile is removed' , async ( ) => {
0 commit comments