Skip to content

Commit ff2c385

Browse files
committed
test: add types badge e2e test
1 parent d6fc700 commit ff2c385

File tree

3 files changed

+359
-0
lines changed

3 files changed

+359
-0
lines changed

test/e2e/badge.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ test.describe('badge API', () => {
100100

101101
expect(body).toContain('active')
102102
})
103+
104+
test('types badge shows @types badge', async ({ page, baseURL }) => {
105+
const url = toLocalUrl(baseURL, '/api/registry/badge/types/is-odd')
106+
const { body } = await fetchBadge(page, url)
107+
108+
expect(body).toContain('@types')
109+
})
103110
})
104111

105112
test('custom labelColor parameter is applied to SVG', async ({ page, baseURL }) => {

test/fixtures/mock-routes.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,17 @@ function matchJsdelivrDataApi(urlString) {
422422
const packageMatch = pathname.match(/^\/v1\/packages\/npm\/(.+)$/)
423423
if (packageMatch && packageMatch[1]) {
424424
const parsed = parseScopedPackage(packageMatch[1])
425+
426+
const fixture = readFixture(`jsdelivr/${parsed.name}.json`)
427+
if (fixture) {
428+
return json({
429+
type: 'npm',
430+
name: parsed.name,
431+
version: parsed.version || 'latest',
432+
...fixture,
433+
})
434+
}
435+
425436
return json({
426437
type: 'npm',
427438
name: parsed.name,
Lines changed: 341 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
{
2+
"_id": "@types/is-odd",
3+
"_rev": "357-6aea66bbc40695119f00465c0fa53de3",
4+
"name": "@types/is-odd",
5+
"dist-tags": {
6+
"ts2.0": "3.0.0",
7+
"ts2.1": "3.0.0",
8+
"ts2.2": "3.0.0",
9+
"ts2.3": "3.0.0",
10+
"ts2.4": "3.0.0",
11+
"ts2.5": "3.0.0",
12+
"ts2.6": "3.0.0",
13+
"ts2.7": "3.0.0",
14+
"ts2.8": "3.0.0",
15+
"ts2.9": "3.0.0",
16+
"ts3.0": "3.0.0",
17+
"ts3.1": "3.0.0",
18+
"ts3.2": "3.0.0",
19+
"ts3.3": "3.0.0",
20+
"ts3.4": "3.0.0",
21+
"ts3.5": "3.0.0",
22+
"ts3.6": "3.0.0",
23+
"ts3.7": "3.0.0",
24+
"ts3.8": "3.0.1",
25+
"ts3.9": "3.0.1",
26+
"ts4.0": "3.0.1",
27+
"ts4.1": "3.0.1",
28+
"ts4.2": "3.0.1",
29+
"ts4.3": "3.0.1",
30+
"ts4.4": "3.0.1",
31+
"ts5.8": "3.0.4",
32+
"ts5.7": "3.0.4",
33+
"latest": "3.0.4",
34+
"ts4.5": "3.0.4",
35+
"ts4.6": "3.0.4",
36+
"ts4.7": "3.0.4",
37+
"ts4.8": "3.0.4",
38+
"ts4.9": "3.0.4",
39+
"ts5.0": "3.0.4",
40+
"ts5.1": "3.0.4",
41+
"ts5.2": "3.0.4",
42+
"ts5.3": "3.0.4",
43+
"ts5.4": "3.0.4",
44+
"ts5.5": "3.0.4",
45+
"ts5.9": "3.0.4",
46+
"ts5.6": "3.0.4",
47+
"ts6.0": "3.0.4"
48+
},
49+
"versions": {
50+
"3.0.0": {
51+
"name": "@types/is-odd",
52+
"version": "3.0.0",
53+
"license": "MIT",
54+
"_id": "@types/is-odd@3.0.0",
55+
"maintainers": [
56+
{
57+
"name": "types",
58+
"email": "ts-npm-types@microsoft.com"
59+
}
60+
],
61+
"contributors": [
62+
{
63+
"url": "https://github.com/adamzerella",
64+
"name": " Adam Zerella",
65+
"githubUsername": "adamzerella"
66+
}
67+
],
68+
"dist": {
69+
"shasum": "861b26fa31e656354bb05d63254091f734c461b5",
70+
"tarball": "https://registry.npmjs.org/@types/is-odd/-/is-odd-3.0.0.tgz",
71+
"fileCount": 4,
72+
"integrity": "sha512-XfoBBgqc9DYRWo0V6clOC9cDy9KYELqgWwyulwCkv8/6Hlnd25XbDXGGnWYqOr3GUYIwqp4/gqm7/RtCZvqOJA==",
73+
"signatures": [
74+
{
75+
"sig": "MEUCIQDCb3RyeOCBQWvvgk/slsNiLZrw352GCFOXn7BvVT+33gIgfYjvWpa8EI/H67e8ndZkZLz93oN/dRVTLqnnm1d/1bM=",
76+
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
77+
}
78+
],
79+
"unpackedSize": 2712,
80+
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJccLErCRA9TVsSAnZWagAAQhcP/2Ab+nx4IOo4BGdIySnD\nBONPypFkgSzUa29B81x0SYuFLk9M6lgVhcHLM6s62/HlTDMgT6MHFJdaIHcg\n9xvm/ROaBeKxKcm/iP2yS8OzMZ4GTzNc8t/r1w1GPrUGw5d/3GuEPktSlA3o\nUoVg9tc+QIMog46UGmcXARX6Hv81UGFqHUiV0JgRWQNLvTlUyXFpcpE1esyB\njumZDFuH+E9Bcj/k+DYy+G12lKhMHmTwLOMBN5YI9Cl3dNgnujcFbpKXCf3s\nYBKxjrWblz1l3eT1hk24KRhpOnUm262Y/v1axSeA2l3xxO/feg7MWf9V0fHZ\ndVDa4QBK+w2yt+0rNLJ0I0EqOxk7lMnxLRbbbBRSf4iwiwrzOVAxqwCCG2MW\nRj6ZAXf0/girV4/tXxFZX6maZVWXRiEEKRVWOFuHPAozp6Sdl8dpB8IXjKn6\n4vbGfDqqN2VMLPAfTtevEaZJDM+1/cnpcJSYRFbuzxxG1a9XU75hWNMzOvDZ\n/YhAmtTxNrNNux9DDVtifg0VoIBbIMUZ90/alhaczf0P2yvA5pJ2ktPHumSh\ne0RaiSu70C+ye2MHraEV9/uBoq+U1/ct6XPt1iYE1vQqtc+jf3nBazSDumpA\n2UXV4kmbHCUgg1a/a7xQH7lRgip+Sx776sv3ljRWmb2QUdlzI1gbipsUIZAA\n08K4\r\n=/LEL\r\n-----END PGP SIGNATURE-----\r\n"
81+
},
82+
"main": "",
83+
"types": "index",
84+
"scripts": {},
85+
"_npmUser": {
86+
"name": "types",
87+
"email": "ts-npm-types@microsoft.com"
88+
},
89+
"repository": {
90+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
91+
"type": "git",
92+
"directory": "types/is-odd"
93+
},
94+
"description": "TypeScript definitions for is-odd",
95+
"directories": {},
96+
"dependencies": {},
97+
"_hasShrinkwrap": false,
98+
"typeScriptVersion": "2.0",
99+
"_npmOperationalInternal": {
100+
"tmp": "tmp/is-odd_3.0.0_1550889259065_0.09125334321631584",
101+
"host": "s3://npm-registry-packages"
102+
},
103+
"typesPublisherContentHash": "1dc04627cea88eece89c95a0aed7905067a849634ee4f4bc84b23fa135d0dd02"
104+
},
105+
"3.0.1": {
106+
"name": "@types/is-odd",
107+
"version": "3.0.1",
108+
"license": "MIT",
109+
"_id": "@types/is-odd@3.0.1",
110+
"maintainers": [
111+
{
112+
"name": "types",
113+
"email": "ts-npm-types@microsoft.com"
114+
}
115+
],
116+
"contributors": [
117+
{
118+
"url": "https://github.com/DefinitelyTyped",
119+
"name": "DefinitelyTyped",
120+
"githubUsername": "DefinitelyTyped"
121+
}
122+
],
123+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/is-odd",
124+
"dist": {
125+
"shasum": "b43a16362855c86db3c4df59e36b6eb3e44f555b",
126+
"tarball": "https://registry.npmjs.org/@types/is-odd/-/is-odd-3.0.1.tgz",
127+
"fileCount": 4,
128+
"integrity": "sha512-mY+bL1FNKoF6xEN87ayz2Xk1O5L5L4v0KKheja7bWcqTD3je1w0nYzDVJ3W/bTtzkHJuqEb0UAFANtF5cI2wBg==",
129+
"signatures": [
130+
{
131+
"sig": "MEUCIQCIF54WCx1KAczN/AuO1k/pC1b6pj4o1a6FVbyunJ51BgIgcqi0fG9vJU1hms3h9IUwrrMJVbBMNlH+G4vPbyDsUf4=",
132+
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
133+
}
134+
],
135+
"unpackedSize": 3272,
136+
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhxQ2wCRA9TVsSAnZWagAAPhsP/3HOZ/uL7BMK+rZAXIdE\n0wy77RIsTo/+ZCWlJ3MNPWocIBi+eVfFmRkEIxnD3u9+EMOjZl10Q3rKlX/D\n6Zu4PDIBIUGU0p6WqdOqAMxHIGbehid+DG8RbgdcZw72QDCztPzPEwYDd3lE\nuaANy3qdPDdN5knlN0QvrJuiU9I++bCgEBWIXuiGTddeQOQXbitEBP7D7Q0E\n+PRYWlGXUjb3YiJgrZJfemEUfvntoqgOa1mPsM9crfo4+tzb5q8H4AEUhpd3\nZyYNxRZKsEN1MpA/i8KjwdO4P2zFofFgvmw/umU2+7/ACD86lYwpII/N26VB\nBlWaZXOPKxsX1uHZSmSI2Z1d6uE6PVSNP9R2fq7KuMWOkhnTb/U39uYBlJHE\nW0SCmMKIz/+TQP83sIH7LKBZmp4hft6UxIoL2LkOTStp7ibAw+rCbPA18NPl\nfMdcCQuHoY2bNHYa87/0ecOFke8JKLkI3DY1AwK+6h9WIX9cOV4MJXl/hXhG\nQiL7NIZ25XfWbqBTfrCtHInxd0e8X1hvR7OytDsyQ6ruAmZqWqNWIjhcLSYL\nGS9wahiPysJcRBxvKiYAfhd8wwUmi/ObbczqygNJqNMcoUZLzNd+AHZSnmlv\nYgU6p6lDs4aOeAcG7moR/+0Pe+OpZwnE0ngkQGLisG/YVayO+cBHLorBkQvc\nBTFo\r\n=oVZZ\r\n-----END PGP SIGNATURE-----\r\n"
137+
},
138+
"main": "",
139+
"types": "index.d.ts",
140+
"scripts": {},
141+
"_npmUser": {
142+
"name": "types",
143+
"email": "ts-npm-types@microsoft.com"
144+
},
145+
"repository": {
146+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
147+
"type": "git",
148+
"directory": "types/is-odd"
149+
},
150+
"description": "TypeScript definitions for is-odd",
151+
"directories": {},
152+
"dependencies": {},
153+
"_hasShrinkwrap": false,
154+
"typeScriptVersion": "3.8",
155+
"_npmOperationalInternal": {
156+
"tmp": "tmp/is-odd_3.0.1_1640304047958_0.02408279906546351",
157+
"host": "s3://npm-registry-packages"
158+
},
159+
"typesPublisherContentHash": "cfeed0da2d9c42717cef03273f341ce6f4edd16f2adf2bacbf13bc82214bfca7"
160+
},
161+
"3.0.2": {
162+
"name": "@types/is-odd",
163+
"version": "3.0.2",
164+
"license": "MIT",
165+
"_id": "@types/is-odd@3.0.2",
166+
"maintainers": [
167+
{
168+
"name": "types",
169+
"email": "ts-npm-types@microsoft.com"
170+
}
171+
],
172+
"contributors": [
173+
{
174+
"url": "https://github.com/DefinitelyTyped",
175+
"name": "DefinitelyTyped",
176+
"githubUsername": "DefinitelyTyped"
177+
}
178+
],
179+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/is-odd",
180+
"dist": {
181+
"shasum": "064ccdfef0cba1f8597e2ec0eba0802fc6aba743",
182+
"tarball": "https://registry.npmjs.org/@types/is-odd/-/is-odd-3.0.2.tgz",
183+
"fileCount": 5,
184+
"integrity": "sha512-a/mE50FokBkPY86oocj/oorgDaYjT+l2EGSVLwbAUFwjOpFFDlbqHW5I9FS0cISLxmuDRr1J26znAy88UkHUbg==",
185+
"signatures": [
186+
{
187+
"sig": "MEUCIC7Z/Qq4ZJJjg5ibpVZWQu1VD8LS/arVBl5awUSBOtRqAiEA20t3jhV+JVYMlUF3fwMl8KneYzDO9+HRYTJ9mQ7WXPY=",
188+
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
189+
}
190+
],
191+
"unpackedSize": 3276
192+
},
193+
"main": "",
194+
"types": "index.d.ts",
195+
"scripts": {},
196+
"_npmUser": {
197+
"name": "types",
198+
"email": "ts-npm-types@microsoft.com"
199+
},
200+
"repository": {
201+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
202+
"type": "git",
203+
"directory": "types/is-odd"
204+
},
205+
"description": "TypeScript definitions for is-odd",
206+
"directories": {},
207+
"dependencies": {},
208+
"_hasShrinkwrap": false,
209+
"typeScriptVersion": "4.5",
210+
"_npmOperationalInternal": {
211+
"tmp": "tmp/is-odd_3.0.2_1695740874873_0.09491697275033473",
212+
"host": "s3://npm-registry-packages"
213+
},
214+
"typesPublisherContentHash": "f9b12a308df62402e8e0f8a8b33f699ed9f75f869afce468cfeafb9f8714df4e"
215+
},
216+
"3.0.3": {
217+
"name": "@types/is-odd",
218+
"version": "3.0.3",
219+
"license": "MIT",
220+
"_id": "@types/is-odd@3.0.3",
221+
"maintainers": [
222+
{
223+
"name": "types",
224+
"email": "ts-npm-types@microsoft.com"
225+
}
226+
],
227+
"contributors": [],
228+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/is-odd",
229+
"dist": {
230+
"shasum": "a60696d7d28b6795522cc757f4bbf0d0250bfa59",
231+
"tarball": "https://registry.npmjs.org/@types/is-odd/-/is-odd-3.0.3.tgz",
232+
"fileCount": 5,
233+
"integrity": "sha512-YdKKQ4CTGEfvdO+MWIPj/DLA3RZMJ9yOJOyLmq0nmN2FrKg6WQ5zynhlmjP7vnfYBTHNp/E9BJmBDsvw0/on/A==",
234+
"signatures": [
235+
{
236+
"sig": "MEQCIGg7zdX3mlxczMdanHMrScYDLSnyDf6TL9b0DLRRkoWVAiBZYASSD5iCM3xRTS767+Gw41jQnDkIeK0rCHuy1SjgIw==",
237+
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
238+
}
239+
],
240+
"unpackedSize": 2576
241+
},
242+
"main": "",
243+
"types": "index.d.ts",
244+
"scripts": {},
245+
"_npmUser": {
246+
"name": "types",
247+
"email": "ts-npm-types@microsoft.com"
248+
},
249+
"repository": {
250+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
251+
"type": "git",
252+
"directory": "types/is-odd"
253+
},
254+
"description": "TypeScript definitions for is-odd",
255+
"directories": {},
256+
"dependencies": {},
257+
"_hasShrinkwrap": false,
258+
"typeScriptVersion": "4.5",
259+
"_npmOperationalInternal": {
260+
"tmp": "tmp/is-odd_3.0.3_1697606685662_0.7307845211597903",
261+
"host": "s3://npm-registry-packages"
262+
},
263+
"typesPublisherContentHash": "f0888f66f4772459e29e716f6016cdaacfc7731573b71c46d23ded2554bd7a73"
264+
},
265+
"3.0.4": {
266+
"name": "@types/is-odd",
267+
"version": "3.0.4",
268+
"license": "MIT",
269+
"_id": "@types/is-odd@3.0.4",
270+
"maintainers": [
271+
{
272+
"name": "types",
273+
"email": "ts-npm-types@microsoft.com"
274+
}
275+
],
276+
"contributors": [],
277+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/is-odd",
278+
"dist": {
279+
"shasum": "281d2e0ff78f04b319e40f83b2c4cfae5377622a",
280+
"tarball": "https://registry.npmjs.org/@types/is-odd/-/is-odd-3.0.4.tgz",
281+
"fileCount": 5,
282+
"integrity": "sha512-BdjXVZXuHVqdXNi9gEbwf/W/k2lIhXzqnmygz4BFRTdpgFpJsn1v7AfB3DaLHj04O9hKiqQvnxu5AeogyptDjQ==",
283+
"signatures": [
284+
{
285+
"sig": "MEUCIHLi2pVt8NsZM0434wTXqtu7F2kqqL9X7uySIbQ/XW7qAiEAzjn/2YlFKI02nQ2vaBNq0OtctmuDAdly4lY0V4eguIc=",
286+
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
287+
}
288+
],
289+
"unpackedSize": 2576
290+
},
291+
"main": "",
292+
"types": "index.d.ts",
293+
"scripts": {},
294+
"_npmUser": {
295+
"name": "types",
296+
"email": "ts-npm-types@microsoft.com"
297+
},
298+
"repository": {
299+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
300+
"type": "git",
301+
"directory": "types/is-odd"
302+
},
303+
"description": "TypeScript definitions for is-odd",
304+
"directories": {},
305+
"dependencies": {},
306+
"_hasShrinkwrap": false,
307+
"typeScriptVersion": "4.5",
308+
"_npmOperationalInternal": {
309+
"tmp": "tmp/is-odd_3.0.4_1699344348594_0.45442272513797977",
310+
"host": "s3://npm-registry-packages"
311+
},
312+
"typesPublisherContentHash": "4f85cab04d848065af4c299b2e5770379553a5d4500593c40f39e06931124f91"
313+
}
314+
},
315+
"time": {
316+
"created": "2019-02-23T02:34:18.884Z",
317+
"modified": "2025-08-03T07:01:33.304Z",
318+
"3.0.0": "2019-02-23T02:34:19.212Z",
319+
"3.0.1": "2021-12-24T00:00:48.118Z",
320+
"3.0.2": "2023-09-26T15:07:55.020Z",
321+
"3.0.3": "2023-10-18T05:24:45.883Z",
322+
"3.0.4": "2023-11-07T08:05:48.848Z"
323+
},
324+
"license": "MIT",
325+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/is-odd",
326+
"repository": {
327+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
328+
"type": "git",
329+
"directory": "types/is-odd"
330+
},
331+
"description": "TypeScript definitions for is-odd",
332+
"contributors": [],
333+
"maintainers": [
334+
{
335+
"name": "types",
336+
"email": "ts-npm-types@microsoft.com"
337+
}
338+
],
339+
"readme": "[object Object]",
340+
"readmeFilename": ""
341+
}

0 commit comments

Comments
 (0)