simplified testing code

main
Inga 🏳‍🌈 11 months ago
parent 97455f5437
commit 08840712af
  1. 25
      src/integration/movies/omdb/converters.spec.ts
  2. 14
      src/integration/movies/omdb/types.ts

@ -4,7 +4,7 @@ import { normalizeRawOmdbData } from './converters';
describe('normalizeRawOmdbData', () => { describe('normalizeRawOmdbData', () => {
it('normalizes data correctly for tt19500164 (online-release animation)', () => { it('normalizes data correctly for tt19500164 (online-release animation)', () => {
const rawOmdbData = { const result = normalizeRawOmdbData({
Title: 'Nimona', Title: 'Nimona',
Year: '2023', Year: '2023',
Rated: 'PG', Rated: 'PG',
@ -32,8 +32,7 @@ describe('normalizeRawOmdbData', () => {
BoxOffice: 'N/A', BoxOffice: 'N/A',
Production: 'N/A', Production: 'N/A',
Website: 'N/A', Website: 'N/A',
} as const; });
const result = normalizeRawOmdbData(rawOmdbData);
expect(result).toEqual({ expect(result).toEqual({
actors: ['Chloë Grace Moretz', 'Riz Ahmed', 'Eugene Lee Yang'], actors: ['Chloë Grace Moretz', 'Riz Ahmed', 'Eugene Lee Yang'],
awards: '2 nominations', awards: '2 nominations',
@ -60,7 +59,7 @@ describe('normalizeRawOmdbData', () => {
}); });
it('normalizes data correctly for tt10482560 (series)', () => { it('normalizes data correctly for tt10482560 (series)', () => {
const rawOmdbData = { const result = normalizeRawOmdbData({
Title: 'Kipo and the Age of Wonderbeasts', Title: 'Kipo and the Age of Wonderbeasts',
Year: '2020', Year: '2020',
Rated: 'TV-Y7', Rated: 'TV-Y7',
@ -82,8 +81,7 @@ describe('normalizeRawOmdbData', () => {
imdbID: 'tt10482560', imdbID: 'tt10482560',
Type: 'series', Type: 'series',
totalSeasons: '3', totalSeasons: '3',
} as const; });
const result = normalizeRawOmdbData(rawOmdbData);
expect(result).toEqual({ expect(result).toEqual({
actors: ['Karen Fukuhara', 'Sydney Mikayla', 'Dee Bradley Baker'], actors: ['Karen Fukuhara', 'Sydney Mikayla', 'Dee Bradley Baker'],
awards: '3 nominations', awards: '3 nominations',
@ -107,7 +105,7 @@ describe('normalizeRawOmdbData', () => {
}); });
it('normalizes data correctly for tt5580266 (cinema-release movie)', () => { it('normalizes data correctly for tt5580266 (cinema-release movie)', () => {
const rawOmdbData = { const result = normalizeRawOmdbData({
Title: 'The Hate U Give', Title: 'The Hate U Give',
Year: '2018', Year: '2018',
Rated: 'PG-13', Rated: 'PG-13',
@ -136,8 +134,7 @@ describe('normalizeRawOmdbData', () => {
BoxOffice: '$29,719,483', BoxOffice: '$29,719,483',
Production: 'N/A', Production: 'N/A',
Website: 'N/A', Website: 'N/A',
} as const; });
const result = normalizeRawOmdbData(rawOmdbData);
expect(result).toEqual({ expect(result).toEqual({
actors: ['Amandla Stenberg', 'Regina Hall', 'Russell Hornsby'], actors: ['Amandla Stenberg', 'Regina Hall', 'Russell Hornsby'],
awards: '22 wins & 38 nominations', awards: '22 wins & 38 nominations',
@ -167,7 +164,7 @@ describe('normalizeRawOmdbData', () => {
}); });
it('normalizes data correctly for tt1508328 (foreign release)', () => { it('normalizes data correctly for tt1508328 (foreign release)', () => {
const rawOmdbData = { const result = normalizeRawOmdbData({
Title: 'Pumzi', Title: 'Pumzi',
Year: '2009', Year: '2009',
Rated: 'N/A', Rated: 'N/A',
@ -192,8 +189,7 @@ describe('normalizeRawOmdbData', () => {
BoxOffice: 'N/A', BoxOffice: 'N/A',
Production: 'N/A', Production: 'N/A',
Website: 'N/A', Website: 'N/A',
} as const; });
const result = normalizeRawOmdbData(rawOmdbData);
expect(result).toEqual({ expect(result).toEqual({
actors: ['Kudzani Moswela', 'Chantelle Burger', 'Tammy Richards'], actors: ['Kudzani Moswela', 'Chantelle Burger', 'Tammy Richards'],
awards: '3 wins & 2 nominations', awards: '3 wins & 2 nominations',
@ -216,7 +212,7 @@ describe('normalizeRawOmdbData', () => {
}); });
it('normalizes data correctly for tt7224520 (local release)', () => { it('normalizes data correctly for tt7224520 (local release)', () => {
const rawOmdbData = { const result = normalizeRawOmdbData({
Title: 'Ever After', Title: 'Ever After',
Year: '2018', Year: '2018',
Rated: 'Not Rated', Rated: 'Not Rated',
@ -245,8 +241,7 @@ describe('normalizeRawOmdbData', () => {
BoxOffice: 'N/A', BoxOffice: 'N/A',
Production: 'N/A', Production: 'N/A',
Website: 'N/A', Website: 'N/A',
} as const; });
const result = normalizeRawOmdbData(rawOmdbData);
expect(result).toEqual({ expect(result).toEqual({
actors: ['Gro Swantje Kohlhof', 'Maja Lehrer', 'Trine Dyrholm'], actors: ['Gro Swantje Kohlhof', 'Maja Lehrer', 'Trine Dyrholm'],
awards: '3 nominations', awards: '3 nominations',

@ -1,4 +1,4 @@
export type RawOmdbData = Readonly<{ export type RawOmdbData = {
Actors: string; Actors: string;
Awards: string; Awards: string;
BoxOffice?: string; BoxOffice?: string;
@ -12,12 +12,10 @@ export type RawOmdbData = Readonly<{
Poster: string; Poster: string;
Production?: string; Production?: string;
Rated: string; Rated: string;
Ratings: Readonly< Ratings: {
{ Source: string;
Source: string; Value: string;
Value: string; }[];
}[]
>;
Released: string; Released: string;
Runtime: string; Runtime: string;
Title: string; Title: string;
@ -29,7 +27,7 @@ export type RawOmdbData = Readonly<{
imdbRating: string; imdbRating: string;
imdbVotes: string; imdbVotes: string;
totalSeasons?: string; totalSeasons?: string;
}>; };
export type OmdbResponse = export type OmdbResponse =
| { | {

Loading…
Cancel
Save