Skip to content

Commit b7ecfd9

Browse files
committed
test: add tests for all modules
1 parent 5fb3ef1 commit b7ecfd9

File tree

39 files changed

+21616
-6684
lines changed

39 files changed

+21616
-6684
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`AlbumController > retrieve album by id 1`] = `
4+
{
5+
"artists": {
6+
"all": [
7+
{
8+
"id": "1274170",
9+
"image": [
10+
{
11+
"quality": "50x50",
12+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_50x50.jpg",
13+
},
14+
{
15+
"quality": "150x150",
16+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_150x150.jpg",
17+
},
18+
{
19+
"quality": "500x500",
20+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_500x500.jpg",
21+
},
22+
],
23+
"name": "Dua Lipa",
24+
"role": "",
25+
"type": "artist",
26+
"url": "https://www.jiosaavn.com/artist/dua-lipa-songs/r-OWIKgpX2I_",
27+
},
28+
],
29+
"featured": [],
30+
"primary": [
31+
{
32+
"id": "1274170",
33+
"image": [
34+
{
35+
"quality": "50x50",
36+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_50x50.jpg",
37+
},
38+
{
39+
"quality": "150x150",
40+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_150x150.jpg",
41+
},
42+
{
43+
"quality": "500x500",
44+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_500x500.jpg",
45+
},
46+
],
47+
"name": "Dua Lipa",
48+
"role": "",
49+
"type": "artist",
50+
"url": "https://www.jiosaavn.com/artist/dua-lipa-songs/r-OWIKgpX2I_",
51+
},
52+
],
53+
},
54+
"description": "2020 · English Album · Dua Lipa",
55+
"explicitContent": true,
56+
"id": "23241654",
57+
"image": [
58+
{
59+
"quality": "50x50",
60+
"url": "https://c.saavncdn.com/665/Future-Nostalgia-English-2020-20231110075246-50x50.jpg",
61+
},
62+
{
63+
"quality": "150x150",
64+
"url": "https://c.saavncdn.com/665/Future-Nostalgia-English-2020-20231110075246-150x150.jpg",
65+
},
66+
{
67+
"quality": "500x500",
68+
"url": "https://c.saavncdn.com/665/Future-Nostalgia-English-2020-20231110075246-500x500.jpg",
69+
},
70+
],
71+
"language": "english",
72+
"name": "Future Nostalgia",
73+
"playCount": Any<Number>,
74+
"songCount": Any<Number>,
75+
"songs": ArrayContaining [
76+
ObjectContaining {
77+
"playCount": Any<Number>,
78+
},
79+
],
80+
"type": "album",
81+
"url": "https://www.jiosaavn.com/album/future-nostalgia/ITIyo-GDr7A_",
82+
"year": 2020,
83+
}
84+
`;
85+
86+
exports[`AlbumController > retrieve album by link 1`] = `
87+
{
88+
"artists": {
89+
"all": [
90+
{
91+
"id": "1274170",
92+
"image": [
93+
{
94+
"quality": "50x50",
95+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_50x50.jpg",
96+
},
97+
{
98+
"quality": "150x150",
99+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_150x150.jpg",
100+
},
101+
{
102+
"quality": "500x500",
103+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_500x500.jpg",
104+
},
105+
],
106+
"name": "Dua Lipa",
107+
"role": "",
108+
"type": "artist",
109+
"url": "https://www.jiosaavn.com/artist/dua-lipa-songs/r-OWIKgpX2I_",
110+
},
111+
],
112+
"featured": [],
113+
"primary": [
114+
{
115+
"id": "1274170",
116+
"image": [
117+
{
118+
"quality": "50x50",
119+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_50x50.jpg",
120+
},
121+
{
122+
"quality": "150x150",
123+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_150x150.jpg",
124+
},
125+
{
126+
"quality": "500x500",
127+
"url": "https://c.saavncdn.com/artists/Dua_Lipa_004_20231120090922_500x500.jpg",
128+
},
129+
],
130+
"name": "Dua Lipa",
131+
"role": "",
132+
"type": "artist",
133+
"url": "https://www.jiosaavn.com/artist/dua-lipa-songs/r-OWIKgpX2I_",
134+
},
135+
],
136+
},
137+
"description": "2020 · English Album · Dua Lipa",
138+
"explicitContent": true,
139+
"id": "23241654",
140+
"image": [
141+
{
142+
"quality": "50x50",
143+
"url": "https://c.saavncdn.com/665/Future-Nostalgia-English-2020-20231110075246-50x50.jpg",
144+
},
145+
{
146+
"quality": "150x150",
147+
"url": "https://c.saavncdn.com/665/Future-Nostalgia-English-2020-20231110075246-150x150.jpg",
148+
},
149+
{
150+
"quality": "500x500",
151+
"url": "https://c.saavncdn.com/665/Future-Nostalgia-English-2020-20231110075246-500x500.jpg",
152+
},
153+
],
154+
"language": "english",
155+
"name": "Future Nostalgia",
156+
"playCount": Any<Number>,
157+
"songCount": Any<Number>,
158+
"songs": ArrayContaining [
159+
ObjectContaining {
160+
"playCount": Any<Number>,
161+
},
162+
],
163+
"type": "album",
164+
"url": "https://www.jiosaavn.com/album/future-nostalgia/ITIyo-GDr7A_",
165+
"year": 2020,
166+
}
167+
`;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { beforeAll, describe, expect, it } from 'vitest'
2+
import type { z } from 'zod'
3+
import type { AlbumModel } from '#modules/albums/models'
4+
import { AlbumController } from '#modules/index'
5+
6+
describe('AlbumController', () => {
7+
let albumController: AlbumController
8+
9+
beforeAll(() => {
10+
albumController = new AlbumController()
11+
albumController.initRoutes()
12+
})
13+
14+
it('retrieve album by link', async () => {
15+
const response = await albumController.controller.request(
16+
'/albums?link=https://www.jiosaavn.com/album/future-nostalgia/ITIyo-GDr7A_'
17+
)
18+
19+
const wow = (await response.json()) as { data: z.infer<typeof AlbumModel> }
20+
21+
expect(wow.data).toMatchSnapshot({
22+
playCount: expect.any(Number),
23+
songCount: expect.any(Number),
24+
songs: expect.arrayContaining([
25+
expect.objectContaining({
26+
playCount: expect.any(Number)
27+
})
28+
])
29+
})
30+
})
31+
32+
it('retrieve album by id', async () => {
33+
const response = await albumController.controller.request('/albums?id=23241654')
34+
35+
const { data } = (await response.json()) as { data: z.infer<typeof AlbumModel> }
36+
37+
expect(data).toMatchSnapshot({
38+
playCount: expect.any(Number),
39+
songCount: expect.any(Number),
40+
songs: expect.arrayContaining([
41+
expect.objectContaining({
42+
playCount: expect.any(Number)
43+
})
44+
])
45+
})
46+
})
47+
})

0 commit comments

Comments
 (0)