-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #946 from shreyanshdwivedi/feedLinker
Adds tests for feed-linker and feed-footer component
- Loading branch information
Showing
2 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
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,9 +1,58 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import { FeedFooterComponent } from './feed-footer.component'; | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
describe('Component: FeedFooter', () => { | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
FeedFooterComponent | ||
] | ||
}); | ||
}); | ||
|
||
it('should create an instance', () => { | ||
const component = new FeedFooterComponent(); | ||
const fixture = TestBed.createComponent(FeedFooterComponent); | ||
const component = fixture.debugElement.componentInstance; | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should sort apiResponseTags on ngOninit()', async(() => { | ||
const fixture = TestBed.createComponent(FeedFooterComponent); | ||
const component = fixture.debugElement.componentInstance; | ||
|
||
component.apiResponseTags = [ | ||
{ | ||
tag : 'tag1', | ||
count : 10 | ||
}, | ||
{ | ||
tag : 'tag2', | ||
count : 5 | ||
}, | ||
{ | ||
tag : 'tag3', | ||
count : 5 | ||
}, | ||
{ | ||
tag : 'tag0', | ||
count : 10 | ||
}, | ||
{ | ||
tag : 'tag1', | ||
count : 10 | ||
}, | ||
]; | ||
component.ngOnInit(); | ||
expect(component.sortedApiResponseTags[0].tag).toBe('tag2'); | ||
expect(component.sortedApiResponseTags[1].tag).toBe('tag3'); | ||
expect(component.sortedApiResponseTags[2].tag).toBe('tag0'); | ||
expect(component.sortedApiResponseTags[3].tag).toBe('tag1'); | ||
expect(component.sortedApiResponseTags[4].tag).toBe('tag1'); | ||
})); | ||
}); |
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,9 +1,55 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import { FeedLinkerComponent } from './feed-linker.component'; | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
describe('Component: FeedLinker', () => { | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
FeedLinkerComponent | ||
] | ||
}); | ||
}); | ||
|
||
it('should create an instance', () => { | ||
const component = new FeedLinkerComponent(); | ||
const fixture = TestBed.createComponent(FeedLinkerComponent); | ||
const component = fixture.debugElement.componentInstance; | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should call generateAllShards() when useAll is true', async(() => { | ||
const fixture = TestBed.createComponent(FeedLinkerComponent); | ||
const component = fixture.debugElement.componentInstance; | ||
|
||
component.useAll = true; | ||
component.text = 'loklak @fossasia #loklak http://loklak.org/'; | ||
component.ngOnInit(); | ||
expect(component.shardArray.length).toBe(4); | ||
})); | ||
|
||
it('should call generateShards() when useAll is false', async(() => { | ||
const fixture = TestBed.createComponent(FeedLinkerComponent); | ||
const component = fixture.debugElement.componentInstance; | ||
|
||
component.useAll = false; | ||
component.hashtags = [ | ||
'FOSSASIA', | ||
'loklak' | ||
]; | ||
component.mentions = [ | ||
'loklak' | ||
]; | ||
component.links = [ | ||
'http://loklak.org/', | ||
'https://github.com/fossasia/loklak_search' | ||
]; | ||
component.text = 'loklak @fossasia #loklak http://loklak.org/'; | ||
component.ngOnInit(); | ||
expect(component.shardArray.length).toBe(4); | ||
})); | ||
}); |