added button tests
This commit is contained in:
parent
5e73523237
commit
62dbe148c0
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<button (click)="loadMore()" mat-button color="primary">Mehr laden</button>
|
<button class="more" (click)="loadMore()" mat-button color="primary">Mehr laden</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import {TweetsComponent} from './tweets.component';
|
import {TweetsComponent} from './tweets.component';
|
||||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
|
||||||
import {HttpClient} from '@angular/common/http';
|
import {HttpClient} from '@angular/common/http';
|
||||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
import {MatSnackBar} from '@angular/material/snack-bar';
|
||||||
import {NGXLogger} from 'ngx-logger';
|
import {NGXLogger} from 'ngx-logger';
|
||||||
@ -107,4 +107,20 @@ describe('Component: Tweets', () => {
|
|||||||
component.loadMore();
|
component.loadMore();
|
||||||
expect(component.tweets.length).toEqual(18);
|
expect(component.tweets.length).toEqual(18);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('load more button visible', () => {
|
||||||
|
expect(expect(fixture.debugElement.query(By.css('.more'))).toBeDefined());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('load more being called after button press', () => {
|
||||||
|
fakeAsync(() => {
|
||||||
|
spyOn(component, 'loadMore');
|
||||||
|
|
||||||
|
const button = fixture.debugElement.nativeElement.querySelector('button');
|
||||||
|
button.click();
|
||||||
|
tick();
|
||||||
|
expect(component.loadMore).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user