Skip to content

Commit

Permalink
Merge pull request #348 from steniowagner/feat/tv-show-details
Browse files Browse the repository at this point in the history
Feat/tv show details
  • Loading branch information
steniowagner authored Nov 28, 2023
2 parents dfe16fa + fd136ee commit 3ff675a
Show file tree
Hide file tree
Showing 72 changed files with 4,718 additions and 191 deletions.
1 change: 1 addition & 0 deletions __mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './quiz-questions';
export * from './trending-famous';
export * from './search';
export * from './famous-details';
export * from './tv-show-details';
293 changes: 293 additions & 0 deletions __mocks__/tv-show-details.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
import { GraphQLError } from 'graphql';

import { TV_SHOW_DETAILS_QUERY } from '@/components/stacks/common-screens/media-details/tv-show-details/screen/use-tv-show-detailts';
import { ISO6391Language } from '@/types/schema';

import { randomPositiveNumber } from './utils';

export const tvShow = {
genres: ['Sci-Fi & Fantasy', 'Drama', 'Action & Adventure'],
voteAverage: 8.436,
voteCount: 3519,
images: [
'/8Mrd6mUCfczEMIYEg8BeeT1mNuv.jpg',
'/lpdzTdAkspzmvrkKeTJoIjlPh16.jpg',
'/9RoQp7UFHE8yBGGatr8igTydw6O.jpg',
'/ywbHCgCYJAudhm0fwUC25J2WRz1.jpg',
'/s6LQdnexGmxf8fCQWuQQqurwelo.jpg',
'/iiIo1Vzow1Fqe2FUjQH3OweFVJ3.jpg',
'/fU4gOMXkR7wMeDCMMirn4zfiefC.jpg',
],
createdBy: [
{
image: '/1A7W0L9dZz0rCN1oj6h8YUvusdN.jpg',
name: 'George R. R. Martin',
id: 237053,
},
{
image: '/ohS1LQEw1aYccD6mxUhWGXc7glz.jpg',
name: 'Ryan Condal',
id: 1167458,
},
],
episodeRunTime: [50],
firstAirDate: '2022-08-21',
lastAirDate: '2022-10-23',
title: 'House of the Dragon',
id: 94997,
originalLanguage: 'en',
originalName: 'House of the Dragon',
originCountry: ['US'],
overview:
'The Targaryen dynasty is at the absolute apex of its power, with more than 15 dragons under their yoke. Most empires crumble from such heights. In the case of the Targaryens, their slow fall begins when King Viserys breaks with a century of tradition by naming his daughter Rhaenyra heir to the Iron Throne. But when Viserys later fathers a son, the court is shocked when Rhaenyra retains her status as his heir, and seeds of division sow friction across the realm.',
videos: [
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/TRhmCMkH7G4/default.jpg',
},
key: 'TRhmCMkH7G4',
id: '655ce7397f054018d5189097',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/dGuhZnm8OOU/default.jpg',
},
key: 'dGuhZnm8OOU',
id: '655ce745109230011b45ca5d',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/GYPenAJGVMs/default.jpg',
},
key: 'GYPenAJGVMs',
id: '655ce756ea84c710922b55a3',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/aoPsQgJgkgo/default.jpg',
},
key: 'aoPsQgJgkgo',
id: '648637a1028f1400aecef5f9',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/l9vfyN1LltY/default.jpg',
},
key: 'l9vfyN1LltY',
id: '630f4c4fbe55b70083c5e6ed',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/blHoET7H0TY/default.jpg',
},
key: 'blHoET7H0TY',
id: '62fe5b597cffda007e4e12d0',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/6BwpPql29a0/default.jpg',
},
key: '6BwpPql29a0',
id: '62f9f8a77eb5f2007bcd04d1',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/DotnJ7tTA34/default.jpg',
},
key: 'DotnJ7tTA34',
id: '62d838996f31af004d1f53f8',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/jwroDWGHwy4/default.jpg',
},
key: 'jwroDWGHwy4',
id: '62de09509f5dfb00556d891b',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/Wg86eQkdudI/default.jpg',
},
key: 'Wg86eQkdudI',
id: '6274010229c62639cd6f3cf2',
},
{
thumbnail: {
extraSmall: 'https://img.youtube.com/vi/fNwwt25mheo/default.jpg',
},
key: 'fNwwt25mheo',
id: '615c1d0ad1444300436234ae',
},
],
cast: [
{
image: '/ox47FvHmHMZet0TOoDSJlQol9Ir.jpg',
subText: 'Princess Rhaenyra Targaryen',
name: "Emma D'Arcy",
id: 2121005,
},
{
image: '/yZNcUEqmvDJQQ7avMfJfCh7sVk9.jpg',
subText: 'Alicent Hightower',
name: 'Olivia Cooke',
id: 1173984,
},
{
image: '/uIKOm4w2wtUegxratSHj2KPFF7i.jpg',
subText: 'King Viserys I Targaryen',
name: 'Paddy Considine',
id: 14887,
},
{
image: '/xr2GSp8Pm6fT5VGm0I9tsWVcZ8q.jpg',
subText: 'Prince Daemon Targaryen',
name: 'Matt Smith',
id: 136532,
},
{
image: '/g8EUs8r1ECh9plKtrxBparsxlZ1.jpg',
subText: 'Ser Otto Hightower',
name: 'Rhys Ifans',
id: 7026,
},
],
crew: [
{
image: null,
name: 'Richard Sharkey',
id: 1105636,
subText: 'Consulting Producer',
},
{
image: null,
name: 'Jim Clay',
id: 1253,
subText: 'Production Design',
},
{
image: null,
name: 'Tim Porter',
id: 1432103,
subText: 'Co-Producer',
},
{
image: '/wbT1bFGQAuqgVbXfQdlxWRBIqDD.jpg',
name: 'Kate Rhodes James',
id: 62257,
subText: 'Casting',
},
{
image: null,
name: 'Angus Bickerton',
id: 15883,
subText: 'Visual Effects Supervisor',
},
{
image: '/1G8TxAQnndnY5CLqVApBQ8RUT4A.jpg',
name: 'Jany Temime',
id: 11227,
subText: 'Costume Designer',
},
{
image: '/1A7W0L9dZz0rCN1oj6h8YUvusdN.jpg',
name: 'George R. R. Martin',
id: 237053,
subText: 'Book',
},
{
image: '/gof8bWW9E7MH30GpvA97PwGiIuu.jpg',
name: 'Kelly Reilly',
id: 17521,
subText: 'Acting Double',
},
],
similar: [
{
voteAverage: 7,
posterPath: '/b0HkkISlAxYZceH5RVAUCBcsryg.jpg',
voteCount: 1,
title: 'Fearless',
id: 289,
},
],
numberOfEpisodes: 10,
numberOfSeasons: 1,
};

