Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TT-52 feat: unit tests for feature flag ui-list-technologies
  • Loading branch information
Angeluz-07 committed Dec 11, 2020
commit 20f8679a76b53310e76ea17ffeab6b7ec978b0d6
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {RouterTestingModule} from '@angular/router/testing';
import {Router, Routes} from '@angular/router';
import {TimeClockComponent} from '../../../time-clock/pages/time-clock.component';
import {provideMockStore} from '@ngrx/store/testing';
import {Observable, of} from 'rxjs';

describe('SidebarComponent', () => {
let component: SidebarComponent;
Expand Down Expand Up @@ -79,4 +80,27 @@ describe('SidebarComponent', () => {
expect(item.active).toBeFalse();
});
});

it('List Technologies item is added when feature flag "ui-list-technologies" is enabled', () => {
const featureManagerServiceStub = {
isToggleEnabledForUser(toggleName: string, toggleLabel?: string): Observable<boolean> {
return of(true);
},
};
const itemsSidebar = [];
component.toggleListTechnologies(featureManagerServiceStub, itemsSidebar);
expect(itemsSidebar.length).toBe(1);
});

it('List Technologies item is not added when feature flag "ui-list-technologies" is disabled', () => {
const featureManagerServiceStub = {
isToggleEnabledForUser(toggleName: string, toggleLabel?: string): Observable<boolean> {
return of(false);
},
};
const itemsSidebar = [];
component.toggleListTechnologies(featureManagerServiceStub, itemsSidebar);
expect(itemsSidebar.length).toBe(0);
});

});
10 changes: 5 additions & 5 deletions src/app/modules/shared/components/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SidebarComponent implements OnInit {
constructor(
private azureAdB2CService: AzureAdB2CService,
private router: Router,
private featureManagerService : FeatureManagerService,
private featureManagerService: FeatureManagerService,
) {
this.navStart = this.router.events.pipe(
filter(evt => evt instanceof NavigationStart)
Expand All @@ -29,7 +29,7 @@ export class SidebarComponent implements OnInit {
ngOnInit(): void {
this.toggleSideBar();
this.getSidebarItems();
this.toggleListTechnologies(this.itemsSidebar);
this.toggleListTechnologies(this.featureManagerService, this.itemsSidebar);
this.highlightMenuOption(this.router.routerState.snapshot.url);
this.navStart.subscribe(evt => {
this.highlightMenuOption(evt.url);
Expand Down Expand Up @@ -61,8 +61,8 @@ export class SidebarComponent implements OnInit {
}
}

toggleListTechnologies(itemsSidebar: ItemSidebar[]){
this.featureManagerService
toggleListTechnologies(featureManagerService, itemsSidebar: ItemSidebar[]){
featureManagerService
.isToggleEnabledForUser('ui-list-technologies')
.subscribe((enabled) => {
if (enabled === true){
Expand All @@ -73,7 +73,7 @@ export class SidebarComponent implements OnInit {
active: false
};
itemsSidebar.push(listTechnologiesItem);
};
}
});
}

Expand Down