node-csfd-api-racintom 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintrc.json +33 -0
  3. package/.gitattributes +2 -0
  4. package/.github/FUNDING.yml +8 -0
  5. package/.github/pull_request_template.md +19 -0
  6. package/.github/workflows/main.yml +40 -0
  7. package/.github/workflows/publish.yml +73 -0
  8. package/.github/workflows/test.yml +43 -0
  9. package/.husky/pre-commit +1 -0
  10. package/.idea/codeStyles/Project.xml +72 -0
  11. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  12. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  13. package/.idea/misc.xml +6 -0
  14. package/.idea/modules.xml +8 -0
  15. package/.idea/node-csfd-api.iml +9 -0
  16. package/.idea/prettier.xml +6 -0
  17. package/.idea/vcs.xml +7 -0
  18. package/.nvmrc +1 -0
  19. package/.prettierignore +8 -0
  20. package/.prettierrc +10 -0
  21. package/.vscode/settings.json +16 -0
  22. package/Dockerfile +19 -0
  23. package/README.md +510 -0
  24. package/demo.ts +35 -0
  25. package/eslint.config.mjs +55 -0
  26. package/package.json +86 -0
  27. package/server.ts +66 -0
  28. package/src/fetchers/fetch.polyfill.ts +7 -0
  29. package/src/fetchers/index.ts +25 -0
  30. package/src/helpers/creator.helper.ts +95 -0
  31. package/src/helpers/global.helper.ts +70 -0
  32. package/src/helpers/movie.helper.ts +276 -0
  33. package/src/helpers/search-user.helper.ts +19 -0
  34. package/src/helpers/search.helper.ts +66 -0
  35. package/src/helpers/user-ratings.helper.ts +62 -0
  36. package/src/index.ts +42 -0
  37. package/src/interfaces/creator.interface.ts +14 -0
  38. package/src/interfaces/global.ts +36 -0
  39. package/src/interfaces/movie.interface.ts +157 -0
  40. package/src/interfaces/search.interface.ts +32 -0
  41. package/src/interfaces/user-ratings.interface.ts +21 -0
  42. package/src/services/creator.service.ts +34 -0
  43. package/src/services/movie.service.ts +89 -0
  44. package/src/services/search.service.ts +101 -0
  45. package/src/services/user-ratings.service.ts +106 -0
  46. package/src/vars.ts +13 -0
  47. package/tests/creator.test.ts +182 -0
  48. package/tests/fetchers.test.ts +109 -0
  49. package/tests/global.test.ts +35 -0
  50. package/tests/helpers.test.ts +59 -0
  51. package/tests/mocks/creator-actor.html.ts +2244 -0
  52. package/tests/mocks/creator-composer-empty.html.ts +683 -0
  53. package/tests/mocks/creator-director.html.ts +3407 -0
  54. package/tests/mocks/movie1.html.ts +1430 -0
  55. package/tests/mocks/movie2.html.ts +740 -0
  56. package/tests/mocks/movie3.html.ts +1843 -0
  57. package/tests/mocks/movie4.html.ts +1568 -0
  58. package/tests/mocks/search.html.ts +838 -0
  59. package/tests/mocks/series1.html.ts +1540 -0
  60. package/tests/mocks/userRatings.html.ts +1354 -0
  61. package/tests/movie.test.ts +606 -0
  62. package/tests/search.test.ts +379 -0
  63. package/tests/services.test.ts +106 -0
  64. package/tests/user-ratings.test.ts +142 -0
  65. package/tests/vars.test.ts +34 -0
  66. package/tsconfig.json +23 -0
  67. package/vitest.config.mts +10 -0
