This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for assignee component (#2801)
* Add unit tests for assignee components * update tests
- Loading branch information
1 parent
48e507e
commit 63d2406
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/app/components_ngrx/assignee/assignee.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { RouterModule } from '@angular/router'; | ||
import { BsDropdownConfig } from 'ngx-bootstrap/dropdown'; | ||
import { TooltipConfig, TooltipModule } from 'ngx-bootstrap/tooltip'; | ||
import { WidgetsModule } from 'ngx-widgets'; | ||
import { UserAvatarModule } from './../../widgets/user-avatar/user-avatar.module'; | ||
import { AssigneesComponent } from './assignee.component'; | ||
|
||
|
||
describe('AssigneeComponent', () => { | ||
let fixture: ComponentFixture<AssigneesComponent>, | ||
comp: AssigneesComponent; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
CommonModule, | ||
RouterModule, | ||
TooltipModule.forRoot(), | ||
UserAvatarModule, | ||
WidgetsModule | ||
], | ||
declarations: [ | ||
AssigneesComponent | ||
], | ||
providers: [ TooltipConfig, BsDropdownConfig ] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AssigneesComponent); | ||
comp = fixture.componentInstance; | ||
}); | ||
|
||
it('should create the app', async(() => { | ||
expect(comp).toBeTruthy(); | ||
})); | ||
|
||
it('should show Unassigned if assignees less than 1', async(() => { | ||
fixture.detectChanges(); | ||
comp.assigneeInput = []; | ||
comp.overlapAvatar = false; | ||
let assigneesDE = fixture.debugElement.query(By.css('small.dib')).nativeElement; | ||
expect(assigneesDE.innerText).toBe('Unassigned'); | ||
})); | ||
|
||
it('should truncate if assignees greater than 3', async(() => { | ||
comp.showFullName = false; | ||
comp.truncateAfter = 3; | ||
comp.assigneeInput = [ | ||
{'name': 'Name 1', avatar: 'https://avatars3.githubusercontent.com/u/34271052?v=4&s=25'}, | ||
{'name': 'Name 2', avatar: 'https://avatars3.githubusercontent.com/u/34271051?v=4&s=25'}, | ||
{'name': 'Name 3', avatar: 'https://avatars3.githubusercontent.com/u/34271053?v=4&s=25'}, | ||
{'name': 'Name 4', avatar: 'https://avatars3.githubusercontent.com/u/34271054?v=4&s=25'} | ||
]; | ||
|
||
fixture.detectChanges(); | ||
let assigneesDE = fixture.debugElement.query(By.css('.f8-assignees')).nativeElement; | ||
expect(assigneesDE.innerText).toContain('1+'); | ||
})); | ||
}); |