@@ -4,16 +4,13 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing';
4
4
import { NgxPaginationModule } from 'ngx-pagination' ;
5
5
import { UsersListComponent } from './users-list.component' ;
6
6
import { UserActionTypes , UserState , LoadUsers , GrantRoleUser , RevokeRoleUser } from '../../store' ;
7
- import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service' ;
8
7
import { ActionsSubject } from '@ngrx/store' ;
9
8
import { DataTablesModule } from 'angular-datatables' ;
10
- import { Observable , of } from 'rxjs' ;
11
9
12
10
describe ( 'UsersListComponent' , ( ) => {
13
11
let component : UsersListComponent ;
14
12
let fixture : ComponentFixture < UsersListComponent > ;
15
13
let store : MockStore < UserState > ;
16
- let featureManagerService : FeatureManagerService ;
17
14
const actionSub : ActionsSubject = new ActionsSubject ( ) ;
18
15
19
16
const state : UserState = {
@@ -39,7 +36,6 @@ describe('UsersListComponent', () => {
39
36
declarations : [ UsersListComponent ] ,
40
37
providers : [ provideMockStore ( { initialState : state } ) , { provide : ActionsSubject , useValue : actionSub } ] ,
41
38
} ) . compileComponents ( ) ;
42
- featureManagerService = TestBed . inject ( FeatureManagerService ) ;
43
39
} )
44
40
) ;
45
41
@@ -75,36 +71,6 @@ describe('UsersListComponent', () => {
75
71
expect ( component . users ) . toEqual ( state . data ) ;
76
72
} ) ;
77
73
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
-
108
74
const grantRoleTypes = [
109
75
{ roleId : 'admin' , roleValue : 'time-tracker-admin' } ,
110
76
{ roleId : 'test' , roleValue : 'time-tracker-tester' } ,
@@ -190,23 +156,7 @@ describe('UsersListComponent', () => {
190
156
} ) ;
191
157
} ) ;
192
158
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 ( ) => {
210
160
const actionSubject = TestBed . inject ( ActionsSubject ) ;
211
161
const action = {
212
162
type : UserActionTypes . LOAD_USERS_SUCCESS ,
@@ -217,7 +167,7 @@ describe('UsersListComponent', () => {
217
167
actionSubject . next ( action ) ;
218
168
219
169
expect ( component . dtElement . dtInstance . then ) . toHaveBeenCalled ( ) ;
220
- });*/
170
+ } ) ;
221
171
222
172
afterEach ( ( ) => {
223
173
component . dtTrigger . unsubscribe ( ) ;
0 commit comments