-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathsocket-patch-version.test.mts
More file actions
44 lines (36 loc) · 1.21 KB
/
Copy pathsocket-patch-version.test.mts
File metadata and controls
44 lines (36 loc) · 1.21 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
/**
* Unit tests for Socket Patch version getter.
*
* Related Files: - src/env/socket-patch-version.mts.
*/
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { getSocketPatchVersion } from '../../../src/env/socket-patch-version.mts'
describe('env/socket-patch-version', () => {
let original: string | undefined
beforeEach(() => {
original = process.env['INLINED_SOCKET_PATCH_VERSION']
})
afterEach(() => {
if (original !== undefined) {
process.env['INLINED_SOCKET_PATCH_VERSION'] = original
} else {
delete process.env['INLINED_SOCKET_PATCH_VERSION']
}
})
it('returns the version string when the env var is set', () => {
process.env['INLINED_SOCKET_PATCH_VERSION'] = '1.2.3'
expect(getSocketPatchVersion()).toBe('1.2.3')
})
it('throws when the env var is missing', () => {
delete process.env['INLINED_SOCKET_PATCH_VERSION']
expect(() => getSocketPatchVersion()).toThrow(
/INLINED_SOCKET_PATCH_VERSION/,
)
})
it('throws when the env var is the empty string', () => {
process.env['INLINED_SOCKET_PATCH_VERSION'] = ''
expect(() => getSocketPatchVersion()).toThrow(
/INLINED_SOCKET_PATCH_VERSION/,
)
})
})