-
Notifications
You must be signed in to change notification settings - Fork 1
TT-264 UI test coverage #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
e45d78d
9e70710
829bc65
0800fa8
3bbd8ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,6 @@ describe('ProjectListComponent', () => { | |
| getCustomerProjectsSelectorMock = store.overrideSelector(getCustomerProjects, state); | ||
| allCustomerProjectsSelectorMock = store.overrideSelector(getProjects, state.projects); | ||
| component.projectsSubscription = new Subscription(); | ||
| spyOn(component, 'getProjectTypeName').and.callFake((typeId: string) => 'BK'); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
|
|
@@ -86,10 +85,20 @@ describe('ProjectListComponent', () => { | |
| it('should destroy the subscriptions', () => { | ||
| component.projectsSubscription = new Subscription(); | ||
| const subscription = spyOn(component.projectsSubscription, 'unsubscribe'); | ||
|
|
||
| component.ngOnDestroy(); | ||
|
|
||
| expect(subscription).toHaveBeenCalledTimes(1); | ||
|
|
||
| }); | ||
|
|
||
| it('should destroy the projectTypesSubscription', () => { | ||
| component.projectTypesSubscription = new Subscription(); | ||
| const subscriptionProjectTypes = spyOn(component.projectTypesSubscription, 'unsubscribe'); | ||
|
|
||
| component.ngOnDestroy(); | ||
|
|
||
| expect(subscriptionProjectTypes).toHaveBeenCalledTimes(1); | ||
|
|
||
|
||
| }); | ||
|
|
||
| it('updateProject, should dispatch SetProjectToEdit action', () => { | ||
|
|
@@ -98,7 +107,6 @@ describe('ProjectListComponent', () => { | |
| const subscription = spyOn(component.projectsSubscription, 'unsubscribe'); | ||
|
|
||
| component.updateProject(project); | ||
|
|
||
| component.ngOnDestroy(); | ||
|
|
||
| expect(subscription).toHaveBeenCalledTimes(1); | ||
|
|
@@ -136,6 +144,7 @@ describe('ProjectListComponent', () => { | |
| spyOn(component, 'openModal'); | ||
| component.switchStatus(itemData); | ||
| expect(component.openModal).toHaveBeenCalled(); | ||
|
|
||
|
||
| }); | ||
|
|
||
| it('switchStatus should set showModal false when item.status = inactive', () => { | ||
|
|
@@ -156,28 +165,23 @@ describe('ProjectListComponent', () => { | |
| expect(component.showModal).toBeFalse(); | ||
| }); | ||
|
|
||
| it('projects table should display Project Type', (done) => { | ||
| const projectType = { | ||
| id: '1234', | ||
| name: 'BK', | ||
| description: 'test', | ||
| it('openModal should set showModal true when item.key !== inactive', () => { | ||
| const itemData = { | ||
| id: '123', | ||
| name: 'aaa', | ||
| description: 'xxx', | ||
| project_type_id: '1234', | ||
| status: 'activate', | ||
| key: 'activate', | ||
| _status: false, | ||
| btnColor: 'btn-danger', | ||
| btnIcon: 'fa-arrow-circle-down', | ||
| btnName: 'Archive', | ||
| }; | ||
|
|
||
| component.projectsTypes = [projectType]; | ||
| fixture.detectChanges(); | ||
| fixture.whenStable().then(() => { | ||
| fixture.detectChanges(); | ||
|
|
||
| const tableRows = fixture.nativeElement.querySelectorAll('tr'); | ||
| expect(tableRows.length).toBe(2); | ||
| component.openModal(itemData); | ||
|
|
||
| const headerRow = tableRows[0]; | ||
| expect(headerRow.cells[2].innerHTML).toBe('Project Type'); | ||
|
|
||
| const dataRow = tableRows[1]; | ||
| expect(dataRow.cells[2].innerHTML).toBe('BK'); | ||
|
|
||
| done(); | ||
| }); | ||
| expect(component.idToDelete).toEqual(itemData.id); | ||
| expect(component.showModal).toBeTrue(); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { TestBed, inject } from '@angular/core/testing'; | ||
| import { UserService } from './user.service'; | ||
| import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; | ||
|
|
||
|
|
||
|
||
| describe('UserService', () => { | ||
| let service: UserService; | ||
| let httpMock: HttpTestingController; | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [HttpClientTestingModule] | ||
| }); | ||
| service = TestBed.inject(UserService); | ||
| httpMock = TestBed.inject(HttpTestingController); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| httpMock.verify(); | ||
| }); | ||
|
|
||
| it('should create', inject( | ||
| [HttpClientTestingModule, UserService], | ||
| (httpClient: HttpClientTestingModule, apiService: UserService) => { | ||
| expect(apiService).toBeTruthy(); | ||
| expect(httpClient).toBeTruthy(); | ||
| } | ||
| )); | ||
|
|
||
| it('load a user to idUser using GET', () => { | ||
| service.baseUrl = '/users'; | ||
| service.loadUser('xyz').subscribe(); | ||
|
|
||
| const loadUserRequest = httpMock.expectOne(`${service.baseUrl}/xyz`); | ||
| expect(loadUserRequest.request.method).toBe('GET'); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dete this line white