Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4f9c47cc09
@ -5,11 +5,11 @@ import {MatSnackBar} from '@angular/material/snack-bar';
|
|||||||
import {NGXLogger} from 'ngx-logger';
|
import {NGXLogger} from 'ngx-logger';
|
||||||
import {MatDialog} from '@angular/material/dialog';
|
import {MatDialog} from '@angular/material/dialog';
|
||||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||||
import {FeedService} from "../../services/feed.service";
|
import {FeedService} from '../../services/feed.service';
|
||||||
import {Observable} from "rxjs";
|
import {Observable} from 'rxjs';
|
||||||
import {IFeed} from "../../interfaces/feed.interface";
|
import {IFeed} from '../../interfaces/feed.interface';
|
||||||
import {Tweet} from "../../interfaces/interface";
|
import {Tweet} from '../../interfaces/interface';
|
||||||
import {By} from "@angular/platform-browser";
|
import {By} from '@angular/platform-browser';
|
||||||
|
|
||||||
|
|
||||||
class MockSnackBar {
|
class MockSnackBar {
|
||||||
@ -23,16 +23,14 @@ class MockNGXLogger {
|
|||||||
|
|
||||||
// Fake Feed Service
|
// Fake Feed Service
|
||||||
export class MockFeedService {
|
export class MockFeedService {
|
||||||
|
|
||||||
getFeeds(): Observable<IFeed[]> {
|
getFeeds(): Observable<IFeed[]> {
|
||||||
return new Observable<IFeed[]>();
|
return new Observable<IFeed[]>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mockFillTweets() {
|
export function mockFillTweets() {
|
||||||
|
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
const tweet: Tweet = {tweet_id: i, created_date: null, text: "Mock", url: "Mock", icon: null}
|
const tweet: Tweet = {tweet_id: i, created_date: null, text: 'Mock', url: 'Mock', icon: null};
|
||||||
this.tweets.push(tweet);
|
this.tweets.push(tweet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,40 +67,28 @@ describe('Component: Tweets', () => {
|
|||||||
expect(component).toBeDefined();
|
expect(component).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Show text if feeds are empty', () => {
|
it('Show text if feeds are empty', () => {
|
||||||
expect(fixture.debugElement.query(By.css('.feeds'))).toBeDefined();
|
expect(fixture.debugElement.query(By.css('.feeds'))).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Do not show text if feeds are filled', () => {
|
it('Do not show text if feeds are filled', () => {
|
||||||
|
const feed: IFeed = {active: true, icon: null, id: 1, keywords: null, match_all_keywords: 'false', url: ''};
|
||||||
const feed: IFeed = {active: true, icon: null, id: 1, keywords: null, match_all_keywords: "false", url: ""};
|
|
||||||
component.feeds.push(feed);
|
component.feeds.push(feed);
|
||||||
|
|
||||||
expect(fixture.debugElement.query(By.css('.feeds'))).toBeNull();
|
expect(fixture.debugElement.query(By.css('.feeds'))).toBeNull();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('initial Tweets empty', () => {
|
it('initial Tweets empty', () => {
|
||||||
|
|
||||||
expect(component.tweets.length).toEqual(0);
|
expect(component.tweets.length).toEqual(0);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Show text if tweets are empty', () => {
|
it('Show text if tweets are empty', () => {
|
||||||
expect(fixture.debugElement.query(By.css('.tweets'))).toBeDefined();
|
expect(fixture.debugElement.query(By.css('.tweets'))).toBeDefined();
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
it('Do not show text if tweets are filled', () => {
|
|
||||||
|
|
||||||
component.fillTweets();
|
|
||||||
expect(fixture.debugElement.query(By.css('.tweets'))).toBeNull();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Do not show text if tweets are filled', () => {
|
||||||
|
component.fillTweets();
|
||||||
|
expect(fixture.debugElement.query(By.css('.tweets'))).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('load initial six Tweets works', () => {
|
it('load initial six Tweets works', () => {
|
||||||
component.fillTweets();
|
component.fillTweets();
|
||||||
@ -110,21 +96,15 @@ describe('Component: Tweets', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('load more Tweets works', () => {
|
it('load more Tweets works', () => {
|
||||||
|
|
||||||
component.fillTweets();
|
component.fillTweets();
|
||||||
component.loadMore();
|
component.loadMore();
|
||||||
expect(component.tweets.length).toEqual(12);
|
expect(component.tweets.length).toEqual(12);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('load more Tweets twice works', () => {
|
it('load more Tweets twice works', () => {
|
||||||
|
component.fillTweets();
|
||||||
component.fillTweets()
|
|
||||||
component.loadMore();
|
component.loadMore();
|
||||||
component.loadMore();
|
component.loadMore();
|
||||||
expect(component.tweets.length).toEqual(18);
|
expect(component.tweets.length).toEqual(18);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user