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.
 

41 lines
1.6 KiB

import { describe, it, expect } from '@jest/globals';
import { createOmdbApiClient } from './apiClient';
describe('createOmdbApiClient', () => {
const client = createOmdbApiClient('68fd98ab');
it('returns some data for the sample movie id', 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);
it('returns undefined for non-existend movie id', async () => {
const result = await client.fetchMetadata('tt99999999999');
expect(result).toBeUndefined();
}, 10_000);
});