]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/recommendations/recommended-videos.store.spec.ts
Check follow constraints when getting a video
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / recommendations / recommended-videos.store.spec.ts
1 import { RecommendedVideosStore } from '@app/videos/recommendations/recommended-videos.store'
2 import { RecommendationService } from '@app/videos/recommendations/recommendations.service'
3
4 describe('RecommendedVideosStore', () => {
5 describe('requestNewRecommendations', () => {
6 let store: RecommendedVideosStore
7 let service: RecommendationService
8 beforeEach(() => {
9 service = {
10 getRecommendations: jest.fn(() => new Promise((r) => r()))
11 }
12 store = new RecommendedVideosStore(service)
13 })
14 it('should pull new videos from the service one time when given the same UUID twice', () => {
15 store.requestNewRecommendations('some-uuid')
16 store.requestNewRecommendations('some-uuid')
17 // Requests aren't fulfilled until someone asks for them (ie: subscribes)
18 store.recommendations$.subscribe()
19 expect(service.getRecommendations).toHaveBeenCalledTimes(1)
20 })
21 })
22 })