1
- import { describe , expect , test } from 'vitest' ;
1
+ import { beforeAll , describe , expect , test } from 'vitest' ;
2
2
import { csfd } from '../src' ;
3
+ import { CSFDCinema } from '../src/dto/cinema' ;
3
4
import { CSFDCreatorScreening } from '../src/dto/creator' ;
4
5
import { CSFDColorRating , CSFDFilmTypes } from '../src/dto/global' ;
5
6
import { fetchPage } from '../src/fetchers' ;
@@ -52,6 +53,9 @@ describe('Live: Movie page', () => {
52
53
expect ( movie . year ) . toEqual < number > ( 1994 ) ;
53
54
expect ( movie . title ) . toEqual < string > ( 'Království' ) ;
54
55
} ) ;
56
+ test ( 'Fetch not number' , async ( ) => {
57
+ await expect ( csfd . movie ( 'test' as any ) ) . rejects . toThrow ( Error ) ;
58
+ } ) ;
55
59
} ) ;
56
60
57
61
// Search
@@ -66,6 +70,33 @@ describe('Live: Search', () => {
66
70
} ) ;
67
71
} ) ;
68
72
73
+ // Search
74
+ describe ( 'Live: Cinemas' , ( ) => {
75
+ let cinemas : CSFDCinema [ ]
76
+ beforeAll ( async ( ) => {
77
+ cinemas = await csfd . cinema ( 1 , 'today' ) ;
78
+ } ) ;
79
+ test ( 'Check city' , async ( ) => {
80
+ const pragueCinemas = cinemas . filter ( ( x ) => x . city . includes ( 'Praha' ) ) ;
81
+ expect ( pragueCinemas . length ) . toBeGreaterThan ( 0 ) ;
82
+ } ) ;
83
+ test ( 'Check screenings' , async ( ) => {
84
+ const screenings = cinemas [ 0 ] . screenings ;
85
+ expect ( screenings . length ) . toBeGreaterThan ( 0 ) ;
86
+ } ) ;
87
+ test ( 'Check screenings' , async ( ) => {
88
+ const film = cinemas [ 0 ] . screenings [ 0 ] . films [ 0 ] ;
89
+ expect ( film . id ) . toBeDefined ( ) ;
90
+ expect ( film . meta ) . toBeDefined ( ) ;
91
+ expect ( film . title ) . toBeDefined ( ) ;
92
+ expect ( film . url ) . toContain ( '/film/' ) ;
93
+ } ) ;
94
+ test ( 'Check showtimes' , async ( ) => {
95
+ const film = cinemas [ 0 ] . screenings [ 0 ] . films [ 1 ] . showTimes [ 0 ] ;
96
+ expect ( film ) . toBeDefined ( ) ;
97
+ } ) ;
98
+ } ) ;
99
+
69
100
// Creator
70
101
describe ( 'Live: Creator page' , ( ) => {
71
102
test ( 'Fetch `2018-jan-werich` creator' , async ( ) => {
@@ -81,6 +112,9 @@ describe('Live: Creator page', () => {
81
112
colorRating : 'good'
82
113
} ) ;
83
114
} ) ;
115
+ test ( 'Fetch not number' , async ( ) => {
116
+ await expect ( csfd . creator ( 'test' as any ) ) . rejects . toThrow ( Error ) ;
117
+ } ) ;
84
118
} ) ;
85
119
86
120
// Edge cases
0 commit comments