@@ -140,6 +140,37 @@ describe('layout-gap directive', () => {
140
140
141
141
} ) ) ;
142
142
143
+ fit ( 'should add update gap styles when only 1 row is remaining' , async ( ( ) => {
144
+ let template = `
145
+ <div fxLayoutAlign='center center' fxLayoutGap='13px'>
146
+ <div fxFlex *ngFor='let row of rows'></div>
147
+ </div>
148
+ ` ;
149
+ fixture = createTestComponent ( template ) ;
150
+ fixture . componentInstance . direction = 'row' ;
151
+ fixture . detectChanges ( ) ;
152
+
153
+ let nodes = queryFor ( fixture , '[fxFlex]' ) ;
154
+
155
+ expect ( nodes . length ) . toEqual ( 4 ) ;
156
+ expect ( nodes [ 0 ] . nativeElement ) . toHaveStyle ( { 'margin-right' : '13px' } ) ;
157
+ expect ( nodes [ 3 ] . nativeElement ) . not . toHaveStyle ( { 'margin-right' : '13px' } ) ;
158
+
159
+ fixture . componentInstance . rows = new Array ( 1 ) ;
160
+ fixture . detectChanges ( ) ;
161
+
162
+ setTimeout ( ( ) => {
163
+ // Since the layoutGap directive detects the *ngFor changes by using a MutationObserver, the
164
+ // browser will take up some time, to actually announce the changes to the directive.
165
+ // (Kudos to @DevVersion)
166
+ nodes = queryFor ( fixture , '[fxFlex]' ) ;
167
+
168
+ expect ( nodes . length ) . toEqual ( 1 ) ;
169
+ expect ( nodes [ 0 ] . nativeElement ) . not . toHaveStyle ( { 'margin-right' : '13px' } ) ;
170
+ } ) ;
171
+
172
+ } ) ) ;
173
+
143
174
it ( 'should apply margin-top for column layouts' , ( ) => {
144
175
verifyCorrectMargin ( 'column' , 'margin-bottom' ) ;
145
176
} ) ;
0 commit comments