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
code-smell: TT-331 Fixing bugs and code-smells
resolving merge conflicts
  • Loading branch information
Edgar Guaman committed Sep 13, 2021
commit 4e8e5ad0f64c36fd3cfa3b915b6c83244e7f7fb3
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<div class="table-cell relative">
<span class="absolute cursor-pointer inset-y-0 right-0 min-h-screen w-0.5 hover:z-0 hover:bg-blue-400" (click)="toggleSideBar()"></span>
<span class="group cursor-pointer absolute w-5 top-20 -right-3">
<img src="assets/icons/left-chevron.svg" id="hide-sidebar" (click)="toggleSideBar()" width="20" height="20" class="bg-black-light rounded-full hover:bg-opacity-50 hover:bg-info-light sm:hidden md:block lg:block shadow-sm"/>
<img src="assets/icons/left-chevron.svg" alt="hide-chevron" id="hide-sidebar" (click)="toggleSideBar()" width="20" height="20" class="bg-black-light rounded-full hover:bg-opacity-50 hover:bg-info-light sm:hidden md:block lg:block shadow-sm"/>
<div class="opacity-0 w-12 bg-black text-white text-center text-xs rounded-lg py-2 absolute z-10 group-hover:opacity-100 bottom-full left-1/4 ml-4 -mb-6 px-1 pointer-events-none">Hide</div>
</span>
<span class="group cursor-pointer absolute top-20 -right-5">
<img src="assets/icons/right-chevron.svg" id="show-sidebar" (click)="toggleSideBar()" width="20" height="20" class="bg-black-light rounded-full hover:bg-opacity-50 hover:bg-info-light sm:block md:hidden lg:hidden"/>
<img src="assets/icons/right-chevron.svg" alt="show-chevron" id="show-sidebar" (click)="toggleSideBar()" width="20" height="20" class="bg-black-light rounded-full hover:bg-opacity-50 hover:bg-info-light sm:block md:hidden lg:hidden"/>
<div class="opacity-0 w-12 bg-black text-white text-center text-xs rounded-lg py-2 absolute z-10 group-hover:opacity-100 bottom-full left-1/4 ml-4 -mb-6 px-1 pointer-events-none">Show</div>
</span>
</div>
Expand Down
36 changes: 25 additions & 11 deletions src/app/modules/shared/components/sidebar/sidebar.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ describe('SidebarComponent', () => {
let router;
const routes: Routes = [{ path: 'time-clock', component: TimeClockComponent }];

const azureAdB2CServiceStub = {
isLogin() {
return true;
},
isAdmin() {
return true;
},
};

const userInfoServiceStub = {
isAdmin: () => of(true),
};
Expand Down Expand Up @@ -83,10 +74,33 @@ describe('SidebarComponent', () => {
});
});

it('uses the Azure service on logout', () => {
it('onInit checks if isLogin is true and gets the name, email and sets the tenantid in the Storage', () => {
spyOn(azureAdB2CServiceStubInjected, 'isLogin').and.returnValue(true);
spyOn(azureAdB2CServiceStubInjected, 'getName').and.returnValue('Name');
spyOn(azureAdB2CServiceStubInjected, 'getUserEmail').and.returnValue('Email');
spyOn(azureAdB2CServiceStubInjected, 'setTenantId');
component.ngOnInit();
expect(azureAdB2CServiceStubInjected.isLogin).toHaveBeenCalled();
expect(azureAdB2CServiceStubInjected.getName).toHaveBeenCalled();
expect(azureAdB2CServiceStubInjected.getUserEmail).toHaveBeenCalled();
expect(azureAdB2CServiceStubInjected.setTenantId).toHaveBeenCalled();
});

it('onInit does not get the name and the email if isLogin is false', () => {
spyOn(azureAdB2CServiceStubInjected, 'isLogin').and.returnValue(false);
spyOn(azureAdB2CServiceStubInjected, 'getName').and.returnValue('Name');
spyOn(azureAdB2CServiceStubInjected, 'getUserEmail').and.returnValue('Email');
spyOn(azureAdB2CServiceStubInjected, 'setTenantId');
component.ngOnInit();
expect(azureAdB2CServiceStubInjected.isLogin).toHaveBeenCalled();
expect(azureAdB2CServiceStubInjected.getName).toHaveBeenCalledTimes(0);
expect(azureAdB2CServiceStubInjected.getUserEmail).toHaveBeenCalledTimes(0);
expect(azureAdB2CServiceStubInjected.setTenantId).not.toHaveBeenCalled();
});

it('should use the Azure service on logout', () => {
spyOn(azureAdB2CServiceStubInjected, 'logout');
component.logout();
expect(azureAdB2CServiceStubInjected.logout).toHaveBeenCalled();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class SidebarComponent implements OnInit, OnDestroy {
if (this.azureAdB2CService.isLogin()) {
this.userName = this.azureAdB2CService.getName();
this.userEmail = this.azureAdB2CService.getUserEmail();
this.azureAdB2CService.setTenantId();
}
}

Expand Down