-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b864eb
commit 1786962
Showing
15 changed files
with
255 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,11 +1,9 @@ | ||
import { FooterComponent } from './footer'; | ||
import { HeaderComponent } from './header'; | ||
import { SermonListComponent } from './sermon-list'; | ||
import { UStreamComponent } from './ustream'; | ||
|
||
export const ORGANISMS = [ | ||
FooterComponent, | ||
HeaderComponent, | ||
SermonListComponent, | ||
UStreamComponent | ||
SermonListComponent | ||
]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { expect, sinon, async, MockBuilder, callCount } from 'testing'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { SermonComponent } from './sermon'; | ||
import { | ||
Analytics, | ||
FeatureToggles, | ||
Observable, | ||
SeriesImageService, | ||
Sermon, | ||
SermonService, | ||
VideoState, | ||
YoutubeService | ||
} from 'app/services'; | ||
|
||
describe('SermonComponent', () => { | ||
|
||
describe('ngOnInit', () => { | ||
|
||
it('should subscribe to video state changes', async(() => { | ||
const youtubeService = MockBuilder.of(YoutubeService) | ||
.withStub('videoState', Observable.of(VideoState.BUFFERING)) | ||
.build(); | ||
|
||
const activatedRoute = MockBuilder.of(ActivatedRoute) | ||
.with('params', Observable.empty()) | ||
.build(); | ||
|
||
const sermon = new SermonComponent(activatedRoute, null, null, null, null, null, youtubeService); | ||
|
||
sermon.ngOnInit(); | ||
|
||
expect(youtubeService.videoState).to.have.been.calledOnce.and.calledWith('sermonVideo'); | ||
expect(sermon.videoState).to.equal(VideoState.BUFFERING); | ||
|
||
sermon.ngOnDestroy(); | ||
})); | ||
|
||
it('should register analytics events on an appropriate cadence', async(() => { | ||
const youtubeService = MockBuilder.of(YoutubeService) | ||
.withStub('videoState', Observable.empty()) | ||
.build(); | ||
|
||
const activatedRoute = MockBuilder.of(ActivatedRoute) | ||
.with('params', Observable.empty()) | ||
.build(); | ||
|
||
const analytics = MockBuilder.of(Analytics) | ||
.withSpy('event') | ||
.build(); | ||
|
||
const sermon = new SermonComponent(activatedRoute, analytics, null, null, null, null, youtubeService); | ||
sermon.analyticsInterval = 5; | ||
sermon.videoState = VideoState.PLAYING; | ||
sermon.sermon = { youtube: 'Jesus4Life' } as Sermon; | ||
|
||
sermon.ngOnInit(); | ||
|
||
window.setTimeout(() => { | ||
/* Giving a reasonable range to account for annoying time based testing */ | ||
expect(callCount(analytics.event)).to.be.at.least(2).and.at.most(6); | ||
expect(analytics.event).to.have.been.calledWith('Sermon', 'Playing', 'Jesus4Life'); | ||
sermon.ngOnDestroy(); | ||
}, 25); | ||
})); | ||
|
||
it('should register live analytics events as appropriate', async(() => { | ||
const youtubeService = MockBuilder.of(YoutubeService) | ||
.withStub('videoState', Observable.empty()) | ||
.build(); | ||
|
||
const activatedRoute = MockBuilder.of(ActivatedRoute) | ||
.with('params', Observable.empty()) | ||
.build(); | ||
|
||
const analytics = MockBuilder.of(Analytics) | ||
.withSpy('event') | ||
.build(); | ||
|
||
const sermon = new SermonComponent(activatedRoute, analytics, null, null, null, null, youtubeService); | ||
sermon.analyticsInterval = 5; | ||
sermon.videoState = VideoState.PLAYING; | ||
sermon.live = true; | ||
sermon.sermon = { youtube: 'Jesus4Life' } as Sermon; | ||
|
||
sermon.ngOnInit(); | ||
|
||
window.setTimeout(() => { | ||
expect(analytics.event).to.have.been.calledWith('Live Sermon', 'Playing', 'Jesus4Life'); | ||
sermon.ngOnDestroy(); | ||
}, 25); | ||
})); | ||
|
||
[ | ||
VideoState.BUFFERING, | ||
VideoState.CUED, | ||
VideoState.ENDED, | ||
VideoState.PAUSED, | ||
VideoState.UNSTARTED | ||
].forEach(state => { | ||
it(`should not call analytics when video state is "${state}"`, async(() => { | ||
const youtubeService = MockBuilder.of(YoutubeService) | ||
.withStub('videoState', Observable.empty()) | ||
.build(); | ||
|
||
const activatedRoute = MockBuilder.of(ActivatedRoute) | ||
.with('params', Observable.empty()) | ||
.build(); | ||
|
||
const analytics = MockBuilder.of(Analytics) | ||
.withSpy('event') | ||
.build(); | ||
|
||
const sermon = new SermonComponent(activatedRoute, analytics, null, null, null, null, youtubeService); | ||
sermon.analyticsInterval = 5; | ||
sermon.videoState = state; | ||
sermon.sermon = { youtube: 'Jesus4Life' } as Sermon; | ||
|
||
sermon.ngOnInit(); | ||
|
||
window.setTimeout(() => { | ||
expect(analytics.event).to.not.have.been.called; | ||
sermon.ngOnDestroy(); | ||
}, 25); | ||
})); | ||
}); | ||
|
||
|
||
|
||
|
||
}); | ||
|
||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expect, sinon, async, MockBuilder, Loop } from 'testing'; | ||
import { Autoclean } from './autoclean'; | ||
import { Subscription } from 'app/services'; | ||
|
||
class TestableAutoclean extends Autoclean {} | ||
|
||
describe('Autoclean', () => { | ||
|
||
it('should clean up registered subscriptions', () => { | ||
const ac = new TestableAutoclean(); | ||
const subscription = MockBuilder.of(Subscription) | ||
.withSpy('unsubscribe') | ||
.build(); | ||
|
||
Loop.times(10).do(() => ac.autoclean(subscription)); | ||
|
||
ac.ngOnDestroy(); | ||
|
||
expect(subscription.unsubscribe).to.have.callCount(10); | ||
}); | ||
|
||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { expect, sinon, async, MockBuilder } from 'testing'; | ||
import { Router } from '@angular/router'; | ||
import { ServiceGroup } from './service-group'; | ||
import { | ||
Analytics, | ||
ConnectionRequest, | ||
ConnectionService, | ||
Observable | ||
} from '../../services'; | ||
|
||
class TestableServiceGroup extends ServiceGroup {} | ||
|
||
describe('ServiceGroup', () => { | ||
|
||
describe('constructor', () => { | ||
it('should work', () => { | ||
const sg = new TestableServiceGroup( | ||
undefined, | ||
undefined, | ||
undefined, | ||
'hero', | ||
'title', | ||
'sub', | ||
[ 'it does this', 'and this' ], | ||
{ | ||
a: { name : 'Eh', description: 'Aye' }, | ||
b: { name: 'Bee', description: 'Honey' } | ||
} | ||
); | ||
|
||
expect(sg).to.exist; | ||
expect(sg.typeKeys).to.have.lengthOf(2); | ||
expect(sg.typesArray).to.have.lengthOf(2); | ||
}); | ||
}); | ||
|
||
describe('submit', () => { | ||
it('should submit exactly once', async(() => { | ||
const service = MockBuilder.of(ConnectionService) | ||
.withStub('submit', Observable.of('')) | ||
.build(); | ||
|
||
const analytics = MockBuilder.of(Analytics) | ||
.withStub('event', Observable.of('')) | ||
.build(); | ||
|
||
const router = MockBuilder.of(Router) | ||
.withSpy('navigate') | ||
.build(); | ||
|
||
const sg = new TestableServiceGroup( | ||
service, | ||
router, | ||
analytics, | ||
undefined, | ||
undefined, | ||
undefined, | ||
undefined, | ||
{} | ||
); | ||
|
||
sg.submit() | ||
.subscribe(() => { | ||
expect(service.submit).to.have.been.calledOnce; | ||
expect(analytics.event).to.have.been.calledOnce; | ||
expect(router.navigate).to.have.been.calledOnce.and.be.calledWith([ '/thank-you' ]); | ||
}); | ||
})); | ||
}); | ||
|
||
}); |
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
Oops, something went wrong.