@@ -7,11 +7,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'
77
88import { GeneralComponent } from './general.component'
99import { ActivatedRoute } from '@angular/router'
10- import { of } from 'rxjs'
10+ import { of , Subject } from 'rxjs'
1111import { DevicesService } from '../devices.service'
1212import { provideTranslateService } from '@ngx-translate/core'
1313import { By } from '@angular/platform-browser'
14- import { Subject } from 'rxjs'
1514
1615describe ( 'GeneralComponent' , ( ) => {
1716 let component : GeneralComponent
@@ -179,4 +178,25 @@ describe('GeneralComponent', () => {
179178 expect ( component . isLoading ( ) ) . toBeFalse ( )
180179 expect ( component . isUpdatingFeatures ( ) ) . toBeFalse ( )
181180 } )
181+
182+ it ( 'keeps feature loading state true until the last overlapping update completes' , ( ) => {
183+ const firstResponse$ = new Subject < any > ( )
184+ const secondResponse$ = new Subject < any > ( )
185+ devicesServiceSpy . setAmtFeatures . and . returnValues ( firstResponse$ , secondResponse$ )
186+
187+ component . setAmtFeatures ( )
188+ component . setAmtFeatures ( )
189+
190+ expect ( component . isUpdatingFeatures ( ) ) . toBeTrue ( )
191+
192+ firstResponse$ . next ( { redirection : true , status : 'ok' } )
193+ firstResponse$ . complete ( )
194+
195+ expect ( component . isUpdatingFeatures ( ) ) . toBeTrue ( )
196+
197+ secondResponse$ . next ( { redirection : true , status : 'ok' } )
198+ secondResponse$ . complete ( )
199+
200+ expect ( component . isUpdatingFeatures ( ) ) . toBeFalse ( )
201+ } )
182202} )
0 commit comments