11import { HTMLElement , parse } from 'node-html-parser' ;
22import { describe , expect , test } from 'vitest' ;
33import {
4- getColorRating ,
5- getDate ,
6- getId ,
7- getTitle ,
8- getType ,
9- getUrl ,
104 getUserRating ,
11- getYear
5+ getUserRatingColorRating ,
6+ getUserRatingDate ,
7+ getUserRatingId ,
8+ getUserRatingTitle ,
9+ getUserRatingType ,
10+ getUserRatingUrl ,
11+ getUserRatingYear
1212} from '../src/helpers/user-ratings.helper' ;
1313import { CSFDColorRating , CSFDFilmTypes , CSFDStars } from '../src/interfaces/global' ;
1414import { userRatingsMock } from './mocks/userRatings.html' ;
@@ -34,109 +34,109 @@ describe('Get Ratings', () => {
3434
3535describe ( 'Get ID' , ( ) => {
3636 test ( 'First ID' , ( ) => {
37- const movie = getId ( movies [ 0 ] ) ;
37+ const movie = getUserRatingId ( movies [ 0 ] ) ;
3838 expect ( movie ) . toEqual < number > ( 1254361 ) ;
3939 } ) ;
4040 test ( 'Last ID' , ( ) => {
41- const movie = getId ( movies [ movies . length - 1 ] ) ;
41+ const movie = getUserRatingId ( movies [ movies . length - 1 ] ) ;
4242 expect ( movie ) . toEqual < number > ( 1169425 ) ;
4343 } ) ;
4444} ) ;
4545
4646describe ( 'Get type' , ( ) => {
4747 test ( 'Film' , ( ) => {
48- const movie = getType ( movies [ 0 ] ) ;
48+ const movie = getUserRatingType ( movies [ 0 ] ) ;
4949 expect ( movie ) . toEqual < CSFDFilmTypes > ( 'film' ) ;
5050 } ) ;
5151 test ( 'TV series' , ( ) => {
52- const movie = getType ( movies [ 23 ] ) ;
52+ const movie = getUserRatingType ( movies [ 23 ] ) ;
5353 expect ( movie ) . toEqual < CSFDFilmTypes > ( 'seriál' ) ;
5454 } ) ;
5555 test ( 'Episode' , ( ) => {
56- const movie = getType ( movies [ 4 ] ) ;
56+ const movie = getUserRatingType ( movies [ 4 ] ) ;
5757 expect ( movie ) . toEqual < CSFDFilmTypes > ( 'epizoda' ) ;
5858 } ) ;
5959 // test('TV film', () => {
60- // const movie = getType (movies[18]);
60+ // const movie = getUserRatingType (movies[18]);
6161 // expect(movie).toEqual<CSFDFilmTypes>('TV film');
6262 // });
6363 // test('Pořad', () => {
64- // const movie = getType (movies[6]);
64+ // const movie = getUserRatingType (movies[6]);
6565 // expect(movie).toEqual<CSFDFilmTypes>('pořad');
6666 // });
6767 test ( 'Amateur film' , ( ) => {
68- const movie = getType ( movies [ 31 ] ) ;
68+ const movie = getUserRatingType ( movies [ 31 ] ) ;
6969 expect ( movie ) . toEqual < CSFDFilmTypes > ( 'amatérský film' ) ;
7070 } ) ;
7171 test ( 'Season' , ( ) => {
72- const movie = getType ( movies [ 11 ] ) ;
72+ const movie = getUserRatingType ( movies [ 11 ] ) ;
7373 expect ( movie ) . toEqual < CSFDFilmTypes > ( 'série' ) ;
7474 } ) ;
7575} ) ;
7676
7777describe ( 'Get title' , ( ) => {
7878 test ( 'First title' , ( ) => {
79- const movie = getTitle ( movies [ 0 ] ) ;
79+ const movie = getUserRatingTitle ( movies [ 0 ] ) ;
8080 expect ( movie ) . toEqual < string > ( 'Stutz' ) ;
8181 } ) ;
8282 test ( 'Last title' , ( ) => {
83- const movie = getTitle ( movies [ movies . length - 1 ] ) ;
83+ const movie = getUserRatingTitle ( movies [ movies . length - 1 ] ) ;
8484 expect ( movie ) . toEqual < string > ( 'Kouření způsobuje kašel' ) ;
8585 } ) ;
8686} ) ;
8787
8888describe ( 'Get year' , ( ) => {
8989 test ( 'First year' , ( ) => {
90- const movie = getYear ( movies [ 0 ] ) ;
90+ const movie = getUserRatingYear ( movies [ 0 ] ) ;
9191 expect ( movie ) . toEqual < number > ( 2022 ) ;
9292 } ) ;
9393 test ( 'Some year' , ( ) => {
94- const movie = getYear ( movies [ 7 ] ) ;
94+ const movie = getUserRatingYear ( movies [ 7 ] ) ;
9595 expect ( movie ) . toEqual < number > ( 2016 ) ;
9696 } ) ;
9797 test ( 'Almost last year' , ( ) => {
98- const movie = getYear ( movies [ movies . length - 7 ] ) ;
98+ const movie = getUserRatingYear ( movies [ movies . length - 7 ] ) ;
9999 expect ( movie ) . toEqual < number > ( 2000 ) ;
100100 } ) ;
101101} ) ;
102102
103103describe ( 'Get color rating' , ( ) => {
104104 // test('Black', () => {
105- // const movie = getColorRating (movies[7]);
105+ // const movie = getUserRatingColorRating (movies[7]);
106106 // expect(movie).toEqual<CSFDColorRating>('bad');
107107 // });
108108 // test('Gray', () => {
109- // const movie = getColorRating (movies[29]);
109+ // const movie = getUserRatingColorRating (movies[29]);
110110 // expect(movie).toEqual<CSFDColorRating>('unknown');
111111 // });
112112 test ( 'Blue' , ( ) => {
113- const movie = getColorRating ( movies [ 3 ] ) ;
113+ const movie = getUserRatingColorRating ( movies [ 3 ] ) ;
114114 expect ( movie ) . toEqual < CSFDColorRating > ( 'average' ) ;
115115 } ) ;
116116 test ( 'Red' , ( ) => {
117- const movie = getColorRating ( movies [ 1 ] ) ;
117+ const movie = getUserRatingColorRating ( movies [ 1 ] ) ;
118118 expect ( movie ) . toEqual < CSFDColorRating > ( 'good' ) ;
119119 } ) ;
120120} ) ;
121121
122122describe ( 'Get date' , ( ) => {
123123 test ( 'First date' , ( ) => {
124- const movie = getDate ( movies [ 0 ] ) ;
124+ const movie = getUserRatingDate ( movies [ 0 ] ) ;
125125 expect ( movie ) . toEqual < string > ( '16.12.2022' ) ;
126126 } ) ;
127127 test ( 'Last date' , ( ) => {
128- const movie = getDate ( movies [ movies . length - 1 ] ) ;
128+ const movie = getUserRatingDate ( movies [ movies . length - 1 ] ) ;
129129 expect ( movie ) . toEqual < string > ( '05.07.2022' ) ;
130130 } ) ;
131131} ) ;
132132
133133describe ( 'Get Url' , ( ) => {
134134 test ( 'First url' , ( ) => {
135- const movie = getUrl ( movies [ 0 ] ) ;
135+ const movie = getUserRatingUrl ( movies [ 0 ] ) ;
136136 expect ( movie ) . toEqual < string > ( 'https://www.csfd.cz/film/1254361-stutz/' ) ;
137137 } ) ;
138138 test ( 'Last url' , ( ) => {
139- const movie = getUrl ( movies [ movies . length - 1 ] ) ;
139+ const movie = getUserRatingUrl ( movies [ movies . length - 1 ] ) ;
140140 expect ( movie ) . toEqual < string > ( 'https://www.csfd.cz/film/1169425-koureni-zpusobuje-kasel/' ) ;
141141 } ) ;
142142} ) ;
0 commit comments