Skip to content

Commit e4d2ea8

Browse files
committed
test(cli): add unit tests for dlx, sea, and constants
Add comprehensive test coverage for: - resolve-binary.mts: Binary resolution for Coana, cdxgen, sfw, socket-patch, synp - detect.mts: SEA binary detection and self-update capability - constants.mts: Barrel file exports verification
1 parent f8bd7f6 commit e4d2ea8

File tree

3 files changed

+430
-307
lines changed

3 files changed

+430
-307
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* Unit tests for constants barrel file.
3+
*
4+
* Purpose:
5+
* Tests the constants barrel export file to ensure all exports work correctly.
6+
*
7+
* Test Coverage:
8+
* - Named exports
9+
* - Default export
10+
*
11+
* Related Files:
12+
* - src/constants.mts (implementation)
13+
*/
14+
15+
import { describe, expect, it } from 'vitest'
16+
17+
import constants, {
18+
FLAG_DRY_RUN,
19+
FLAG_JSON,
20+
FLAG_ORG,
21+
getCliVersion,
22+
LOOP_SENTINEL,
23+
NPM,
24+
OUTPUT_JSON,
25+
OUTPUT_MARKDOWN,
26+
OUTPUT_TEXT,
27+
PNPM,
28+
SOCKET_CLI_BIN_NAME,
29+
SOCKET_CLI_PACKAGE_NAME,
30+
VITEST,
31+
YARN,
32+
} from '../../src/constants.mts'
33+
34+
describe('constants barrel exports', () => {
35+
describe('named exports', () => {
36+
it('exports flag constants', () => {
37+
// Flags include the -- prefix.
38+
expect(FLAG_DRY_RUN).toBe('--dry-run')
39+
expect(FLAG_JSON).toBe('--json')
40+
expect(FLAG_ORG).toBe('--org')
41+
})
42+
43+
it('exports output format constants', () => {
44+
expect(OUTPUT_JSON).toBe('json')
45+
expect(OUTPUT_MARKDOWN).toBe('markdown')
46+
expect(OUTPUT_TEXT).toBe('text')
47+
})
48+
49+
it('exports agent constants', () => {
50+
expect(NPM).toBe('npm')
51+
expect(PNPM).toBe('pnpm')
52+
expect(YARN).toBe('yarn')
53+
})
54+
55+
it('exports error constants', () => {
56+
expect(typeof LOOP_SENTINEL).toBe('number')
57+
})
58+
59+
it('exports package name constants', () => {
60+
expect(SOCKET_CLI_BIN_NAME).toBe('socket')
61+
// SOCKET_CLI_PACKAGE_NAME is the npm package name 'socket'.
62+
expect(SOCKET_CLI_PACKAGE_NAME).toBe('socket')
63+
})
64+
65+
it('exports VITEST constant', () => {
66+
expect(VITEST).toBe(true)
67+
})
68+
69+
it('exports getCliVersion function', () => {
70+
expect(typeof getCliVersion).toBe('function')
71+
})
72+
})
73+
74+
describe('default export', () => {
75+
it('exports an object with constants', () => {
76+
expect(typeof constants).toBe('object')
77+
})
78+
79+
it('includes flag constants', () => {
80+
expect(constants.FLAG_DRY_RUN).toBe('--dry-run')
81+
expect(constants.FLAG_JSON).toBe('--json')
82+
})
83+
84+
it('includes output format constants', () => {
85+
expect(constants.OUTPUT_JSON).toBe('json')
86+
expect(constants.OUTPUT_MARKDOWN).toBe('markdown')
87+
})
88+
89+
it('includes agent constants', () => {
90+
expect(constants.NPM).toBe('npm')
91+
expect(constants.PNPM).toBe('pnpm')
92+
})
93+
94+
it('includes ENV object', () => {
95+
expect(typeof constants.ENV).toBe('object')
96+
})
97+
98+
it('includes getCliVersion function', () => {
99+
expect(typeof constants.getCliVersion).toBe('function')
100+
})
101+
})
102+
})

0 commit comments

Comments
 (0)