Skip to content

Commit 20f8679

Browse files
committed
TT-52 feat: unit tests for feature flag ui-list-technologies
1 parent 29bbfa7 commit 20f8679

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/app/modules/shared/components/sidebar/sidebar.component.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {RouterTestingModule} from '@angular/router/testing';
66
import {Router, Routes} from '@angular/router';
77
import {TimeClockComponent} from '../../../time-clock/pages/time-clock.component';
88
import {provideMockStore} from '@ngrx/store/testing';
9+
import {Observable, of} from 'rxjs';
910

1011
describe('SidebarComponent', () => {
1112
let component: SidebarComponent;
@@ -79,4 +80,27 @@ describe('SidebarComponent', () => {
7980
expect(item.active).toBeFalse();
8081
});
8182
});
83+
84+
it('List Technologies item is added when feature flag "ui-list-technologies" is enabled', () => {
85+
const featureManagerServiceStub = {
86+
isToggleEnabledForUser(toggleName: string, toggleLabel?: string): Observable<boolean> {
87+
return of(true);
88+
},
89+
};
90+
const itemsSidebar = [];
91+
component.toggleListTechnologies(featureManagerServiceStub, itemsSidebar);
92+
expect(itemsSidebar.length).toBe(1);
93+
});
94+
95+
it('List Technologies item is not added when feature flag "ui-list-technologies" is disabled', () => {
96+
const featureManagerServiceStub = {
97+
isToggleEnabledForUser(toggleName: string, toggleLabel?: string): Observable<boolean> {
98+
return of(false);
99+
},
100+
};
101+
const itemsSidebar = [];
102+
component.toggleListTechnologies(featureManagerServiceStub, itemsSidebar);
103+
expect(itemsSidebar.length).toBe(0);
104+
});
105+
82106
});

src/app/modules/shared/components/sidebar/sidebar.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class SidebarComponent implements OnInit {
1919
constructor(
2020
private azureAdB2CService: AzureAdB2CService,
2121
private router: Router,
22-
private featureManagerService : FeatureManagerService,
22+
private featureManagerService: FeatureManagerService,
2323
) {
2424
this.navStart = this.router.events.pipe(
2525
filter(evt => evt instanceof NavigationStart)
@@ -29,7 +29,7 @@ export class SidebarComponent implements OnInit {
2929
ngOnInit(): void {
3030
this.toggleSideBar();
3131
this.getSidebarItems();
32-
this.toggleListTechnologies(this.itemsSidebar);
32+
this.toggleListTechnologies(this.featureManagerService, this.itemsSidebar);
3333
this.highlightMenuOption(this.router.routerState.snapshot.url);
3434
this.navStart.subscribe(evt => {
3535
this.highlightMenuOption(evt.url);
@@ -61,8 +61,8 @@ export class SidebarComponent implements OnInit {
6161
}
6262
}
6363

64-
toggleListTechnologies(itemsSidebar: ItemSidebar[]){
65-
this.featureManagerService
64+
toggleListTechnologies(featureManagerService, itemsSidebar: ItemSidebar[]){
65+
featureManagerService
6666
.isToggleEnabledForUser('ui-list-technologies')
6767
.subscribe((enabled) => {
6868
if (enabled === true){
@@ -73,7 +73,7 @@ export class SidebarComponent implements OnInit {
7373
active: false
7474
};
7575
itemsSidebar.push(listTechnologiesItem);
76-
};
76+
}
7777
});
7878
}
7979

0 commit comments

Comments
 (0)