Skip to content

Commit acf79d6

Browse files
scastillo-jpLEON12699
authored andcommitted
feat: TT-190 mock test
1 parent 76aaa74 commit acf79d6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/app/modules/users/components/users-list/users-list.component.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service';
13
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
24
import { MockStore, provideMockStore } from '@ngrx/store/testing';
35

@@ -6,12 +8,14 @@ import { UsersListComponent } from './users-list.component';
68
import { UserActionTypes, UserState, LoadUsers, GrantRoleUser, RevokeRoleUser } from '../../store';
79
import { ActionsSubject } from '@ngrx/store';
810
import { DataTablesModule } from 'angular-datatables';
11+
import { of } from 'rxjs';
912

1013
describe('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

Comments
 (0)