-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(IconButton): now with integration tests
ISSUES CLOSED: #1284
- Loading branch information
1 parent
23298fc
commit 1ab6e85
Showing
2 changed files
with
34 additions
and
16 deletions.
There are no files selected for viewing
48 changes: 33 additions & 15 deletions
48
terminus-ui/icon-button/src/icon-button.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,32 +1,50 @@ | ||
import { ElementRef } from '@angular/core'; | ||
import { ElementRefMock } from '@terminus/ngx-tools/testing'; | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { ComponentFixture } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { createComponent } from '@terminus/ngx-tools/testing'; | ||
|
||
import { TsIconButtonComponent } from './icon-button.component'; | ||
import { TsIconButtonModule } from './icon-button.module'; | ||
|
||
|
||
@Component({ | ||
template: ` | ||
<ts-icon-button | ||
actionName="Menu" | ||
buttonType="button" | ||
isDisabled="false" | ||
(clickEvent)="clickEvent($event)" | ||
>delete_forever</ts-icon-button> | ||
`, | ||
}) | ||
class TestHostComponent { | ||
|
||
@ViewChild(TsIconButtonComponent) | ||
iconButtonComponent: TsIconButtonComponent; | ||
} | ||
|
||
|
||
describe(`TsIconButtonComponent`, function() { | ||
let elRefMock: ElementRef; | ||
let component: TsIconButtonComponent; | ||
let component: TestHostComponent; | ||
let fixture: ComponentFixture<TestHostComponent>; | ||
let iconButton: HTMLElement; | ||
|
||
beforeEach(() => { | ||
elRefMock = new ElementRefMock(); | ||
component = new TsIconButtonComponent( | ||
elRefMock, | ||
); | ||
fixture = createComponent(TestHostComponent, [], [TsIconButtonModule]); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
iconButton = fixture.debugElement.query(By.css('.c-icon-button ')).nativeElement as HTMLElement; | ||
}); | ||
|
||
|
||
test(`should exist`, () => { | ||
expect(component).toBeTruthy(); | ||
expect(iconButton).toBeTruthy(); | ||
}); | ||
|
||
|
||
describe(`get hostElement`, () => { | ||
|
||
test(`should return the native element`, () => { | ||
expect(component.hostElement).toEqual(elRefMock.nativeElement); | ||
}); | ||
|
||
test(`should contain icon`, () => { | ||
expect(iconButton.children[0].textContent).toContain('delete_forever'); | ||
}); | ||
|
||
}); |
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