type MockTVShowDetailsQueryResponseParams = {
includeVoteAverage: boolean;
includeGenres: boolean;
includeVoteCount: boolean;
id: number;
};

const baseMockTVShowDetailsQueryResponse = (
params: MockTVShowDetailsQueryResponseParams,
) => {
const request = {
request: {
query: TV_SHOW_DETAILS_QUERY,
variables: {
language: ISO6391Language.en,
...params,
},
},
};

const result = {
result: {
data: {
tvShow,
},
},
};

const responseWithNetworkError = {
...request,
error: new Error('A Network error occurred'),
};

const responseWithGraphQLError = {
...request,
errors: [new GraphQLError('A GraphQL error occurred')],
};

return {
responseWithGraphQLError,
responseWithNetworkError,
request,
result,
};
};

export const mockQueryTVShowDetailsSuccess = (
params: MockTVShowDetailsQueryResponseParams,
) => {
const query = baseMockTVShowDetailsQueryResponse(params);
return [
{
...query.request,
...query.result,
},
];
};

export const mockQueryTVShowDetailsError = (id: number) => {
const query = baseMockTVShowDetailsQueryResponse({
includeVoteAverage: false,
includeGenres: false,
includeVoteCount: false,
id,
});
const error = randomPositiveNumber(1) % 2 === 0 ? 'network' : 'graphql';
const errorResponse =
error === 'network'
? query.responseWithNetworkError
: query.responseWithGraphQLError;
return [
{
...query.request,
...errorResponse,
},
];
};
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
PODS:
- boost (1.76.0)
- BVLinearGradient (2.8.3):
- React-Core
- CocoaAsyncSocket (7.6.5)
- DoubleConversion (1.1.6)
- FBLazyVector (0.72.5)
Expand Down Expand Up @@ -558,6 +560,7 @@ PODS:

DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- BVLinearGradient (from `../node_modules/react-native-linear-gradient`)
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
Expand Down Expand Up @@ -653,6 +656,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
boost:
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
BVLinearGradient:
:path: "../node_modules/react-native-linear-gradient"
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
FBLazyVector:
Expand Down Expand Up @@ -751,6 +756,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
BVLinearGradient: 880f91a7854faff2df62518f0281afb1c60d49a3
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 71803c074f6325f10b5ec891c443b6bbabef0ca7
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"react-native": "0.72.5",
"react-native-fast-image": "^8.6.3",
"react-native-gesture-handler": "^2.13.1",
"react-native-linear-gradient": "^2.8.3",
"react-native-navigation-bar-color": "^2.0.2",
"react-native-reanimated": "^3.5.4",
"react-native-restart": "^0.0.27",
Expand Down
Loading

0 comments on commit 3ff675a

Please sign in to comment.