|
|
|
import { describe, it, expect } from '@jest/globals';
|
|
|
|
|
|
|
|
import { createOmdbProviderByApiKey } from '../src/integration/movies/omdb';
|
|
|
|
|
|
|
|
describe('createOmdbProvider', () => {
|
|
|
|
const apiKey = process.env['OMDB_API_KEY'];
|
|
|
|
if (!apiKey) {
|
|
|
|
throw new Error('Missing api key');
|
|
|
|
}
|
|
|
|
|
|
|
|
const client = createOmdbProviderByApiKey(apiKey);
|
|
|
|
it('returns correct data for tt10687116', async () => {
|
|
|
|
const result = await client.getMetadata('tt10687116');
|
|
|
|
expect(result).toMatchObject({
|
|
|
|
actors: ['Kid Cudi', 'Jessica Williams', 'Laura Harrier'],
|
|
|
|
awards: expect.any(String),
|
|
|
|
contentRating: 'TV-MA',
|
|
|
|
description: expect.any(String),
|
|
|
|
directors: ['Fletcher Moules'],
|
|
|
|
duration: 93,
|
|
|
|
dvdReleaseDate: '30 Sep 2022',
|
|
|
|
genres: ['Animation', 'Comedy', 'Music'],
|
|
|
|
imdbId: 'tt10687116',
|
|
|
|
posterUrl: expect.any(String),
|
|
|
|
productionCountries: ['United Kingdom', 'United States'],
|
|
|
|
productionYear: 2022,
|
|
|
|
ratings: expect.arrayContaining([
|
|
|
|
{
|
|
|
|
source: expect.any(String),
|
|
|
|
value: expect.any(String),
|
|
|
|
},
|
|
|
|
]),
|
|
|
|
releaseDate: '30 Sep 2022',
|
|
|
|
title: 'Entergalactic',
|
|
|
|
type: 'movie',
|
|
|
|
writers: ['Kid Cudi', 'Kenya Barris', 'Ian Edelman'],
|
|
|
|
});
|
|
|
|
}, 10_000);
|
|
|
|
|
|
|
|
it('returns undefined for non-existent id', async () => {
|
|
|
|
const result = await client.getMetadata('tt99999999999');
|
|
|
|
expect(result).toBeUndefined();
|
|
|
|
}, 10_000);
|
|
|
|
});
|