From 62dbe148c045fd858d9052485583380a4452daa9 Mon Sep 17 00:00:00 2001 From: Manuel Hude Date: Mon, 24 May 2021 15:24:43 +0200 Subject: [PATCH] added button tests --- .../app/component/tweets/tweets.component.html | 2 +- .../component/tweets/tweets.component.spec.ts | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/component/tweets/tweets.component.html b/frontend/src/app/component/tweets/tweets.component.html index 819d346..de9beeb 100644 --- a/frontend/src/app/component/tweets/tweets.component.html +++ b/frontend/src/app/component/tweets/tweets.component.html @@ -28,7 +28,7 @@
- +
diff --git a/frontend/src/app/component/tweets/tweets.component.spec.ts b/frontend/src/app/component/tweets/tweets.component.spec.ts index 1fdc45c..1e455a5 100644 --- a/frontend/src/app/component/tweets/tweets.component.spec.ts +++ b/frontend/src/app/component/tweets/tweets.component.spec.ts @@ -1,5 +1,5 @@ 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 {MatSnackBar} from '@angular/material/snack-bar'; import {NGXLogger} from 'ngx-logger'; @@ -107,4 +107,20 @@ describe('Component: Tweets', () => { component.loadMore(); 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(); + }); + }); + });