1- import { Subscription , of } from 'rxjs' ;
1+ import { Subscription , of , Observable } from 'rxjs' ;
22import { LoadActiveEntry , EntryActionTypes , UpdateEntry } from './../../store/entry.actions' ;
33import { ActivityManagementActionTypes } from './../../../activities-management/store/activity-management.actions' ;
44import { waitForAsync , ComponentFixture , TestBed } from '@angular/core/testing' ;
@@ -430,7 +430,7 @@ describe('EntryFieldsComponent', () => {
430430 expect ( component . actionSetDateSubscription . unsubscribe ) . toHaveBeenCalled ( ) ;
431431 } ) ;
432432
433- it ( 'The flag "update_last_entry_if_overlap" is added to the "newData" when feature flag "update-entries" is enabled for user ' , ( ) => {
433+ it ( 'when feature-toggle "update-entries" enable for the user, the updateEntry function is executes to update the entries ' , ( ) => {
434434 spyOn ( featureManagerService , 'isToggleEnabledForUser' ) . and . returnValue ( of ( true ) ) ;
435435
436436 const mockEntry = { ...entry ,
@@ -444,7 +444,7 @@ describe('EntryFieldsComponent', () => {
444444 expect ( component . newData . update_last_entry_if_overlap ) . toEqual ( expected . update_last_entry_if_overlap ) ;
445445 } ) ;
446446
447- it ( 'The flag "update_last_entry_if_overlap" is not added to the "newData" when feature flag " update-entries" is disable for user ' , ( ) => {
447+ it ( 'when FT "update-entries" disable for the user, the UpdateCurrentOrLastEntry function is called to update the entries ' , ( ) => {
448448 spyOn ( featureManagerService , 'isToggleEnabledForUser' ) . and . returnValue ( of ( false ) ) ;
449449
450450 const mockEntry = { ...entry ,
@@ -457,4 +457,25 @@ describe('EntryFieldsComponent', () => {
457457 const expected = { update_last_entry_if_overlap : false } ;
458458 expect ( component . newData . update_last_entry_if_overlap ) . toEqual ( expected . update_last_entry_if_overlap ) ;
459459 } ) ;
460+
461+ const toggleValues = [ true , false ] ;
462+ toggleValues . map ( ( toggleValue ) => {
463+ it ( `when FeatureToggle is ${ toggleValue } should return ${ toggleValue } ` , ( ) => {
464+ spyOn ( featureManagerService , 'isToggleEnabledForUser' ) . and . returnValue ( of ( toggleValue ) ) ;
465+
466+ const isFeatureToggleActivated : Observable < boolean > = component . isFeatureToggleActivated ( ) ;
467+
468+ expect ( featureManagerService . isToggleEnabledForUser ) . toHaveBeenCalled ( ) ;
469+ isFeatureToggleActivated . subscribe ( ( value ) => expect ( value ) . toEqual ( toggleValue ) ) ;
470+ } ) ;
471+ } ) ;
472+
473+ // fit('should return the id of the active user', () => {
474+
475+ // const userId = 'user_id';
476+
477+ // expect( component.getOwnerId()).
478+ // });
460479} ) ;
480+
481+
0 commit comments