parent
449d95109e
commit
b8f3cac3fc
@ -0,0 +1,53 @@ |
|||||||
|
import { describe, it, expect } from '@jest/globals'; |
||||||
|
|
||||||
|
import { createLocalMoviesClient } from './local'; |
||||||
|
|
||||||
|
describe('createLocalMoviesClient', () => { |
||||||
|
const client = createLocalMoviesClient(); |
||||||
|
|
||||||
|
it('returns data for internal movie id', async () => { |
||||||
|
const result = await client.getMovieMetadataByInternalId(11528860); |
||||||
|
expect(result).toMatchObject({ |
||||||
|
description: expect.any(String), |
||||||
|
duration: 75, |
||||||
|
id: 11528860, |
||||||
|
imdbId: 'tt0061852', |
||||||
|
languages: expect.any(Array), |
||||||
|
originalLanguage: 'en', |
||||||
|
productionYear: 1967, |
||||||
|
studios: ['Disney'], |
||||||
|
title: 'Das Dschungelbuch', |
||||||
|
userrating: { |
||||||
|
countStar1: expect.any(Number), |
||||||
|
countStar2: expect.any(Number), |
||||||
|
countStar3: expect.any(Number), |
||||||
|
countStar4: expect.any(Number), |
||||||
|
countStar5: expect.any(Number), |
||||||
|
countTotal: expect.any(Number), |
||||||
|
}, |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
it('returns data for imdb id', async () => { |
||||||
|
const result = await client.getMovieMetadataByImdbId('tt0061852'); |
||||||
|
expect(result).toMatchObject({ |
||||||
|
description: expect.any(String), |
||||||
|
duration: 75, |
||||||
|
id: 11528860, |
||||||
|
imdbId: 'tt0061852', |
||||||
|
languages: expect.any(Array), |
||||||
|
originalLanguage: 'en', |
||||||
|
productionYear: 1967, |
||||||
|
studios: ['Disney'], |
||||||
|
title: 'Das Dschungelbuch', |
||||||
|
userrating: { |
||||||
|
countStar1: expect.any(Number), |
||||||
|
countStar2: expect.any(Number), |
||||||
|
countStar3: expect.any(Number), |
||||||
|
countStar4: expect.any(Number), |
||||||
|
countStar5: expect.any(Number), |
||||||
|
countTotal: expect.any(Number), |
||||||
|
}, |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,13 @@ |
|||||||
|
import movie1 from '../../resources/movies/3532674.json'; |
||||||
|
import movie2 from '../../resources/movies/5979300.json'; |
||||||
|
import movie3 from '../../resources/movies/11043689.json'; |
||||||
|
import movie4 from '../../resources/movies/11528860.json'; |
||||||
|
|
||||||
|
const movies = [movie1, movie2, movie3, movie4]; |
||||||
|
|
||||||
|
export const createLocalMoviesClient = () => { |
||||||
|
return { |
||||||
|
getMovieMetadataByInternalId: async (internalId: number) => movies.find(({ id }) => id == internalId), |
||||||
|
getMovieMetadataByImdbId: async (id: string) => movies.find(({ imdbId }) => imdbId == id), |
||||||
|
}; |
||||||
|
}; |
Loading…
Reference in new issue