node-csfd-api-racintom 1.8.0 → 1.9.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.
- package/fetchers/fetch.polyfill.d.ts +1 -0
- package/fetchers/fetch.polyfill.js +9 -0
- package/fetchers/index.d.ts +1 -0
- package/fetchers/index.js +27 -0
- package/helpers/creator.helper.d.ts +17 -0
- package/helpers/creator.helper.js +87 -0
- package/helpers/global.helper.d.ts +17 -0
- package/helpers/global.helper.js +68 -0
- package/helpers/movie.helper.d.ts +26 -0
- package/helpers/movie.helper.js +270 -0
- package/helpers/search-user.helper.d.ts +5 -0
- package/helpers/search-user.helper.js +22 -0
- package/helpers/search.helper.d.ts +11 -0
- package/helpers/search.helper.js +62 -0
- package/helpers/user-ratings.helper.d.ts +13 -0
- package/helpers/user-ratings.helper.js +61 -0
- package/index.d.ts +24 -0
- package/index.js +39 -0
- package/interfaces/creator.interface.d.ts +12 -0
- package/interfaces/creator.interface.js +2 -0
- package/interfaces/global.d.ts +22 -0
- package/interfaces/global.js +2 -0
- package/interfaces/movie.interface.d.ts +73 -0
- package/interfaces/movie.interface.js +2 -0
- package/interfaces/search.interface.d.ts +27 -0
- package/interfaces/search.interface.js +2 -0
- package/interfaces/season.interface.d.ts +11 -0
- package/interfaces/season.interface.js +2 -0
- package/interfaces/user-ratings.interface.d.ts +18 -0
- package/interfaces/user-ratings.interface.js +2 -0
- package/package.json +62 -86
- package/services/creator.service.d.ts +6 -0
- package/services/creator.service.js +32 -0
- package/services/movie.service.d.ts +6 -0
- package/services/movie.service.js +59 -0
- package/services/search.service.d.ts +5 -0
- package/services/search.service.js +80 -0
- package/services/season.service.d.ts +9 -0
- package/services/season.service.js +43 -0
- package/services/user-ratings.service.d.ts +7 -0
- package/services/user-ratings.service.js +84 -0
- package/vars.d.ts +5 -0
- package/vars.js +13 -0
- package/.editorconfig +0 -13
- package/.eslintrc.json +0 -33
- package/.gitattributes +0 -2
- package/.github/FUNDING.yml +0 -8
- package/.github/pull_request_template.md +0 -19
- package/.github/workflows/main.yml +0 -40
- package/.github/workflows/publish.yml +0 -73
- package/.github/workflows/test.yml +0 -43
- package/.husky/pre-commit +0 -1
- package/.idea/codeStyles/Project.xml +0 -72
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/node-csfd-api.iml +0 -9
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -7
- package/.nvmrc +0 -1
- package/.prettierignore +0 -8
- package/.prettierrc +0 -10
- package/.vscode/settings.json +0 -16
- package/Dockerfile +0 -19
- package/demo.ts +0 -35
- package/eslint.config.mjs +0 -55
- package/server.ts +0 -66
- package/src/fetchers/fetch.polyfill.ts +0 -7
- package/src/fetchers/index.ts +0 -25
- package/src/helpers/creator.helper.ts +0 -95
- package/src/helpers/global.helper.ts +0 -70
- package/src/helpers/movie.helper.ts +0 -276
- package/src/helpers/search-user.helper.ts +0 -19
- package/src/helpers/search.helper.ts +0 -66
- package/src/helpers/user-ratings.helper.ts +0 -62
- package/src/index.ts +0 -50
- package/src/interfaces/creator.interface.ts +0 -14
- package/src/interfaces/global.ts +0 -36
- package/src/interfaces/movie.interface.ts +0 -157
- package/src/interfaces/search.interface.ts +0 -32
- package/src/interfaces/season.interface.ts +0 -12
- package/src/interfaces/user-ratings.interface.ts +0 -21
- package/src/services/creator.service.ts +0 -34
- package/src/services/movie.service.ts +0 -89
- package/src/services/search.service.ts +0 -101
- package/src/services/season.service.ts +0 -55
- package/src/services/user-ratings.service.ts +0 -106
- package/src/vars.ts +0 -16
- package/tests/creator.test.ts +0 -182
- package/tests/fetchers.test.ts +0 -109
- package/tests/global.test.ts +0 -35
- package/tests/helpers.test.ts +0 -59
- package/tests/mocks/creator-actor.html.ts +0 -2244
- package/tests/mocks/creator-composer-empty.html.ts +0 -683
- package/tests/mocks/creator-director.html.ts +0 -3407
- package/tests/mocks/movie1.html.ts +0 -1430
- package/tests/mocks/movie2.html.ts +0 -740
- package/tests/mocks/movie3.html.ts +0 -1843
- package/tests/mocks/movie4.html.ts +0 -1568
- package/tests/mocks/search.html.ts +0 -838
- package/tests/mocks/series1.html.ts +0 -1540
- package/tests/mocks/userRatings.html.ts +0 -1354
- package/tests/movie.test.ts +0 -606
- package/tests/search.test.ts +0 -379
- package/tests/season.test.ts +0 -115
- package/tests/services.test.ts +0 -106
- package/tests/user-ratings.test.ts +0 -142
- package/tests/vars.test.ts +0 -34
- package/tsconfig.json +0 -23
- package/vitest.config.mts +0 -10
package/tests/search.test.ts
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { parse } from 'node-html-parser';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
3
|
-
import { getAvatar, getUser, getUserRealName, getUserUrl } from '../src/helpers/search-user.helper';
|
|
4
|
-
import {
|
|
5
|
-
getColorRating,
|
|
6
|
-
getOrigins,
|
|
7
|
-
getPoster,
|
|
8
|
-
getTitle,
|
|
9
|
-
getType,
|
|
10
|
-
getUrl,
|
|
11
|
-
getYear,
|
|
12
|
-
parsePeople
|
|
13
|
-
} from '../src/helpers/search.helper';
|
|
14
|
-
import { CSFDColorRating, CSFDFilmTypes } from '../src/interfaces/global';
|
|
15
|
-
import { CSFDCreator } from '../src/interfaces/movie.interface';
|
|
16
|
-
import { searchMock } from './mocks/search.html';
|
|
17
|
-
|
|
18
|
-
const html = parse(searchMock);
|
|
19
|
-
const moviesNode = html.querySelectorAll('.main-movies article');
|
|
20
|
-
const usersNode = html.querySelectorAll('.main-users article');
|
|
21
|
-
const tvSeriesNode = html.querySelectorAll('.main-series article');
|
|
22
|
-
|
|
23
|
-
describe('Get Movie titles', () => {
|
|
24
|
-
test('First movie', () => {
|
|
25
|
-
const movie = getTitle(moviesNode[0]);
|
|
26
|
-
expect(movie).toEqual<string>('Matrix');
|
|
27
|
-
});
|
|
28
|
-
test('Last movie', () => {
|
|
29
|
-
const movie = getTitle(moviesNode[moviesNode.length - 1]);
|
|
30
|
-
expect(movie).toEqual<string>('Matrix hunter');
|
|
31
|
-
});
|
|
32
|
-
test('Some movie', () => {
|
|
33
|
-
const movie = getTitle(moviesNode[5]);
|
|
34
|
-
expect(movie).toEqual<string>('Matrix - Reloaded');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('Get Movie years', () => {
|
|
39
|
-
test('First movie', () => {
|
|
40
|
-
const movie = getYear(moviesNode[0]);
|
|
41
|
-
expect(movie).toEqual<number>(1999);
|
|
42
|
-
});
|
|
43
|
-
test('Last movie', () => {
|
|
44
|
-
const movie = getYear(moviesNode[moviesNode.length - 1]);
|
|
45
|
-
expect(movie).toEqual<number>(2004);
|
|
46
|
-
});
|
|
47
|
-
test('Some movie', () => {
|
|
48
|
-
const movie = getYear(moviesNode[3]);
|
|
49
|
-
expect(movie).toEqual<number>(2003);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('Get Movie url', () => {
|
|
54
|
-
test('First movie', () => {
|
|
55
|
-
const movie = getUrl(moviesNode[0]);
|
|
56
|
-
expect(movie).toEqual<string>('/film/9499-matrix/');
|
|
57
|
-
});
|
|
58
|
-
test('Last movie', () => {
|
|
59
|
-
const movie = getUrl(moviesNode[moviesNode.length - 1]);
|
|
60
|
-
expect(movie).toEqual<string>('/film/40940-matrix-hunter/');
|
|
61
|
-
});
|
|
62
|
-
test('Some movie', () => {
|
|
63
|
-
const movie = getUrl(moviesNode[4]);
|
|
64
|
-
expect(movie).toEqual<string>('/film/799868-matrix/');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('Get Movie types', () => {
|
|
69
|
-
test('First movie', () => {
|
|
70
|
-
const movie = getType(moviesNode[0]);
|
|
71
|
-
expect(movie).toEqual<CSFDFilmTypes>('film');
|
|
72
|
-
});
|
|
73
|
-
test('Last movie', () => {
|
|
74
|
-
const movie = getType(moviesNode[moviesNode.length - 1]);
|
|
75
|
-
expect(movie).toEqual<CSFDFilmTypes>('film');
|
|
76
|
-
});
|
|
77
|
-
test('Some movie', () => {
|
|
78
|
-
const movie = getType(moviesNode[1]);
|
|
79
|
-
expect(movie).toEqual<CSFDFilmTypes>('film');
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('Get Movie colors', () => {
|
|
84
|
-
test('First movie', () => {
|
|
85
|
-
const movie = getColorRating(moviesNode[0]);
|
|
86
|
-
expect(movie).toEqual<CSFDColorRating>('good');
|
|
87
|
-
});
|
|
88
|
-
test('Last movie', () => {
|
|
89
|
-
const movie = getColorRating(moviesNode[moviesNode.length - 1]);
|
|
90
|
-
expect(movie).toEqual<CSFDColorRating>('average');
|
|
91
|
-
});
|
|
92
|
-
test('Some movie', () => {
|
|
93
|
-
const movie = getColorRating(moviesNode[4]);
|
|
94
|
-
expect(movie).toEqual<CSFDColorRating>('unknown');
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('Get Movie posters', () => {
|
|
99
|
-
test('First movie', () => {
|
|
100
|
-
const movie = getPoster(moviesNode[0]);
|
|
101
|
-
expect(movie).toEqual<string>(
|
|
102
|
-
'https://image.pmgstatic.com/cache/resized/w60h85/files/images/film/posters/000/008/8959_164d69.jpg'
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
test('Empty poster', () => {
|
|
106
|
-
const movie = getPoster(moviesNode[4]);
|
|
107
|
-
expect(movie).toEqual<string>(
|
|
108
|
-
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
test('Some movie', () => {
|
|
112
|
-
const movie = getPoster(moviesNode[1]);
|
|
113
|
-
expect(movie).toEqual<string>(
|
|
114
|
-
'https://image.pmgstatic.com/cache/resized/w60h85/files/images/film/posters/165/852/165852808_71b2e1.jpg'
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('Get Movie origins', () => {
|
|
120
|
-
test('First movie', () => {
|
|
121
|
-
const movie = getOrigins(moviesNode[0]);
|
|
122
|
-
expect(movie).toEqual<string[]>(['USA']);
|
|
123
|
-
});
|
|
124
|
-
test('Second movie', () => {
|
|
125
|
-
const movie = getOrigins(moviesNode[1]);
|
|
126
|
-
expect(movie).toEqual<string[]>(['USA']);
|
|
127
|
-
});
|
|
128
|
-
test('Third movie', () => {
|
|
129
|
-
const movie = getOrigins(moviesNode[2]);
|
|
130
|
-
expect(movie).toEqual<string[]>(['USA', 'Austrálie']);
|
|
131
|
-
});
|
|
132
|
-
test('Some movie', () => {
|
|
133
|
-
const movie = getOrigins(moviesNode[4]);
|
|
134
|
-
expect(movie).toEqual<string[]>(['Slovensko']);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('Get Movie creators', () => {
|
|
139
|
-
test('First movie directors', () => {
|
|
140
|
-
const movie = parsePeople(moviesNode[0], 'directors');
|
|
141
|
-
expect(movie).toEqual<CSFDCreator[]>([
|
|
142
|
-
{
|
|
143
|
-
id: 3112,
|
|
144
|
-
name: 'Lilly Wachowski',
|
|
145
|
-
url: 'https://www.csfd.cz/tvurce/3112-lilly-wachowski/'
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
id: 3113,
|
|
149
|
-
name: 'Lana Wachowski',
|
|
150
|
-
url: 'https://www.csfd.cz/tvurce/3113-lana-wachowski/'
|
|
151
|
-
}
|
|
152
|
-
]);
|
|
153
|
-
});
|
|
154
|
-
test('Last movie actors', () => {
|
|
155
|
-
const movie = parsePeople(moviesNode[moviesNode.length - 1], 'actors');
|
|
156
|
-
expect(movie).toEqual<CSFDCreator[]>([
|
|
157
|
-
{
|
|
158
|
-
id: 67747,
|
|
159
|
-
name: "Genevieve O'Reilly",
|
|
160
|
-
url: 'https://www.csfd.cz/tvurce/67747-genevieve-o-reilly/'
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
id: 294809,
|
|
164
|
-
name: 'Luoyong Wang',
|
|
165
|
-
url: 'https://www.csfd.cz/tvurce/294809-luoyong-wang/'
|
|
166
|
-
}
|
|
167
|
-
]);
|
|
168
|
-
});
|
|
169
|
-
test('Empty actors', () => {
|
|
170
|
-
const movie = parsePeople(moviesNode[5], 'actors');
|
|
171
|
-
expect(movie).toEqual<CSFDCreator[]>([]);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// TV SERIES
|
|
176
|
-
|
|
177
|
-
describe('Get TV series titles', () => {
|
|
178
|
-
test('First TV series', () => {
|
|
179
|
-
const movie = getTitle(tvSeriesNode[0]);
|
|
180
|
-
expect(movie).toEqual<string>('Matrix');
|
|
181
|
-
});
|
|
182
|
-
test('Last TV series', () => {
|
|
183
|
-
const movie = getTitle(tvSeriesNode[tvSeriesNode.length - 1]);
|
|
184
|
-
expect(movie).toEqual<string>('Futurama - Skoro poslední přání');
|
|
185
|
-
});
|
|
186
|
-
test('Some TV series', () => {
|
|
187
|
-
const movie = getTitle(tvSeriesNode[5]);
|
|
188
|
-
expect(movie).toEqual<string>('MP4orce - Dungeon Matrix');
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
describe('Get TV series years', () => {
|
|
193
|
-
test('First TV series', () => {
|
|
194
|
-
const movie = getYear(tvSeriesNode[0]);
|
|
195
|
-
expect(movie).toEqual<number>(1993);
|
|
196
|
-
});
|
|
197
|
-
test('Last TV series', () => {
|
|
198
|
-
const movie = getYear(tvSeriesNode[tvSeriesNode.length - 1]);
|
|
199
|
-
expect(movie).toEqual<number>(2012);
|
|
200
|
-
});
|
|
201
|
-
test('Some TV series', () => {
|
|
202
|
-
const movie = getYear(tvSeriesNode[4]);
|
|
203
|
-
expect(movie).toEqual<number>(2020);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('Get TV series url', () => {
|
|
208
|
-
test('First TV series', () => {
|
|
209
|
-
const movie = getUrl(tvSeriesNode[0]);
|
|
210
|
-
expect(movie).toEqual<string>('/film/72014-matrix/');
|
|
211
|
-
});
|
|
212
|
-
test('Last TV series', () => {
|
|
213
|
-
const movie = getUrl(tvSeriesNode[tvSeriesNode.length - 1]);
|
|
214
|
-
expect(movie).toEqual<string>('/film/77748-futurama/483972-skoro-posledni-prani/');
|
|
215
|
-
});
|
|
216
|
-
test('Some TV series', () => {
|
|
217
|
-
const movie = getUrl(tvSeriesNode[4]);
|
|
218
|
-
expect(movie).toEqual<string>('/film/999565-escape-the-matrix/');
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe('Get TV series types', () => {
|
|
223
|
-
test('First TV series', () => {
|
|
224
|
-
const movie = getType(tvSeriesNode[0]);
|
|
225
|
-
expect(movie).toEqual<CSFDFilmTypes>('seriál');
|
|
226
|
-
});
|
|
227
|
-
test('Last TV series', () => {
|
|
228
|
-
const movie = getType(tvSeriesNode[tvSeriesNode.length - 1]);
|
|
229
|
-
expect(movie).toEqual<CSFDFilmTypes>('epizoda');
|
|
230
|
-
});
|
|
231
|
-
test('Some TV series', () => {
|
|
232
|
-
const movie = getType(tvSeriesNode[1]);
|
|
233
|
-
expect(movie).toEqual<CSFDFilmTypes>('epizoda');
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
describe('Get TV series colors', () => {
|
|
238
|
-
test('First TV series', () => {
|
|
239
|
-
const movie = getColorRating(tvSeriesNode[0]);
|
|
240
|
-
expect(movie).toEqual<CSFDColorRating>('good');
|
|
241
|
-
});
|
|
242
|
-
test('Last TV series', () => {
|
|
243
|
-
const movie = getColorRating(tvSeriesNode[3]);
|
|
244
|
-
expect(movie).toEqual<CSFDColorRating>('average');
|
|
245
|
-
});
|
|
246
|
-
test('Some TV series', () => {
|
|
247
|
-
const movie = getColorRating(tvSeriesNode[5]);
|
|
248
|
-
expect(movie).toEqual<CSFDColorRating>('unknown');
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
describe('Get TV series posters', () => {
|
|
253
|
-
test('Some TV series', () => {
|
|
254
|
-
const movie = getPoster(tvSeriesNode[2]);
|
|
255
|
-
expect(movie).toEqual<string>(
|
|
256
|
-
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
|
257
|
-
);
|
|
258
|
-
});
|
|
259
|
-
test('Empty poster', () => {
|
|
260
|
-
const movie = getPoster(tvSeriesNode[4]);
|
|
261
|
-
expect(movie).toEqual<string>(
|
|
262
|
-
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
|
263
|
-
);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe('Get TV series origins', () => {
|
|
268
|
-
test('First TV series', () => {
|
|
269
|
-
const movie = getOrigins(tvSeriesNode[0]);
|
|
270
|
-
expect(movie).toEqual<string[]>(['Kanada']);
|
|
271
|
-
});
|
|
272
|
-
test('Second TV series', () => {
|
|
273
|
-
const movie = getOrigins(tvSeriesNode[1]);
|
|
274
|
-
expect(movie).toEqual<string[]>(['Česko']);
|
|
275
|
-
});
|
|
276
|
-
test('Third TV series', () => {
|
|
277
|
-
const movie = getOrigins(tvSeriesNode[2]);
|
|
278
|
-
expect(movie).toEqual<string[]>(['USA', 'Kanada']);
|
|
279
|
-
});
|
|
280
|
-
test('Some TV series', () => {
|
|
281
|
-
const movie = getOrigins(tvSeriesNode[4]);
|
|
282
|
-
expect(movie).toEqual<string[]>(['Velká Británie']);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('Get TV series creators', () => {
|
|
287
|
-
test('First TV series directors', () => {
|
|
288
|
-
const movie = parsePeople(tvSeriesNode[0], 'directors');
|
|
289
|
-
expect(movie).toEqual<CSFDCreator[]>([
|
|
290
|
-
{
|
|
291
|
-
id: 8877,
|
|
292
|
-
name: 'Allan Eastman',
|
|
293
|
-
url: 'https://www.csfd.cz/tvurce/8877-allan-eastman/'
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
id: 8686,
|
|
297
|
-
name: 'Mario Azzopardi',
|
|
298
|
-
url: 'https://www.csfd.cz/tvurce/8686-mario-azzopardi/'
|
|
299
|
-
}
|
|
300
|
-
]);
|
|
301
|
-
});
|
|
302
|
-
test('Last TV series actors', () => {
|
|
303
|
-
const movie = parsePeople(tvSeriesNode[tvSeriesNode.length - 1], 'actors');
|
|
304
|
-
expect(movie).toEqual<CSFDCreator[]>([
|
|
305
|
-
{
|
|
306
|
-
id: 20335,
|
|
307
|
-
name: 'Billy West',
|
|
308
|
-
url: 'https://www.csfd.cz/tvurce/20335-billy-west/'
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
id: 1931,
|
|
312
|
-
name: 'Katey Sagal',
|
|
313
|
-
url: 'https://www.csfd.cz/tvurce/1931-katey-sagal/'
|
|
314
|
-
}
|
|
315
|
-
]);
|
|
316
|
-
});
|
|
317
|
-
test('Empty actors', () => {
|
|
318
|
-
const movie = parsePeople(tvSeriesNode[5], 'actors');
|
|
319
|
-
expect(movie).toEqual<CSFDCreator[]>([]);
|
|
320
|
-
});
|
|
321
|
-
test('Empty directors + some actors', () => {
|
|
322
|
-
const movie = parsePeople(tvSeriesNode[4], 'actors');
|
|
323
|
-
const movieDirectors = parsePeople(tvSeriesNode[4], 'directors');
|
|
324
|
-
expect(movie).toEqual<CSFDCreator[]>([
|
|
325
|
-
{
|
|
326
|
-
id: 61834,
|
|
327
|
-
name: 'David Icke',
|
|
328
|
-
url: 'https://www.csfd.cz/tvurce/61834-david-icke/'
|
|
329
|
-
}
|
|
330
|
-
]);
|
|
331
|
-
expect(movieDirectors).toEqual<CSFDCreator[]>([]);
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// USERS
|
|
336
|
-
|
|
337
|
-
describe('Get Users name', () => {
|
|
338
|
-
test('First user', () => {
|
|
339
|
-
const movie = getUser(usersNode[0]);
|
|
340
|
-
expect(movie).toEqual<string>('Matrix44');
|
|
341
|
-
});
|
|
342
|
-
test('Last user', () => {
|
|
343
|
-
const movie = getUser(usersNode[usersNode.length - 1]);
|
|
344
|
-
expect(movie).toEqual<string>('Atrix');
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
describe('Get Users real name', () => {
|
|
349
|
-
test('First user', () => {
|
|
350
|
-
const movie = getUserRealName(usersNode[0]);
|
|
351
|
-
expect(movie).toEqual<string>('Matrix 44');
|
|
352
|
-
});
|
|
353
|
-
test('Some name (nothing)', () => {
|
|
354
|
-
const movie = getUserRealName(usersNode[3]);
|
|
355
|
-
expect(movie).toEqual(null);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
describe('Get Users avatar', () => {
|
|
360
|
-
test('First user', () => {
|
|
361
|
-
const movie = getAvatar(usersNode[0]);
|
|
362
|
-
expect(movie).toEqual<string>(
|
|
363
|
-
'https://image.pmgstatic.com/cache/resized/w45h60crop/files/images/user/avatars/000/327/327230_b48a6e.jpg'
|
|
364
|
-
);
|
|
365
|
-
});
|
|
366
|
-
test('Some name (nothing)', () => {
|
|
367
|
-
const movie = getAvatar(usersNode[3]);
|
|
368
|
-
expect(movie).toEqual<string>(
|
|
369
|
-
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
|
370
|
-
);
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
describe('Get Users url', () => {
|
|
375
|
-
test('First user', () => {
|
|
376
|
-
const movie = getUserUrl(usersNode[0]);
|
|
377
|
-
expect(movie).toEqual<string>('/uzivatel/100416-matrix44/');
|
|
378
|
-
});
|
|
379
|
-
});
|
package/tests/season.test.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { csfd } from '../src';
|
|
3
|
-
import { CSFDSeason } from '../src/interfaces/season.interface';
|
|
4
|
-
|
|
5
|
-
describe('season', () => {
|
|
6
|
-
test('gets season details for big bang theory', async () => {
|
|
7
|
-
const expectedSeason: CSFDSeason = {
|
|
8
|
-
description: "Dva fyzici Leonard a Sheldon rozumí úplně všemu, od nepřekonatelné gravitace černých děr po spletitou strukturu atomů. Jenže když vezmete ty atomy a zformujete z nich ženu, jsou oba vědátoři v koncích. Když se do sousedního bytu přistěhuje Penny, žena se všemi atomy na těch pravých místech, začne se soukromý vesmír pánů Leonarda a Sheldona rozpínat do netušených rozměrů. Tvůrci série Chuck Lorre (Dva a půl chlapa) a Bill Prady (Dharma & Greg) vytvořili skvělou melanž vědy, superhrdinů i sexu. Johnny Galecki (Roseanne) a Jim Parsons (Soudkyně Amy) v hlavních rolích rozesmějí každého. (Magic Box)",
|
|
9
|
-
thumbnail: "//image.pmgstatic.com/cache/resized/w140/files/images/film/posters/157/797/157797756_1d26d3.jpg",
|
|
10
|
-
episodeList: [
|
|
11
|
-
{
|
|
12
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470331-pilot/",
|
|
13
|
-
"name": "Pilot",
|
|
14
|
-
"seasonEpisodeIdentifier": " (S01E01)"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470332-hypoteza-otrubove-vlakniny/",
|
|
18
|
-
"name": "Hypotéza otrubové vlákniny",
|
|
19
|
-
"seasonEpisodeIdentifier": " (S01E02)"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470333-korolar-serzanta-snehulky/",
|
|
23
|
-
"name": "Korolár seržanta Sněhulky",
|
|
24
|
-
"seasonEpisodeIdentifier": " (S01E03)"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470334-efekt-svetelkujici-rybky/",
|
|
28
|
-
"name": "Efekt světélkující rybky",
|
|
29
|
-
"seasonEpisodeIdentifier": " (S01E04)"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470335-hamburgerovy-postulat/",
|
|
33
|
-
"name": "Hamburgerový postulát",
|
|
34
|
-
"seasonEpisodeIdentifier": " (S01E05)"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470336-paradigma-pana-prstenu/",
|
|
38
|
-
"name": "Paradigma Pána prstenů",
|
|
39
|
-
"seasonEpisodeIdentifier": " (S01E06)"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470337-knedlickovy-paradox/",
|
|
43
|
-
"name": "Knedlíčkový paradox",
|
|
44
|
-
"seasonEpisodeIdentifier": " (S01E07)"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470338-koktejlovy-experiment/",
|
|
48
|
-
"name": "Koktejlový experiment",
|
|
49
|
-
"seasonEpisodeIdentifier": " (S01E08)"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470339-cooper-hofstadterova-polarizace/",
|
|
53
|
-
"name": "Cooper-Hofstadterova polarizace",
|
|
54
|
-
"seasonEpisodeIdentifier": " (S01E09)"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470340-loobenfelduv-rozpad/",
|
|
58
|
-
"name": "Loobenfeldův rozpad",
|
|
59
|
-
"seasonEpisodeIdentifier": " (S01E10)"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470341-livancova-anomalie/",
|
|
63
|
-
"name": "Lívancová anomálie",
|
|
64
|
-
"seasonEpisodeIdentifier": " (S01E11)"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470342-jeruzalemska-dualita/",
|
|
68
|
-
"name": "Jeruzalémská dualita",
|
|
69
|
-
"seasonEpisodeIdentifier": " (S01E12)"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470343-batnadoba-a-chybny-predpoklad/",
|
|
73
|
-
"name": "Batnádoba a chybný předpoklad",
|
|
74
|
-
"seasonEpisodeIdentifier": " (S01E13)"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470344-zkaza-mimonoraje/",
|
|
78
|
-
"name": "Zkáza mimoňoráje",
|
|
79
|
-
"seasonEpisodeIdentifier": " (S01E14)"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470345-rostenkove-distribucni-dilema/",
|
|
83
|
-
"name": "Roštěnkové distribuční dilema",
|
|
84
|
-
"seasonEpisodeIdentifier": " (S01E15)"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470346-reakce-na-arasidy/",
|
|
88
|
-
"name": "Reakce na arašídy",
|
|
89
|
-
"seasonEpisodeIdentifier": " (S01E16)"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"linkToDetail": "/film/234260-teorie-velkeho-tresku/470347-mandarinkovy-faktor/",
|
|
93
|
-
"name": "Mandarinkový faktor",
|
|
94
|
-
"seasonEpisodeIdentifier": " (S01E17)"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
origin: 'USA, \n\t\t\t\t\t\t\t(2007–2008), 5 h 57 min\n\t\t\t\t\t\t\t(Minutáž: 20–23 min)\n\n\t\t\t\t\t\t'
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const season = await csfd.seasonDetails("/film/234260-teorie-velkeho-tresku/470330-serie-1/")
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
expect(trimWhiteSpace(season)).toEqual(trimWhiteSpace(expectedSeason))
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
function trimWhiteSpace(season: CSFDSeason): CSFDSeason {
|
|
109
|
-
return {
|
|
110
|
-
...season,
|
|
111
|
-
description: season.description.replace(/\s/g, ""),
|
|
112
|
-
origin: season.origin.replace(/\s/g, ""),
|
|
113
|
-
thumbnail: season.thumbnail.replace(/\s/g, ""),
|
|
114
|
-
}
|
|
115
|
-
}
|
package/tests/services.test.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { CSFDUserRatings } from '../src/interfaces/user-ratings.interface';
|
|
3
|
-
import { UserRatingsScraper } from '../src/services/user-ratings.service';
|
|
4
|
-
|
|
5
|
-
// Live API tests
|
|
6
|
-
const USER = 912;
|
|
7
|
-
const USER2 = 228645;
|
|
8
|
-
|
|
9
|
-
describe('Simple call', () => {
|
|
10
|
-
// Fetch data with excludes
|
|
11
|
-
const userRatingsScraper = new UserRatingsScraper();
|
|
12
|
-
const res: Promise<CSFDUserRatings[]> = userRatingsScraper.userRatings(USER);
|
|
13
|
-
|
|
14
|
-
test('Should have some movies', async () => {
|
|
15
|
-
const results = await res;
|
|
16
|
-
|
|
17
|
-
const films = results.filter((item) => item.type === 'film');
|
|
18
|
-
expect(films.length).toBeGreaterThan(10);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('AllPages', async () => {
|
|
23
|
-
const userRatingsScraper = new UserRatingsScraper();
|
|
24
|
-
const res: Promise<CSFDUserRatings[]> = userRatingsScraper.userRatings(USER2, {
|
|
25
|
-
allPages: true,
|
|
26
|
-
allPagesDelay: 100
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('Should have exact number of movies', async () => {
|
|
30
|
-
const results = await res;
|
|
31
|
-
expect(results.length).toBeCloseTo(181);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('Filter out episodes, TV Series and Seasons', () => {
|
|
36
|
-
// Fetch data with excludes
|
|
37
|
-
const userRatingsScraper = new UserRatingsScraper();
|
|
38
|
-
const resExcluded: Promise<CSFDUserRatings[]> = userRatingsScraper.userRatings(USER, {
|
|
39
|
-
excludes: ['epizoda', 'seriál', 'série']
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('Should not have any episode', async () => {
|
|
43
|
-
const results = await resExcluded;
|
|
44
|
-
|
|
45
|
-
const episodes = results.filter((item) => item.type === 'epizoda');
|
|
46
|
-
expect(episodes.length).toBe<number>(0);
|
|
47
|
-
});
|
|
48
|
-
test('Should not have any TV series', async () => {
|
|
49
|
-
const results = await resExcluded;
|
|
50
|
-
const tvSeries = results.filter((item) => item.type === 'seriál');
|
|
51
|
-
expect(tvSeries.length).toBe<number>(0);
|
|
52
|
-
});
|
|
53
|
-
test('Should not have any Season', async () => {
|
|
54
|
-
const results = await resExcluded;
|
|
55
|
-
const season = results.filter((item) => item.type === 'série');
|
|
56
|
-
expect(season.length).toBe<number>(0);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('Includes only TV series or Episodes or something...', () => {
|
|
61
|
-
// Fetch data with excludes
|
|
62
|
-
const userRatingsScraper = new UserRatingsScraper();
|
|
63
|
-
const resIncluded: Promise<CSFDUserRatings[]> = userRatingsScraper.userRatings(USER, {
|
|
64
|
-
includesOnly: ['série']
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('Should not have any film', async () => {
|
|
68
|
-
const results = await resIncluded;
|
|
69
|
-
|
|
70
|
-
const films = results.filter((item) => item.type === 'film');
|
|
71
|
-
expect(films.length).toBe<number>(0);
|
|
72
|
-
});
|
|
73
|
-
test('Should have some season', async () => {
|
|
74
|
-
const results = await resIncluded;
|
|
75
|
-
console.log(results);
|
|
76
|
-
|
|
77
|
-
const tvSeries = results.filter((item) => item.type === 'série');
|
|
78
|
-
expect(tvSeries.length).toBeGreaterThan(0);
|
|
79
|
-
});
|
|
80
|
-
test('Should have only TV series', async () => {
|
|
81
|
-
const results = await resIncluded;
|
|
82
|
-
|
|
83
|
-
const tvSeries = results.filter((item) => item.type === 'série');
|
|
84
|
-
expect(tvSeries.length).toBe(results.length);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('Exclude + includes together', () => {
|
|
89
|
-
// Fetch data with excludes + includes
|
|
90
|
-
const userRatingsScraper = new UserRatingsScraper();
|
|
91
|
-
const resBoth: Promise<CSFDUserRatings[]> = userRatingsScraper.userRatings(USER, {
|
|
92
|
-
includesOnly: ['seriál'],
|
|
93
|
-
excludes: ['film']
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('Should have warning', () => {
|
|
97
|
-
expect(console.warn).toHaveBeenCalled;
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('Should use includesOnly', async () => {
|
|
101
|
-
const results = await resBoth;
|
|
102
|
-
|
|
103
|
-
const tvSeries = results.filter((item) => item.type === 'seriál');
|
|
104
|
-
expect(tvSeries.length).toBe<number>(results.length);
|
|
105
|
-
});
|
|
106
|
-
});
|