@@ -0,0 +1,606 @@
1
+ import { HTMLElement, parse } from 'node-html-parser';
2
+ import { describe, expect, test } from 'vitest';
3
+ import { getColor } from '../src/helpers/global.helper';
4
+ import {
5
+ getBoxMovies,
6
+ getColorRating,
7
+ getDescriptions,
8
+ getDuration,
9
+ getGenres,
10
+ getGroup,
11
+ getId,
12
+ getOrigins,
13
+ getPoster,
14
+ getPremieres,
15
+ getRandomPhoto,
16
+ getRating,
17
+ getRatingCount,
18
+ getTitle,
19
+ getTitlesOther,
20
+ getTrivia,
21
+ getType,
22
+ getVods,
23
+ getYear
24
+ } from '../src/helpers/movie.helper';
25
+ import { CSFDColorRating } from '../src/interfaces/global';
26
+ import {
27
+ CSFDCreator,
28
+ CSFDMovieListItem,
29
+ CSFDPremiere,
30
+ CSFDTitlesOther,
31
+ CSFDVod
32
+ } from '../src/interfaces/movie.interface';
33
+ import { movieMock } from './mocks/movie1.html';
34
+ import { movieMockBlank } from './mocks/movie2.html';
35
+ import { movieMockRich } from './mocks/movie3.html';
36
+ import { movieMock4 } from './mocks/movie4.html';
37
+ import { seriesMock } from './mocks/series1.html';
38
+
39
+ const getPageClasses = (node: HTMLElement): string[] => {
40
+ return node.querySelector('.page-content')?.classNames.split(' ') ?? [''];
41
+ };
42
+
43
+ const getAsideNode = (node: HTMLElement): HTMLElement => {
44
+ return node.querySelector('.aside-movie-profile') as HTMLElement;
45
+ };
46
+
47
+ const getNode = (node: HTMLElement): HTMLElement => {
48
+ return node.querySelector('.main-movie-profile') as HTMLElement;
49
+ };
50
+
51
+ const getJsonLd = (node: HTMLElement): string => {
52
+ return node.querySelector('script[type="application/ld+json"]')?.innerText ?? '{}';
53
+ };
54
+
55
+ const getMovie = (
56
+ node: HTMLElement
57
+ ): { pClasses: string[]; aside: HTMLElement; pNode: HTMLElement; jsonLd: string } => {
58
+ return {
59
+ pClasses: getPageClasses(node),
60
+ aside: getAsideNode(node),
61
+ pNode: getNode(node),
62
+ jsonLd: getJsonLd(node)
63
+ };
64
+ };
65
+
66
+ // Movie
67
+ const movieHtml = parse(movieMock);
68
+ const {
69
+ pClasses: pageClasses,
70
+ aside: asideNode,
71
+ pNode: movieNode,
72
+ jsonLd: movieJsonLd
73
+ } = getMovie(movieHtml);
74
+
75
+ // Wrong html
76
+ const wrongHtml = parse(
77
+ '<div class="film-rating-average"></div><ul class="film-names"><li><img class="flag" /></li></ul>'
78
+ );
79
+
80
+ // Movie blank
81
+ const movieHtmlBlank = parse(movieMockBlank);
82
+
83
+ const {
84
+ pClasses: pageClassesBlank,
85
+ aside: asideNodeBlank,
86
+ pNode: movieNodeBlank,
87
+ jsonLd: movieBlankJsonLd
88
+ } = getMovie(movieHtmlBlank);
89
+
90
+ // Movie rich
91
+ const movieHtmlRich = parse(movieMockRich);
92
+
93
+ const {
94
+ aside: asideNodeRich,
95
+ pNode: movieNodeRich,
96
+ jsonLd: movieRichJsonLd
97
+ } = getMovie(movieHtmlRich);
98
+
99
+ // Movie 4
100
+ const movieHtml4 = parse(movieMock4);
101
+
102
+ const { aside: asideNode4 } = getMovie(movieHtml4);
103
+
104
+ // Series
105
+ const seriesHtml = parse(seriesMock);
106
+
107
+ const { aside: asideNodeSeries, pNode: seriesNode, jsonLd: seriesJsonLd } = getMovie(seriesHtml);
108
+
109
+ const emptyHtmlNode = movieHtml.querySelector('.page-footer'); // some random node
110
+
111
+ describe('Get ID', () => {
112
+ test('Movie ID', () => {
113
+ const movie = getId(movieNode);
114
+ expect(movie).toEqual<number>(535121);
115
+ });
116
+ // test('Empty node', () => {
117
+ // const movie = getId(emptyHtmlNode);
118
+ // expect(movie).toEqual<number>(null);
119
+ // });
120
+ });
121
+
122
+ describe('Get Movie Title', () => {
123
+ test('Movie title', () => {
124
+ const movie = getTitle(movieNode);
125
+ expect(movie).toEqual<string>('Na špatné straně');
126
+ });
127
+ test('Series title', () => {
128
+ const movie = getTitle(seriesNode);
129
+ expect(movie).toEqual<string>('Království');
130
+ });
131
+ test('Movie rich title', () => {
132
+ const movie = getTitle(movieNodeRich);
133
+ expect(movie).toEqual<string>('Pán prstenů: Společenstvo Prstenu');
134
+ });
135
+ // test('Empty node', () => {
136
+ // const movie = getTitle(emptyHtmlNode);
137
+ // expect(movie).toEqual(null);
138
+ // });
139
+ });
140
+
141
+ describe('Get Poster', () => {
142
+ test('Movie poster', () => {
143
+ const movie = getPoster(movieNode);
144
+ expect(movie).toEqual<string>(
145
+ 'https://image.pmgstatic.com/cache/resized/w1080/files/images/film/posters/163/579/163579352_bf8737.jpg'
146
+ );
147
+ });
148
+ test('Movie Blank poster', () => {
149
+ const movie = getPoster(movieNodeBlank);
150
+ expect(movie).toEqual(null);
151
+ });
152
+ test('Movie rich poster', () => {
153
+ const movie = getPoster(movieNodeRich);
154
+ expect(movie).toEqual<string>(
155
+ 'https://image.pmgstatic.com/cache/resized/w1080/files/images/film/posters/158/600/158600806_7b6c15.jpg'
156
+ );
157
+ });
158
+ test('Movie empty node', () => {
159
+ const movie = getPoster(emptyHtmlNode);
160
+ expect(movie).toEqual(null);
161
+ });
162
+ });
163
+
164
+ describe('Get Movie photo', () => {
165
+ test('Movie photo', () => {
166
+ const movie = getRandomPhoto(movieNode);
167
+ expect(movie).toEqual<string>(
168
+ '//image.pmgstatic.com/cache/resized/w1326/files/images/film/photos/163/416/163416559_60bcbb.jpg'
169
+ );
170
+ });
171
+ test('Movie Blank photo', () => {
172
+ const movie = getRandomPhoto(movieNodeBlank);
173
+ expect(movie).toEqual(null);
174
+ });
175
+ test('Movie Series photo', () => {
176
+ const movie = getRandomPhoto(seriesNode);
177
+ expect(movie).toEqual<string>(
178
+ '//image.pmgstatic.com/cache/resized/w1326/files/images/film/photos/166/598/166598546_c16928.jpg'
179
+ );
180
+ });
181
+ test('Movie empty node', () => {
182
+ const movie = getRandomPhoto(emptyHtmlNode);
183
+ expect(movie).toEqual(null);
184
+ });
185
+ });
186
+
187
+ describe('Get Movie trivia', () => {
188
+ test('Movie trivia', () => {
189
+ const movie = getTrivia(movieNode);
190
+ expect(movie).toEqual<string[]>([
191
+ 'Režisér S. Craig Zahler původně napsal scénář pro věk hlavních postav 30 a 50 let. Poté našel pro roli mladšího policisty Lurasettiho svého oblíbeného herce Vinceho a hledal vhodného partnera. Když se dohodl s Mel Gibsonem na obsazení role Ridgemana, musel přepsat role do věku postav 40 a 60 let.(Tonula)',
192
+ 'Ve filmu se střídají pro různé záběry dvě auta, Melovo Chevrolet je buď model Caprice ročník 1986 anebo model Impala ročník 1980. Při závěrečné scéně je v jednom záběru auto schované v garáži bílé SUV Dodge Durango, ale jinak je to Chevrolet Tahoe. Dvě úplně jiná auta.(350cuiV8)',
193
+ 'Při přepadení obchodu ve 36. minutě, střelec rozstřílí stojan s chipsy a přitom si můžeme jasně všimnout, že zákazník pohne hlavou, i když ho předtím lupič evidentně zastřelil.(Timak)'
194
+ ]);
195
+ });
196
+ test('Movie Blank trivia', () => {
197
+ const movie = getTrivia(movieNodeBlank);
198
+ expect(movie).toEqual(null);
199
+ });
200
+ test('Movie Series trivia', () => {
201
+ const movie = getTrivia(seriesNode);
202
+ expect(movie).toEqual<string[]>([
203
+ 'Herci, kteří se v seriálu objevili jako umývači nádobí, nedokázali své dialogy řádně vyslovovat, a tak museli být předabováni.(HellFire)',
204
+ 'Údajne sa plánovala i tretia séria seriálu, plány však narušila predčasná smrť niektorých hlavných hercov.(misterz)',
205
+ 'Ernst-Hugo Järegård se právě díky roli v Riget v Dánsku výrazně zviditelnil a byl dokonce považován za nový sexuální symbol.(TomikZlesa)'
206
+ ]);
207
+ });
208
+ test('Movie empty node', () => {
209
+ const movie = getTrivia(emptyHtmlNode);
210
+ expect(movie).toEqual(null);
211
+ });
212
+ });
213
+
214
+ describe('Get Duration', () => {
215
+ test('Duration', () => {
216
+ const movie = getDuration(movieJsonLd, movieNode);
217
+ expect(movie).toEqual<number>(159);
218
+ });
219
+ test('Duration Blank', () => {
220
+ const movie = getDuration(movieBlankJsonLd, movieNodeBlank);
221
+ expect(movie).toEqual(null);
222
+ });
223
+ test('Duration Rich', () => {
224
+ const movie = getDuration(movieRichJsonLd, movieNodeRich);
225
+ expect(movie).toEqual<number>(172);
226
+ });
227
+ test('Duration Series', () => {
228
+ const movie = getDuration(seriesJsonLd, seriesNode);
229
+ expect(movie).toEqual<number>(860);
230
+ });
231
+ // test('Empty node', () => {
232
+ // const movie = getDuration('bad json', emptyHtmlNode);
233
+ // expect(movie).toEqual<number>(null);
234
+ // });
235
+ });
236
+
237
+ describe('Get VOD', () => {
238
+ test('Get vods movie', () => {
239
+ const movie = getVods(asideNode);
240
+ expect(movie).toEqual<CSFDVod[]>([
241
+ {
242
+ title: 'Apple TV+',
243
+ url: 'https://tv.apple.com/cz/movie/dragged-across-concrete/umc.cmc.34ihj6x6alpeso7j7lpvamjfb'
244
+ },
245
+ {
246
+ title: 'Voyo',
247
+ url: 'https://voyo.nova.cz/titul/4604-na-spatne-strane'
248
+ },
249
+ { title: 'KVIFF.TV', url: 'https://kviff.tv/katalog/na-spatne-strane' },
250
+ {
251
+ title: 'iTunes',
252
+ url: 'https://itunes.apple.com/cz/movie/dragged-across-concrete/id1469983874'
253
+ },
254
+ {
255
+ title: 'DVD',
256
+ url: 'https://www.martinus.cz/?uItem=619199'
257
+ }
258
+ ]);
259
+ });
260
+ test('Get vods series', () => {
261
+ const movie = getVods(asideNodeSeries);
262
+ expect(movie).toEqual<CSFDVod[]>([
263
+ {
264
+ title: 'KVIFF.TV',
265
+ url: 'https://kviff.tv/katalog/kralovstvi-cast-sedma-gargantua'
266
+ }
267
+ ]);
268
+ });
269
+ test('Get vods rich', () => {
270
+ const movie = getVods(asideNodeRich);
271
+ expect(movie.length).toEqual<number>(11);
272
+ });
273
+ test('Get vods blank', () => {
274
+ const movie = getVods(asideNodeBlank);
275
+ expect(movie).toEqual<CSFDVod[]>([]);
276
+ });
277
+ test('Empty node', () => {
278
+ const movie = getVods(emptyHtmlNode);
279
+ expect(movie).toEqual<CSFDVod[]>([]);
280
+ });
281
+ });
282
+
283
+ // TODO
284
+ // describe('Get additional info', () => {
285
+ // test('Get tags', () => {
286
+ // const item = getTags(movieNode);
287
+ // expect(item).toEqual<string[]>([
288
+ // 'policie',
289
+ // 'zbraně',
290
+ // 'město',
291
+ // 'zloděj',
292
+ // 'rukojmí',
293
+ // 'sledování',
294
+ // 'podsvětí',
295
+ // 'přepadení',
296
+ // 'banka'
297
+ // ]);
298
+ // });
299
+ // });
300
+
301
+ describe('Get titlesOther', () => {
302
+ test('Titles Other', () => {
303
+ const movie = getTitlesOther(movieNode);
304
+ expect(movie).toEqual<CSFDTitlesOther[]>([
305
+ { country: 'USA', title: 'Dragged Across Concrete' },
306
+ { country: 'Kanada', title: 'Dragged Across Concrete' },
307
+ { country: 'Slovensko', title: 'Na zlej strane' },
308
+ { country: 'Velká Británie', title: 'Dragged Across Concrete' },
309
+ { country: 'Austrálie', title: 'Dragged Across Concrete' }
310
+ ]);
311
+ });
312
+ test('Titles Other Blank', () => {
313
+ const movie = getTitlesOther(movieNodeBlank);
314
+ expect(movie).toEqual<CSFDTitlesOther[]>([]);
315
+ });
316
+ });
317
+
318
+ describe('Get origins', () => {
319
+ test('Origins', () => {
320
+ const movie = getOrigins(movieNode);
321
+ expect(movie).toEqual<string[]>(['USA', 'Kanada']);
322
+ });
323
+ test('Origins Series', () => {
324
+ const movie = getOrigins(seriesNode);
325
+ expect(movie).toEqual<string[]>(['Dánsko', 'Francie', 'Německo', 'Švédsko']);
326
+ });
327
+ });
328
+
329
+ describe('Get descriptions', () => {
330
+ test('Descriptions', () => {
331
+ const movie = getDescriptions(movieNode);
332
+ expect(movie).toEqual<string[]>([
333
+ 'Otupělý policejní veterán Ridgeman (Mel Gibson) a jeho náladový mladší kolega Anthony (Vince Vaughn) jsou suspendováni ze služby poté, co do médií unikne videozáznam jejich svérázných metod. Bez prostředků a velkých šancí se oba zatrpklí vojáci vydají do kriminálního podsvětí, aby učinili spravedlnosti zadost. Mezitím je v jiné části města propuštěn z vězení mladý zločinec Henry Jones a zjišťuje, že jeho matce a postiženému bratrovi hrozí vystěhování. Ve snaze najít způsob, jak jim pomoci, se obrátí na kamaráda z dětství jménem Biscuit, který ho představí nelítostnému kriminálnímu bossovi, jehož ambiciózní plány jej postaví do přímého konfliktu s oběma policejními odpadlíky.(HBO Europe)'
334
+ ]);
335
+ });
336
+ test('Descriptions rich', () => {
337
+ const movie = getDescriptions(movieNodeRich);
338
+ expect(movie).toEqual<string[]>([
339
+ 'V dávných dobách byl vykován kouzelný prsten, který vlastnil pán Mordoru Sauron. Jeho moc začal využívat k šíření zla, ale o prsten nakonec v boji přišel, a ten na dlouhá léta zmizel. Nakonec ho našel hobit Bilbo Pytlík, který díky němu přestal stárnout. Na naléhavou žádost čaroděje Gandalfa předá prsten synovci Frodovi. Ten se svými kamarády Samem, Smíškem a Pipinem odcházejí do Hůrky a Gandalf se vydává pro radu za svým učitelem, čarodějem Sarumanem. Ten se však přidal na stranu zla a zajme ho. S pomocí tajemného hraničáře, přezdívaného Chodec, Frodo a jeho kamarádi uniknou jen o vlásek devíti černým jezdcům, kteří vyrazili z Temné věže, aby prsten našli a přinesli svému pánovi Sauronovi. Do Roklinky je svolána velká porada lidí a elfů, která rozhodne, že prsten musí být zničen. To je možné pouze tam, kde byl prsten zrozen, v ohni Hory osudu. Odvážný Frodo se nabídne, že tam prsten odnese. Nebezpečí je však příliš veliké, a tak se mu, jako jeho ochránci, postaví po bok čaroděj Gandalf, trpaslík Gimli, elf Legolas, bojovník Boromir, hobiti Sam, Smíšek a Pipin a také Chodec. Zrodí se Společenstvo Prstenu, které se vydává na nebezpečnou cestu plnou nástrah a nebezpečí.(TV Nova)',
340
+ 'Budoucnost civilizace spočívá v osudu Jednoho prstenu, který byl po staletí ztracen. Osud jej však umístil do rukou mladého Hobita jménem Frodo Pytlík, který zdědil Prsten. Když se Frodo stane nositelem prstenu, čeká ho skličující úkol – zničit prsten v ohni Hory Osudu, kde byl vytvořen.(G....)'
341
+ ]);
342
+ });
343
+ test('Description blank', () => {
344
+ const movie = getDescriptions(movieNodeBlank);
345
+ expect(movie).toEqual<string[]>([]);
346
+ });
347
+ });
348
+
349
+ describe('Get genres', () => {
350
+ test('Genres', () => {
351
+ const movie = getGenres(movieNode);
352
+ expect(movie).toEqual<string[]>(['Krimi', 'Drama', 'Thriller']);
353
+ });
354
+ test('Genres rich', () => {
355
+ const movie = getGenres(movieNodeRich);
356
+ expect(movie).toEqual<string[]>(['Fantasy', 'Dobrodružný', 'Akční']);
357
+ });
358
+ test('Genres Series', () => {
359
+ const movie = getGenres(seriesNode);
360
+ expect(movie).toEqual<string[]>(['Drama', 'Horor', 'Mysteriózní', 'Komedie']);
361
+ });
362
+ });
363
+
364
+ describe('Get type', () => {
365
+ test('Type', () => {
366
+ const movie = getType(movieNode);
367
+ expect(movie).toEqual<string>('film');
368
+ });
369
+ test('Type Rich', () => {
370
+ const movie = getType(movieNodeRich);
371
+ expect(movie).toEqual<string>('film');
372
+ });
373
+ test('Type Series', () => {
374
+ const movie = getType(seriesNode);
375
+ expect(movie).toEqual<string>('seriál');
376
+ });
377
+ });
378
+
379
+ describe('Get year', () => {
380
+ test('Year', () => {
381
+ const movie = getYear(movieJsonLd);
382
+ expect(movie).toEqual<number>(2018);
383
+ });
384
+ test('Year', () => {
385
+ const movie = getYear(movieRichJsonLd);
386
+ expect(movie).toEqual<number>(2001);
387
+ });
388
+ test('Year Series', () => {
389
+ const movie = getYear(seriesJsonLd);
390
+ expect(movie).toEqual<number>(1994);
391
+ });
392
+ test('Wrong year', () => {
393
+ const movie = getYear(null as any);
394
+ expect(movie).toEqual(null);
395
+ });
396
+ });
397
+
398
+ describe('Get rating count', () => {
399
+ test('Rating count', () => {
400
+ const movie = getRatingCount(asideNode);
401
+ expect(movie).toBeGreaterThan(6468);
402
+ });
403
+ test('Rating count', () => {
404
+ const movie = getRatingCount(asideNodeSeries);
405
+ expect(movie).toBeGreaterThan(4450);
406
+ });
407
+ test('Rating count rich', () => {
408
+ const movie = getRatingCount(asideNodeRich);
409
+ expect(movie).toBeGreaterThan(100000);
410
+ });
411
+ // TODO get new blank movie
412
+ test('Rating count blank', () => {
413
+ const movie = getRatingCount(asideNodeBlank);
414
+ expect(movie).toEqual(null);
415
+ });
416
+ });
417
+
418
+ describe('Get ratings', () => {
419
+ test('Rating', () => {
420
+ const movie = getRating(movieNode);
421
+ expect(movie).toEqual<number>(72);
422
+ });
423
+ test('Color Rating', () => {
424
+ const movie = getColorRating(pageClasses);
425
+ expect(movie).toEqual<CSFDColorRating>('good');
426
+ });
427
+ test('Blank Rating', () => {
428
+ const movie = getColorRating(pageClassesBlank);
429
+ expect(movie).toEqual<CSFDColorRating>('unknown');
430
+ });
431
+ test('Bad Rating', () => {
432
+ const rating = getColor('nothing!');
433
+ expect(rating).toEqual<CSFDColorRating>('unknown');
434
+ });
435
+ test('Bad Rating', () => {
436
+ const rating = getColor('page-grey');
437
+ expect(rating).toEqual<CSFDColorRating>('bad');
438
+ });
439
+ test('Bad Rating', () => {
440
+ const rating = getColor('page-blue');
441
+ expect(rating).toEqual<CSFDColorRating>('average');
442
+ });
443
+ });
444
+
445
+ describe('Get people', () => {
446
+ test('directors', () => {
447
+ const movie = getGroup(movieNode, 'Režie');
448
+ expect(movie).toEqual<CSFDCreator[]>([
449
+ {
450
+ id: 87470,
451
+ name: 'S. Craig Zahler',
452
+ url: 'https://www.csfd.cz/tvurce/87470-s-craig-zahler/'
453
+ }
454
+ ]);
455
+ });
456
+ test('Screenwriters', () => {
457
+ const movie = getGroup(movieNode, 'Scénář');
458
+ expect(movie.slice(0, 1)).toEqual<CSFDCreator[]>([
459
+ {
460
+ id: 87470,
461
+ name: 'S. Craig Zahler',
462
+ url: 'https://www.csfd.cz/tvurce/87470-s-craig-zahler/'
463
+ }
464
+ ]);
465
+ });
466
+ test('Music composers', () => {
467
+ const movie = getGroup(movieNode, 'Hudba');
468
+ expect(movie.slice(0, 1)).toEqual<CSFDCreator[]>([
469
+ { id: 203209, name: 'Jeff Herriott', url: 'https://www.csfd.cz/tvurce/203209-jeff-herriott/' }
470
+ ]);
471
+ });
472
+ test('Actors', () => {
473
+ const movie = getGroup(movieNode, 'Hrají');
474
+ expect(movie.slice(0, 1)).toEqual<CSFDCreator[]>([
475
+ {
476
+ id: 1,
477
+ name: 'Mel Gibson',
478
+ url: 'https://www.csfd.cz/tvurce/1-mel-gibson/'
479
+ }
480
+ ]);
481
+ });
482
+ test('Based on', () => {
483
+ const movie = getGroup(movieNode, 'Předloha');
484
+ expect(movie.slice(0, 1)).toEqual<CSFDCreator[]>([]);
485
+ });
486
+
487
+ describe('Get premieres', () => {
488
+ test('Get movie premiere', () => {
489
+ const movie = getPremieres(asideNode);
490
+ expect(movie).toEqual<CSFDPremiere[]>([
491
+ { company: 'Magic Box', country: 'Česko', date: '07.08.2019', format: 'Na DVD' },
492
+ { company: 'Magic Box', country: 'Česko', date: '07.08.2019', format: 'Na Blu-ray' },
493
+ { company: 'Lionsgate US', country: 'USA', date: '22.03.2019', format: 'V kinech' }
494
+ ]);
495
+ });
496
+ test('Get series premiere', () => {
497
+ const movie = getPremieres(asideNodeSeries);
498
+ expect(movie).toEqual<CSFDPremiere[]>([
499
+ {
500
+ company: 'Aerofilms',
501
+ country: 'Česko',
502
+ date: '26.09.2022',
503
+ format: 'V kinech'
504
+ },
505
+ { company: 'Levné knihy', country: 'Česko', date: '22.12.2010', format: 'Na DVD' },
506
+ { company: 'Danmarks Radio', country: 'Dánsko', date: '24.11.1994', format: 'V TV' },
507
+ { company: 'arte', country: 'Německo', date: '11.03.1995', format: 'V TV' },
508
+ { company: 'SVT', country: 'Švédsko', date: '04.03.1995', format: 'V TV' }
509
+ ]);
510
+ });
511
+ test('Get other movie premiere', () => {
512
+ const movie = getPremieres(asideNode4);
513
+ expect(movie).toEqual<CSFDPremiere[]>([
514
+ {
515
+ country: 'Česko',
516
+ format: 'Na DVD',
517
+ date: '20.06.2013',
518
+ company: 'Bontonfilm'
519
+ },
520
+ {
521
+ country: 'Česko',
522
+ format: 'Na DVD',
523
+ date: '21.05.2010',
524
+ company: 'dvdcom'
525
+ },
526
+ {
527
+ country: 'Česko',
528
+ format: 'Na DVD',
529
+ date: '01.05.2004',
530
+ company: 'Bontonfilm'
531
+ },
532
+ {
533
+ country: 'Česko',
534
+ format: 'Na Blu-ray',
535
+ date: '07.12.2011',
536
+ company: 'Bontonfilm'
537
+ },
538
+ {
539
+ country: 'USA',
540
+ format: 'V kinech',
541
+ date: '27.07.2001',
542
+ company: '20th Century Fox'
543
+ }
544
+ ]);
545
+ });
546
+ test('Get blank premiere', () => {
547
+ const movie = getPremieres(asideNodeBlank);
548
+ expect(movie).toEqual<CSFDPremiere[]>([]);
549
+ });
550
+ });
551
+
552
+ // TODO get movies with related box
553
+ describe('Get related', () => {
554
+ test('Get movie related', () => {
555
+ const movie = getBoxMovies(asideNode, 'Související');
556
+ expect(movie).toEqual<CSFDMovieListItem[]>([]);
557
+ });
558
+ test('Get series related', () => {
559
+ const movie = getBoxMovies(asideNodeSeries, 'Související');
560
+ expect(movie).toEqual<CSFDMovieListItem[]>([
561
+ {
562
+ id: 116244,
563
+ title: 'Královská nemocnice',
564
+ url: 'https://www.csfd.cz/film/116244-kralovska-nemocnice/'
565
+ }
566
+ ]);
567
+ });
568
+ test('Get blank related', () => {
569
+ const movie = getBoxMovies(asideNodeBlank, 'Související');
570
+ expect(movie).toEqual<CSFDMovieListItem[]>([]);
571
+ });
572
+ });
573
+
574
+ // TODO get movies with similar box
575
+ describe('Get similar', () => {
576
+ test('Get movie similar', () => {
577
+ const movie = getBoxMovies(asideNode, 'Podobné');
578
+ expect(movie).toEqual<CSFDMovieListItem[]>([]);
579
+ });
580
+ test('Get series similar', () => {
581
+ const movie = getBoxMovies(asideNodeSeries, 'Podobné');
582
+ expect(movie).toEqual<CSFDMovieListItem[]>([]);
583
+ });
584
+ test('Get blank similar', () => {
585
+ const movie = getBoxMovies(asideNodeBlank, 'Podobné');
586
+ expect(movie).toEqual<CSFDMovieListItem[]>([]);
587
+ });
588
+ });
589
+
590
+ describe('Anomaly detection', () => {
591
+ test('Bad node for rating', () => {
592
+ const movie = getRatingCount(movieNode);
593
+ expect(movie).toEqual<CSFDMovieListItem[]>(null as any);
594
+ });
595
+
596
+ test('Wrong rating', () => {
597
+ const movie = getRating(wrongHtml);
598
+ expect(movie).toEqual(null);
599
+ });
600
+
601
+ test('Wrong otherTitle', () => {
602
+ const movie = getTitlesOther(wrongHtml);
603
+ expect(movie).toEqual([]);
604
+ });
605
+ });
606
+ });