-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af8fa6d
commit 34cee4b
Showing
4 changed files
with
190 additions
and
24 deletions.
There are no files selected for viewing
47 changes: 30 additions & 17 deletions
47
libs/app/components/src/lib/floorplan-editor-page/floorplan-editor-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FloorplanEditorPageComponent } from './floorplan-editor-page.component'; | ||
// import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
// import { FloorplanEditorPageComponent } from './floorplan-editor-page.component'; | ||
// import { NgIconsModule, provideIcons } from '@ng-icons/core'; | ||
// import { RouterTestingModule } from '@angular/router/testing'; | ||
// import { AppApiService } from '@event-participation-trends/app/api'; | ||
|
||
describe('FloorplanEditorPageComponent', () => { | ||
let component: FloorplanEditorPageComponent; | ||
let fixture: ComponentFixture<FloorplanEditorPageComponent>; | ||
// import { heroUserGroupSolid } from "@ng-icons/heroicons/solid"; | ||
// import { heroBackward } from "@ng-icons/heroicons/outline"; | ||
// import { matKeyboardDoubleArrowUp, matKeyboardDoubleArrowDown, matRadioButtonUnchecked, matCheckCircleOutline } from "@ng-icons/material-icons/baseline"; | ||
// import { matFilterCenterFocus, matZoomIn, matZoomOut } from "@ng-icons/material-icons/baseline"; | ||
// import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [FloorplanEditorPageComponent], | ||
}).compileComponents(); | ||
// describe('FloorplanEditorPageComponent', () => { | ||
// let component: FloorplanEditorPageComponent; | ||
// let fixture: ComponentFixture<FloorplanEditorPageComponent>; | ||
|
||
fixture = TestBed.createComponent(FloorplanEditorPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
// beforeEach(async () => { | ||
// await TestBed.configureTestingModule({ | ||
// imports: [FloorplanEditorPageComponent, NgIconsModule, RouterTestingModule, HttpClientTestingModule], | ||
// providers: [ | ||
// AppApiService, | ||
// provideIcons({matCheckCircleOutline, matRadioButtonUnchecked, heroUserGroupSolid, heroBackward, matKeyboardDoubleArrowUp, matKeyboardDoubleArrowDown, matFilterCenterFocus, matZoomIn, matZoomOut}) | ||
// ] | ||
// }).compileComponents(); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); | ||
// fixture = TestBed.createComponent(FloorplanEditorPageComponent); | ||
// component = fixture.componentInstance; | ||
// fixture.detectChanges(); | ||
// }); | ||
|
||
// it('should create', () => { | ||
// expect(component).toBeTruthy(); | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 122 additions & 2 deletions
124
libs/app/components/src/lib/users-page/users-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,141 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ComponentFixture, TestBed, fakeAsync, flush, tick } from '@angular/core/testing'; | ||
import { UsersPageComponent } from './users-page.component'; | ||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { Router } from '@angular/router'; | ||
import { AppApiService } from '@event-participation-trends/app/api'; | ||
import { IGetUsersResponse, Status } from '@event-participation-trends/api/user/util'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
describe('UsersPageComponent', () => { | ||
let component: UsersPageComponent; | ||
let fixture: ComponentFixture<UsersPageComponent>; | ||
let httpTestingController: HttpTestingController; | ||
let router: Router; | ||
let appApiService: AppApiService; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [UsersPageComponent], | ||
imports: [UsersPageComponent, HttpClientTestingModule, RouterTestingModule], | ||
providers: [ | ||
AppApiService | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UsersPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
|
||
httpTestingController = TestBed.inject(HttpTestingController); | ||
router = TestBed.inject(Router); | ||
appApiService = TestBed.inject(AppApiService); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should return user\'s full name', () => { | ||
const user = { | ||
FirstName: 'John', | ||
LastName: 'Doe' | ||
}; | ||
|
||
expect(component.getName(user)).toEqual('John Doe'); | ||
}); | ||
|
||
it('should call updateRole when clicking SetViewer', () => { | ||
const user = { | ||
FirstName: 'John', | ||
LastName: 'Doe', | ||
Role: 'manager' | ||
}; | ||
|
||
jest.spyOn(component, 'updateRole'); | ||
component.setViewer(user); | ||
expect(component.updateRole).toHaveBeenCalledWith({...user, Role: 'viewer'}); | ||
}); | ||
|
||
it('should call updateRole when clicking SetManager', () => { | ||
const user = { | ||
FirstName: 'John', | ||
LastName: 'Doe', | ||
Role: 'viewer' | ||
}; | ||
|
||
jest.spyOn(component, 'updateRole'); | ||
component.setManager(user); | ||
expect(component.updateRole).toHaveBeenCalledWith({...user, Role: 'manager'}); | ||
}); | ||
|
||
it('should make a call to UpdateUserRole', fakeAsync(() => { | ||
const response = { | ||
status: Status.SUCCESS | ||
}; | ||
|
||
const user = { | ||
FirstName: 'John', | ||
LastName: 'Doe', | ||
Role: 'viewer' | ||
}; | ||
|
||
component.updateRole(user); | ||
|
||
const req = httpTestingController.expectOne(`/api/user/updateUserRole`); | ||
expect(req.request.method).toEqual('POST'); | ||
|
||
req.flush(response); | ||
})); | ||
|
||
it('should return a list of users', fakeAsync(() => { | ||
const response = [ | ||
{ | ||
FirstName: 'John', | ||
LastName: 'Doe', | ||
Role: 'viewer', | ||
Email: '[email protected]' | ||
}, | ||
{ | ||
FirstName: 'Jane', | ||
LastName: 'Doe', | ||
Role: 'manager', | ||
Email: '[email protected]' | ||
} | ||
]; | ||
|
||
component.users = response; | ||
component.search = 'John'; | ||
|
||
expect(component.get_users()).toEqual([response[0]]); | ||
})); | ||
|
||
it('should set users array', () => { | ||
jest.spyOn(appApiService, 'getRole').mockResolvedValue('admin'); | ||
|
||
component.ngOnInit(); | ||
|
||
const endpoint = '/api/user/getAllUsers'; | ||
const httpClient: HttpClient = TestBed.inject(HttpClient); | ||
httpClient.get<IGetUsersResponse>(endpoint).subscribe((response) => { | ||
component.users = response.users; | ||
|
||
expect(component.users).toEqual(response.users); | ||
}); | ||
}); | ||
|
||
//tests for the resizing of the window | ||
it('should change ViewerText to V and ManagerText to M when the screen is small', () => { | ||
window.innerWidth = 500; | ||
window.dispatchEvent(new Event('resize')); | ||
|
||
expect(component.viewerText).toEqual('V'); | ||
expect(component.managerText).toEqual('M'); | ||
}); | ||
|
||
it('should set largeScreen to true when the screen is large', () => { | ||
window.innerWidth = 1024; | ||
window.dispatchEvent(new Event('resize')); | ||
|
||
expect(component.largeScreen).toEqual(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters