@@ -4,16 +4,13 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing';
44import { NgxPaginationModule } from 'ngx-pagination' ;
55import { UsersListComponent } from './users-list.component' ;
66import { UserActionTypes , UserState , LoadUsers , GrantRoleUser , RevokeRoleUser } from '../../store' ;
7- import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service' ;
87import { ActionsSubject } from '@ngrx/store' ;
98import { DataTablesModule } from 'angular-datatables' ;
10- import { Observable , of } from 'rxjs' ;
119
1210describe ( 'UsersListComponent' , ( ) => {
1311 let component : UsersListComponent ;
1412 let fixture : ComponentFixture < UsersListComponent > ;
1513 let store : MockStore < UserState > ;
16- let featureManagerService : FeatureManagerService ;
1714 const actionSub : ActionsSubject = new ActionsSubject ( ) ;
1815
1916 const state : UserState = {
@@ -39,7 +36,6 @@ describe('UsersListComponent', () => {
3936 declarations : [ UsersListComponent ] ,
4037 providers : [ provideMockStore ( { initialState : state } ) , { provide : ActionsSubject , useValue : actionSub } ] ,
4138 } ) . compileComponents ( ) ;
42- featureManagerService = TestBed . inject ( FeatureManagerService ) ;
4339 } )
4440 ) ;
4541
@@ -75,36 +71,6 @@ describe('UsersListComponent', () => {
7571 expect ( component . users ) . toEqual ( state . data ) ;
7672 } ) ;
7773
78- it ( 'When Component is created, should call the feature toggle method' , ( ) => {
79- spyOn ( component , 'isFeatureToggleActivated' ) . and . returnValue ( of ( true ) ) ;
80-
81- component . ngOnInit ( ) ;
82-
83- expect ( component . isFeatureToggleActivated ) . toHaveBeenCalled ( ) ;
84- expect ( component . isUserRoleToggleOn ) . toBe ( true ) ;
85- } ) ;
86-
87- const actionsParams = [
88- { actionType : UserActionTypes . GRANT_USER_ROLE_SUCCESS } ,
89- { actionType : UserActionTypes . REVOKE_USER_ROLE_SUCCESS } ,
90- ] ;
91-
92- actionsParams . map ( ( param ) => {
93- it ( `When action ${ param . actionType } is dispatched should triggered load Users action` , ( ) => {
94- spyOn ( store , 'dispatch' ) ;
95-
96- const actionSubject = TestBed . inject ( ActionsSubject ) as ActionsSubject ;
97- const action = {
98- type : param . actionType ,
99- payload : state . data ,
100- } ;
101-
102- actionSubject . next ( action ) ;
103-
104- expect ( store . dispatch ) . toHaveBeenCalledWith ( new LoadUsers ( ) ) ;
105- } ) ;
106- } ) ;
107-
10874 const grantRoleTypes = [
10975 { roleId : 'admin' , roleValue : 'time-tracker-admin' } ,
11076 { roleId : 'test' , roleValue : 'time-tracker-tester' } ,
@@ -190,23 +156,7 @@ describe('UsersListComponent', () => {
190156 } ) ;
191157 } ) ;
192158
193- const toggleValues = [ true , false ] ;
194- toggleValues . map ( ( toggleValue ) => {
195- it ( `when FeatureToggle is ${ toggleValue } should return ${ toggleValue } ` , ( ) => {
196- spyOn ( featureManagerService , 'isToggleEnabledForUser' ) . and . returnValue ( of ( toggleValue ) ) ;
197-
198- const isFeatureToggleActivated : Observable < boolean > = component . isFeatureToggleActivated ( ) ;
199-
200- expect ( featureManagerService . isToggleEnabledForUser ) . toHaveBeenCalled ( ) ;
201- isFeatureToggleActivated . subscribe ( ( value ) => expect ( value ) . toEqual ( toggleValue ) ) ;
202- } ) ;
203- } ) ;
204-
205- /*
206- TODO: block commented on purpose so that when the tests pass and the Feature toggle is removed,
207- the table will be rendered again with dtInstance and not with dtOptions
208-
209- it('on success load users, the datatable should be reloaded', async () => {
159+ it ( 'on success load users, the datatable should be reloaded' , async ( ) => {
210160 const actionSubject = TestBed . inject ( ActionsSubject ) ;
211161 const action = {
212162 type : UserActionTypes . LOAD_USERS_SUCCESS ,
@@ -217,7 +167,7 @@ describe('UsersListComponent', () => {
217167 actionSubject . next ( action ) ;
218168
219169 expect ( component . dtElement . dtInstance . then ) . toHaveBeenCalled ( ) ;
220- });*/
170+ } ) ;
221171
222172 afterEach ( ( ) => {
223173 component . dtTrigger . unsubscribe ( ) ;
0 commit comments