1+ import { HttpClient } from '@angular/common/http' ;
2+ import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service' ;
13import { waitForAsync , ComponentFixture , TestBed } from '@angular/core/testing' ;
24import { MockStore , provideMockStore } from '@ngrx/store/testing' ;
35
@@ -6,12 +8,14 @@ import { UsersListComponent } from './users-list.component';
68import { UserActionTypes , UserState , LoadUsers , GrantRoleUser , RevokeRoleUser } from '../../store' ;
79import { ActionsSubject } from '@ngrx/store' ;
810import { DataTablesModule } from 'angular-datatables' ;
11+ import { of } from 'rxjs' ;
912
1013describe ( 'UsersListComponent' , ( ) => {
1114 let component : UsersListComponent ;
1215 let fixture : ComponentFixture < UsersListComponent > ;
1316 let store : MockStore < UserState > ;
1417 const actionSub : ActionsSubject = new ActionsSubject ( ) ;
18+ let featureManagerService : FeatureManagerService ;
1519
1620 const state : UserState = {
1721 data : [
@@ -35,6 +39,7 @@ describe('UsersListComponent', () => {
3539 declarations : [ UsersListComponent ] ,
3640 providers : [ provideMockStore ( { initialState : state } ) , { provide : ActionsSubject , useValue : actionSub } ] ,
3741 } ) . compileComponents ( ) ;
42+ featureManagerService = TestBed . inject ( FeatureManagerService ) ;
3843 } )
3944 ) ;
4045
@@ -158,9 +163,27 @@ describe('UsersListComponent', () => {
158163 expect ( component . dtElement . dtInstance . then ) . toHaveBeenCalled ( ) ;
159164 } ) ;
160165
166+
167+ fit ( 'When Component is created, should call the feature toggle method' , ( ) => {
168+
169+ // spyOn(service, 'getAll').and.callFake( () => {
170+ // return of(mockUser);
171+ // });
172+
173+ spyOn ( component , 'isFeatureToggleActivated' ) . and . callFake ( ( ) => {
174+ return of ( true ) ;
175+ } ) ;
176+
177+ component . ngOnInit ( ) ;
178+
179+ expect ( component . isFeatureToggleActivated ) . toHaveBeenCalled ( ) ;
180+ expect ( component . isUserGroupsToggleOn ) . toBe ( true ) ;
181+ } ) ;
182+
161183 afterEach ( ( ) => {
162184 component . dtTrigger . unsubscribe ( ) ;
163185 component . loadUsersSubscription . unsubscribe ( ) ;
164186 fixture . destroy ( ) ;
165187 } ) ;
188+
166189} ) ;
0 commit comments