Skip to content

Commit cd5c6ab

Browse files
committed
test: add more tests
1 parent 3d710ee commit cd5c6ab

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

tests/cinema.service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from 'vitest';
2-
import { CSFDCinema } from '../src/dto/cinema.interface';
2+
import { CSFDCinema } from '../src/dto/cinema';
33
import { CinemaScraper } from '../src/services/cinema.service';
44

55
const DISTRICT = 1;

tests/creator.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('Composer info', () => {
146146

147147
test('Bio', () => {
148148
const creator = getCreatorBio(asideNodeComposer);
149-
expect(creator).toEqual<string>(null as any);
149+
expect(creator).toEqual(null);
150150
});
151151

152152
test('Photo', () => {

tests/fetchers.test.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { describe, expect, test } from 'vitest';
1+
import { beforeAll, describe, expect, test } from 'vitest';
22
import { csfd } from '../src';
3+
import { CSFDCinema } from '../src/dto/cinema';
34
import { CSFDCreatorScreening } from '../src/dto/creator';
45
import { CSFDColorRating, CSFDFilmTypes } from '../src/dto/global';
56
import { fetchPage } from '../src/fetchers';
@@ -52,6 +53,9 @@ describe('Live: Movie page', () => {
5253
expect(movie.year).toEqual<number>(1994);
5354
expect(movie.title).toEqual<string>('Království');
5455
});
56+
test('Fetch not number', async () => {
57+
await expect(csfd.movie('test' as any)).rejects.toThrow(Error);
58+
});
5559
});
5660

5761
// Search
@@ -66,6 +70,33 @@ describe('Live: Search', () => {
6670
});
6771
});
6872

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+
69100
// Creator
70101
describe('Live: Creator page', () => {
71102
test('Fetch `2018-jan-werich` creator', async () => {
@@ -81,6 +112,9 @@ describe('Live: Creator page', () => {
81112
colorRating: 'good'
82113
});
83114
});
115+
test('Fetch not number', async () => {
116+
await expect(csfd.creator('test' as any)).rejects.toThrow(Error);
117+
});
84118
});
85119

86120
// Edge cases

0 commit comments

Comments
 (0)