Last change
on this file since f33b0d4 was 30a465f, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[30a465f] | 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
---|
| 2 |
|
---|
| 3 | import { CounterComponent } from './counter.component';
|
---|
| 4 |
|
---|
| 5 | describe('CounterComponent', () => {
|
---|
| 6 | let component: CounterComponent;
|
---|
| 7 | let fixture: ComponentFixture<CounterComponent>;
|
---|
| 8 |
|
---|
| 9 | beforeEach(async(() => {
|
---|
| 10 | TestBed.configureTestingModule({
|
---|
| 11 | declarations: [ CounterComponent ]
|
---|
| 12 | })
|
---|
| 13 | .compileComponents();
|
---|
| 14 | }));
|
---|
| 15 |
|
---|
| 16 | beforeEach(() => {
|
---|
| 17 | fixture = TestBed.createComponent(CounterComponent);
|
---|
| 18 | component = fixture.componentInstance;
|
---|
| 19 | fixture.detectChanges();
|
---|
| 20 | });
|
---|
| 21 |
|
---|
| 22 | it('should display a title', async(() => {
|
---|
| 23 | const titleText = fixture.nativeElement.querySelector('h1').textContent;
|
---|
| 24 | expect(titleText).toEqual('Counter');
|
---|
| 25 | }));
|
---|
| 26 |
|
---|
| 27 | it('should start with count 0, then increments by 1 when clicked', async(() => {
|
---|
| 28 | const countElement = fixture.nativeElement.querySelector('strong');
|
---|
| 29 | expect(countElement.textContent).toEqual('0');
|
---|
| 30 |
|
---|
| 31 | const incrementButton = fixture.nativeElement.querySelector('button');
|
---|
| 32 | incrementButton.click();
|
---|
| 33 | fixture.detectChanges();
|
---|
| 34 | expect(countElement.textContent).toEqual('1');
|
---|
| 35 | }));
|
---|
| 36 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.