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.
- package/.editorconfig +13 -0
- package/.eslintrc.json +33 -0
- package/.gitattributes +2 -0
- package/.github/FUNDING.yml +8 -0
- package/.github/pull_request_template.md +19 -0
- package/.github/workflows/main.yml +40 -0
- package/.github/workflows/publish.yml +73 -0
- package/.github/workflows/test.yml +43 -0
- package/.husky/pre-commit +1 -0
- package/.idea/codeStyles/Project.xml +72 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/node-csfd-api.iml +9 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +7 -0
- package/.nvmrc +1 -0
- package/.prettierignore +8 -0
- package/.prettierrc +10 -0
- package/.vscode/settings.json +16 -0
- package/Dockerfile +19 -0
- package/README.md +510 -0
- package/demo.ts +35 -0
- package/eslint.config.mjs +55 -0
- package/package.json +86 -0
- package/server.ts +66 -0
- package/src/fetchers/fetch.polyfill.ts +7 -0
- package/src/fetchers/index.ts +25 -0
- package/src/helpers/creator.helper.ts +95 -0
- package/src/helpers/global.helper.ts +70 -0
- package/src/helpers/movie.helper.ts +276 -0
- package/src/helpers/search-user.helper.ts +19 -0
- package/src/helpers/search.helper.ts +66 -0
- package/src/helpers/user-ratings.helper.ts +62 -0
- package/src/index.ts +42 -0
- package/src/interfaces/creator.interface.ts +14 -0
- package/src/interfaces/global.ts +36 -0
- package/src/interfaces/movie.interface.ts +157 -0
- package/src/interfaces/search.interface.ts +32 -0
- package/src/interfaces/user-ratings.interface.ts +21 -0
- package/src/services/creator.service.ts +34 -0
- package/src/services/movie.service.ts +89 -0
- package/src/services/search.service.ts +101 -0
- package/src/services/user-ratings.service.ts +106 -0
- package/src/vars.ts +13 -0
- package/tests/creator.test.ts +182 -0
- package/tests/fetchers.test.ts +109 -0
- package/tests/global.test.ts +35 -0
- package/tests/helpers.test.ts +59 -0
- package/tests/mocks/creator-actor.html.ts +2244 -0
- package/tests/mocks/creator-composer-empty.html.ts +683 -0
- package/tests/mocks/creator-director.html.ts +3407 -0
- package/tests/mocks/movie1.html.ts +1430 -0
- package/tests/mocks/movie2.html.ts +740 -0
- package/tests/mocks/movie3.html.ts +1843 -0
- package/tests/mocks/movie4.html.ts +1568 -0
- package/tests/mocks/search.html.ts +838 -0
- package/tests/mocks/series1.html.ts +1540 -0
- package/tests/mocks/userRatings.html.ts +1354 -0
- package/tests/movie.test.ts +606 -0
- package/tests/search.test.ts +379 -0
- package/tests/services.test.ts +106 -0
- package/tests/user-ratings.test.ts +142 -0
- package/tests/vars.test.ts +34 -0
- package/tsconfig.json +23 -0
- package/vitest.config.mts +10 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { parse } from 'node-html-parser';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import {
|
|
4
|
+
getBio,
|
|
5
|
+
getBirthdayInfo,
|
|
6
|
+
getFilms,
|
|
7
|
+
getName,
|
|
8
|
+
getPhoto
|
|
9
|
+
} from '../src/helpers/creator.helper';
|
|
10
|
+
import { CSFDCreatorScreening } from '../src/interfaces/creator.interface';
|
|
11
|
+
import { actorMock } from './mocks/creator-actor.html';
|
|
12
|
+
import { composerMock } from './mocks/creator-composer-empty.html';
|
|
13
|
+
import { directorMock } from './mocks/creator-director.html';
|
|
14
|
+
|
|
15
|
+
const html = parse(directorMock);
|
|
16
|
+
const asideNode = html.querySelector('.creator-about');
|
|
17
|
+
const filmsNode = html.querySelector('.creator-filmography');
|
|
18
|
+
|
|
19
|
+
const htmlActor = parse(actorMock);
|
|
20
|
+
const asideNodeActor = htmlActor.querySelector('.creator-about');
|
|
21
|
+
const filmsNodeActor = htmlActor.querySelector('.creator-filmography');
|
|
22
|
+
|
|
23
|
+
const htmlComposer = parse(composerMock);
|
|
24
|
+
const asideNodeComposer = htmlComposer.querySelector('.creator-about');
|
|
25
|
+
const filmsNodeComposer = htmlComposer.querySelector('.creator-filmography');
|
|
26
|
+
|
|
27
|
+
describe('Creator info', () => {
|
|
28
|
+
test('Name', () => {
|
|
29
|
+
const creator = getName(asideNode);
|
|
30
|
+
expect(creator).toEqual<string>('Quentin Tarantino');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('Bio', () => {
|
|
34
|
+
const creator = getBio(asideNode);
|
|
35
|
+
expect(creator).toEqual<string>(
|
|
36
|
+
'Narodil se teprve šestnáctileté Connii McHugh, která mu dala křestní jméno podle své oblíbené postavy Quinta ze seriálu Gunsmoke. Jeho biologickým otcem byl jistý Tony Tarantino, který rodinu opustil když byl Quentin ještě malinký a nikdy o syna nejevil zájem (přesněji řečeno jen do doby, než se potomek stal slavným – pak se na jeho úspěchu pokoušel parazitovat). Jeho náhradním tatínkem se stal hudebník s československými kořeny, který si Connii vzal a Quentina…'
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('Photo', () => {
|
|
41
|
+
const creator = getPhoto(asideNode);
|
|
42
|
+
expect(creator).toEqual<string>(
|
|
43
|
+
'https://image.pmgstatic.com/cache/resized/w100h132crop/files/images/creator/photos/164/515/164515525_b98f8a.jpg'
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('Creator birthday info', () => {
|
|
49
|
+
test('Birthday', () => {
|
|
50
|
+
const creator = getBirthdayInfo(asideNode)?.birthday;
|
|
51
|
+
expect(creator).toEqual<string>('27.03.1963');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('Birthplace', () => {
|
|
55
|
+
const creator = getBirthdayInfo(asideNode)?.birthPlace;
|
|
56
|
+
expect(creator).toEqual<string>('Knoxville, Tennessee, USA');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Age', () => {
|
|
60
|
+
const creator = getBirthdayInfo(asideNode)?.age;
|
|
61
|
+
expect(creator).toEqual<number>(61);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe("Creator's films", () => {
|
|
66
|
+
test('First film from first section', () => {
|
|
67
|
+
const films = getFilms(filmsNode) as CSFDCreatorScreening[];
|
|
68
|
+
expect(films[0].title).toEqual<string>('The Movie Critic');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('Last film from first section', () => {
|
|
72
|
+
const films = getFilms(filmsNode) as CSFDCreatorScreening[];
|
|
73
|
+
expect(films[films.length - 1].id).toEqual<number>(1051715);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('Year second movie', () => {
|
|
77
|
+
const films = getFilms(filmsNode) as CSFDCreatorScreening[];
|
|
78
|
+
expect(films[1].year).toEqual<number>(2019);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// actor
|
|
83
|
+
|
|
84
|
+
describe('Actor info', () => {
|
|
85
|
+
test('Name', () => {
|
|
86
|
+
const creator = getName(asideNodeActor);
|
|
87
|
+
expect(creator).toEqual<string>('Mads Mikkelsen');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('Bio', () => {
|
|
91
|
+
const creator = getBio(asideNodeActor);
|
|
92
|
+
expect(creator).toEqual<string>(
|
|
93
|
+
'Dánský herec, celým jménem Mads Dittmann Mikkelsen, se narodil v roce 1965 v kodaňské čtvrti Østerbro. Dříve než se vrhl na hereckou dráhu, pracoval 8 let jako profesionální tanečník. Herecké vzdělání získal Mikkelsen na herecké škole při divadle v Århusu. Školu zakončil v roce 1996. Co se týká soukromého života je Mads Mikkelsen, který za svůj nejoblíbenější film považuje Taxikáře od Martina Scorseseho, od roku 1987 ženatý s dánskou choreografkou Hanne Jacobsen.…'
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('Photo', () => {
|
|
98
|
+
const creator = getPhoto(asideNodeActor);
|
|
99
|
+
expect(creator).toEqual<string>(
|
|
100
|
+
'https://image.pmgstatic.com/cache/resized/w100h132crop/files/images/creator/photos/166/233/166233274_298dbd.jpg'
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('Actor birthday info', () => {
|
|
106
|
+
test('Birthday', () => {
|
|
107
|
+
const creator = getBirthdayInfo(asideNodeActor)?.birthday;
|
|
108
|
+
expect(creator).toEqual<string>('22.11.1965');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('Birthplace', () => {
|
|
112
|
+
const creator = getBirthdayInfo(asideNodeActor)?.birthPlace;
|
|
113
|
+
expect(creator).toEqual<string>('Østerbro, København, Dánsko');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('Age', () => {
|
|
117
|
+
const creator = getBirthdayInfo(asideNodeActor)?.age;
|
|
118
|
+
expect(creator).toEqual<number>(58);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("Creator's films", () => {
|
|
123
|
+
test('First film from first section', () => {
|
|
124
|
+
const films = getFilms(filmsNodeActor) as CSFDCreatorScreening[];
|
|
125
|
+
expect(films[0].title).toEqual<string>('The Billion Dollar Spy');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('Last film from first section', () => {
|
|
129
|
+
const films = getFilms(filmsNodeActor) as CSFDCreatorScreening[];
|
|
130
|
+
expect(films[films.length - 1].id).toEqual<number>(88874);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('Year second movie', () => {
|
|
134
|
+
const films = getFilms(filmsNodeActor) as CSFDCreatorScreening[];
|
|
135
|
+
expect(films[1].year).toEqual<number>(2025);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// composer
|
|
140
|
+
|
|
141
|
+
describe('Composer info', () => {
|
|
142
|
+
test('Name', () => {
|
|
143
|
+
const creator = getName(asideNodeComposer);
|
|
144
|
+
expect(creator).toEqual<string>('Sven Mikkelsen');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('Bio', () => {
|
|
148
|
+
const creator = getBio(asideNodeComposer);
|
|
149
|
+
expect(creator).toEqual<string>(null);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('Photo', () => {
|
|
153
|
+
const creator = getPhoto(asideNodeComposer);
|
|
154
|
+
expect(creator).toEqual<string>(
|
|
155
|
+
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('Composer birthday info', () => {
|
|
161
|
+
test('Birthday', () => {
|
|
162
|
+
const creator = getBirthdayInfo(asideNodeComposer)?.birthday;
|
|
163
|
+
expect(creator).toEqual<string>('');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('Birthplace', () => {
|
|
167
|
+
const creator = getBirthdayInfo(asideNodeComposer)?.birthPlace;
|
|
168
|
+
expect(creator).toEqual<string>('');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('Birthplace', () => {
|
|
172
|
+
const creator = getBirthdayInfo(asideNodeComposer)?.age;
|
|
173
|
+
expect(creator).toEqual(null);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe("Creator's films", () => {
|
|
178
|
+
test('First film from first section', () => {
|
|
179
|
+
const films = getFilms(filmsNodeComposer) as CSFDCreatorScreening[];
|
|
180
|
+
expect(films[0].title).toEqual<string>('Spolu');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { csfd } from '../src';
|
|
3
|
+
import { fetchPage } from '../src/fetchers';
|
|
4
|
+
import { CSFDCreatorScreening } from '../src/interfaces/creator.interface';
|
|
5
|
+
import { CSFDColorRating, CSFDFilmTypes } from '../src/interfaces/global';
|
|
6
|
+
import { movieUrl, userRatingsUrl } from '../src/vars';
|
|
7
|
+
const badId = 999999999999999;
|
|
8
|
+
|
|
9
|
+
// User Ratings
|
|
10
|
+
describe('Live: Fetch rating page', () => {
|
|
11
|
+
test('Fetch `912-bart` user and check some movie', async () => {
|
|
12
|
+
const MOVIE_NAME = 'Návštěvník';
|
|
13
|
+
|
|
14
|
+
const movies = await csfd.userRatings('912-bart');
|
|
15
|
+
const movieSelected = movies.filter((x) => x.title === MOVIE_NAME)[0];
|
|
16
|
+
expect(movies.map((x) => x.title)).toEqual(expect.arrayContaining([MOVIE_NAME]));
|
|
17
|
+
expect(movieSelected?.year).toEqual<number>(2025);
|
|
18
|
+
expect(movieSelected?.type).toEqual<CSFDFilmTypes>('film');
|
|
19
|
+
expect(movieSelected?.userDate).toContain<string>('2025');
|
|
20
|
+
expect(movies.length).toEqual(50);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Fetch rating page 2', () => {
|
|
25
|
+
test('Fetch `912-bart` user – page 2 and check html', async () => {
|
|
26
|
+
const url = userRatingsUrl(912, 2);
|
|
27
|
+
const html = await fetchPage(url);
|
|
28
|
+
expect(html).toContain('Můj soused Totoro');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Movie
|
|
33
|
+
describe('Live: Movie page', () => {
|
|
34
|
+
test('Fetch `10135-forrest-gump` movie', async () => {
|
|
35
|
+
const movie = await csfd.movie(10135);
|
|
36
|
+
expect(movie.title).toEqual<string>('Forrest Gump');
|
|
37
|
+
expect(movie.rating).toBeGreaterThan(90);
|
|
38
|
+
expect(movie.ratingCount).toBeGreaterThan(100000);
|
|
39
|
+
// More than 10 words in description
|
|
40
|
+
expect(movie.descriptions[0].split(' ').length).toBeGreaterThan(10);
|
|
41
|
+
expect(movie.tags.length).toBeGreaterThan(3);
|
|
42
|
+
expect(movie.year).toEqual(1994);
|
|
43
|
+
expect(movie.type).toEqual<CSFDFilmTypes>('film');
|
|
44
|
+
expect(movie.duration).toBeGreaterThan(140);
|
|
45
|
+
expect(movie.premieres.length).toBeGreaterThan(1);
|
|
46
|
+
expect(movie.colorRating).toEqual<CSFDColorRating>('good');
|
|
47
|
+
expect(movie.creators.directors[0]?.name).toEqual('Robert Zemeckis');
|
|
48
|
+
expect(movie.origins[0]).toEqual<string>('USA');
|
|
49
|
+
});
|
|
50
|
+
test('Fetch `71924-kralovstvi` serial years', async () => {
|
|
51
|
+
const movie = await csfd.movie(71924);
|
|
52
|
+
expect(movie.year).toEqual<number>(1994);
|
|
53
|
+
expect(movie.title).toEqual<string>('Království');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Search
|
|
58
|
+
describe('Live: Search', () => {
|
|
59
|
+
test('Search matrix', async () => {
|
|
60
|
+
const search = await csfd.search('matrix');
|
|
61
|
+
const matrix = search.movies.find((x) => x.title === 'Matrix');
|
|
62
|
+
expect(matrix?.year).toEqual<number>(1999);
|
|
63
|
+
expect(matrix?.creators?.directors.map((x) => x.name)).toEqual<string[]>(
|
|
64
|
+
expect.arrayContaining(['Lilly Wachowski'])
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Creator
|
|
70
|
+
describe('Live: Creator page', () => {
|
|
71
|
+
test('Fetch `2018-jan-werich` creator', async () => {
|
|
72
|
+
const creator = await csfd.creator(2018);
|
|
73
|
+
expect(creator.name).toEqual<string>('Jan Werich');
|
|
74
|
+
expect(creator.birthday).toEqual('06.02.1905');
|
|
75
|
+
expect(creator.birthplace).toContain('Rakousko-Uhersko');
|
|
76
|
+
expect(creator.birthplace).toContain('Praha');
|
|
77
|
+
expect(creator.films.find((film) => film.title === 'Hej-rup!')).toEqual<CSFDCreatorScreening>({
|
|
78
|
+
id: 3106,
|
|
79
|
+
title: 'Hej-rup!',
|
|
80
|
+
year: 1934,
|
|
81
|
+
colorRating: 'good'
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Edge cases
|
|
87
|
+
describe('User page 404', () => {
|
|
88
|
+
test('Fetch error URL', async () => {
|
|
89
|
+
try {
|
|
90
|
+
const url = userRatingsUrl(badId);
|
|
91
|
+
const html = await fetchPage(url);
|
|
92
|
+
expect(html).toBe('Error');
|
|
93
|
+
} catch (e) {
|
|
94
|
+
expect(e).toContain(Error);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('Movie page 404', () => {
|
|
100
|
+
test('Fetch error URL', async () => {
|
|
101
|
+
try {
|
|
102
|
+
const url = movieUrl(badId);
|
|
103
|
+
const html = await fetchPage(url);
|
|
104
|
+
expect(html).toBe('Error');
|
|
105
|
+
} catch (e) {
|
|
106
|
+
expect(e).toThrow(Error);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { getDuration } from '../src/helpers/global.helper';
|
|
3
|
+
|
|
4
|
+
export const durationInput = [
|
|
5
|
+
'PT142M',
|
|
6
|
+
undefined,
|
|
7
|
+
undefined,
|
|
8
|
+
undefined,
|
|
9
|
+
undefined,
|
|
10
|
+
undefined,
|
|
11
|
+
undefined,
|
|
12
|
+
'142',
|
|
13
|
+
undefined,
|
|
14
|
+
{ index: 0 },
|
|
15
|
+
{ input: 'PT142M' },
|
|
16
|
+
{ groups: undefined }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const result = {
|
|
20
|
+
sign: '+',
|
|
21
|
+
years: 0,
|
|
22
|
+
months: 0,
|
|
23
|
+
weeks: 0,
|
|
24
|
+
days: 0,
|
|
25
|
+
hours: 0,
|
|
26
|
+
minutes: '142',
|
|
27
|
+
seconds: 0
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe('Live: Fetch rating page', () => {
|
|
31
|
+
test('Resolve duration', async () => {
|
|
32
|
+
const resolver = getDuration(durationInput);
|
|
33
|
+
expect(resolver).toEqual(result);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { addProtocol, parseColor, parseIdFromUrl } from '../src/helpers/global.helper';
|
|
3
|
+
|
|
4
|
+
describe('Add protocol', () => {
|
|
5
|
+
test('Handle without protocol', () => {
|
|
6
|
+
const url = addProtocol('//www.csfd.cz/uzivatel/912-bart/hodnoceni/');
|
|
7
|
+
expect(url).toBe('https://www.csfd.cz/uzivatel/912-bart/hodnoceni/');
|
|
8
|
+
});
|
|
9
|
+
test('Handle with protocol', () => {
|
|
10
|
+
const url = addProtocol('https://www.csfd.cz/uzivatel/912-bart');
|
|
11
|
+
expect(url).toBe('https://www.csfd.cz/uzivatel/912-bart');
|
|
12
|
+
});
|
|
13
|
+
test('Handle http protocol', () => {
|
|
14
|
+
const url = addProtocol('http://www.csfd.cz/uzivatel/912-bart');
|
|
15
|
+
expect(url).toBe('http://www.csfd.cz/uzivatel/912-bart');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('Parse Id', () => {
|
|
20
|
+
test('Handle whole movie url', () => {
|
|
21
|
+
const url = parseIdFromUrl('https://www.csfd.cz/film/906693-projekt-adam/recenze/');
|
|
22
|
+
expect(url).toBe(null);
|
|
23
|
+
});
|
|
24
|
+
test('Handle movie url', () => {
|
|
25
|
+
const url = parseIdFromUrl('/film/906693-projekt-adam/recenze/');
|
|
26
|
+
expect(url).toBe(906693);
|
|
27
|
+
});
|
|
28
|
+
test('Handle bad url', () => {
|
|
29
|
+
const url = parseIdFromUrl(null as any);
|
|
30
|
+
expect(url).toBe(null);
|
|
31
|
+
});
|
|
32
|
+
test('bad string', () => {
|
|
33
|
+
const url = parseIdFromUrl('bad string');
|
|
34
|
+
expect(url).toBe(null);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('Parse color', () => {
|
|
39
|
+
test('Red', () => {
|
|
40
|
+
const url = parseColor('red');
|
|
41
|
+
expect(url).toBe('good');
|
|
42
|
+
});
|
|
43
|
+
test('Blue', () => {
|
|
44
|
+
const url = parseColor('blue');
|
|
45
|
+
expect(url).toBe('average');
|
|
46
|
+
});
|
|
47
|
+
test('Light grey', () => {
|
|
48
|
+
const url = parseColor('lightgrey');
|
|
49
|
+
expect(url).toBe('unknown');
|
|
50
|
+
});
|
|
51
|
+
test('Grey', () => {
|
|
52
|
+
const url = parseColor('grey');
|
|
53
|
+
expect(url).toBe('bad');
|
|
54
|
+
});
|
|
55
|
+
test('Wrong color', () => {
|
|
56
|
+
const url = parseColor('adas' as any);
|
|
57
|
+
expect(url).toBe('unknown');
|
|
58
|
+
});
|
|
59
|
+
});
|