Small Nest.js-based project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
test-assignment-joyn/test/omdbApiClient.e2e-spec.ts

47 lines
1.8 KiB

import { describe, it, expect } from '@jest/globals';
import { createOmdbApiClient } from '../src/integration/movies/omdb/apiClient';
describe('createOmdbApiClient', () => {
const apiKey = process.env['OMDB_API_KEY'];
if (!apiKey) {
throw new Error('Missing api key');
}
const client = createOmdbApiClient(apiKey);
11 months ago
it('returns some data for tt11873472', async () => {
const result = await client.fetchMetadata('tt11873472');
expect(result).toMatchObject({
Actors: 'Cheryl Isheja, Elvis Ngabo, Diogène Ntarindwa',
Awards: expect.any(String),
BoxOffice: expect.any(String),
Country: 'Rwanda, France, Canada, United Kingdom, United States',
DVD: expect.any(String),
Director: 'Anisia Uzeyman, Saul Williams',
Genre: 'Musical, Sci-Fi',
Language: 'Kinyarwanda, Kirundi, Swahili, French, English',
Metascore: expect.stringMatching(/^\d+$/),
Plot: expect.any(String),
Poster: expect.stringMatching(/^http/),
Production: expect.any(String),
Rated: expect.any(String),
Ratings: expect.any(Array),
Released: '10 May 2023',
Runtime: '105 min',
Title: 'Neptune Frost',
Type: 'movie',
Website: expect.any(String),
Writer: 'Saul Williams',
Year: '2021',
imdbID: 'tt11873472',
imdbRating: expect.stringMatching(/^\d?\d(\.\d)?$/),
imdbVotes: expect.stringMatching(/^\d+$/),
});
}, 10_000);
11 months ago
it('returns undefined for non-existent id', async () => {
const result = await client.fetchMetadata('tt99999999999');
expect(result).toBeUndefined();
}, 10_000);
});