-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsocket-url.test.ts
More file actions
73 lines (64 loc) · 2.06 KB
/
socket-url.test.ts
File metadata and controls
73 lines (64 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env node
import { test } from 'node:test'
import assert from 'node:assert'
import { buildSocketReportUrl } from './socket-url.ts'
test('buildSocketReportUrl produces correct URLs across ecosystems', async (t) => {
await t.test('npm unscoped', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'npm', name: 'express' }),
'https://socket.dev/npm/package/express'
)
})
await t.test('npm scoped', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'npm', namespace: 'babel', name: 'core' }),
'https://socket.dev/npm/package/@babel/core'
)
})
await t.test('pypi', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'pypi', name: 'requests' }),
'https://socket.dev/pypi/package/requests'
)
})
await t.test('golang', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'golang', namespace: 'github.com/gin-gonic', name: 'gin' }),
'https://socket.dev/golang/package/github.com/gin-gonic/gin'
)
})
await t.test('maven', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'maven', namespace: 'org.apache.commons', name: 'commons-lang3' }),
'https://socket.dev/maven/package/org.apache.commons/commons-lang3'
)
})
await t.test('cargo', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'cargo', name: 'serde' }),
'https://socket.dev/cargo/package/serde'
)
})
await t.test('gem', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'gem', name: 'rails' }),
'https://socket.dev/gem/package/rails'
)
})
await t.test('nuget', () => {
assert.strictEqual(
buildSocketReportUrl({ type: 'nuget', name: 'Newtonsoft.Json' }),
'https://socket.dev/nuget/package/Newtonsoft.Json'
)
})
await t.test('handles unknown/missing data gracefully', () => {
assert.strictEqual(
buildSocketReportUrl({}),
'https://socket.dev/npm/package/unknown'
)
assert.strictEqual(
buildSocketReportUrl(null),
'https://socket.dev/npm/package/unknown'
)
})
})