|
| 1 | +/** |
| 2 | + * Unit tests for package constants. |
| 3 | + * |
| 4 | + * Purpose: |
| 5 | + * Tests the package and binary name constants for Socket CLI. |
| 6 | + * |
| 7 | + * Test Coverage: |
| 8 | + * - Package manifest file constants |
| 9 | + * - Directory name constants |
| 10 | + * - File extension constants |
| 11 | + * - Package name constants |
| 12 | + * - Binary name constants |
| 13 | + * |
| 14 | + * Related Files: |
| 15 | + * - constants/packages.mts (implementation) |
| 16 | + */ |
| 17 | + |
| 18 | +import { describe, expect, it } from 'vitest' |
| 19 | + |
| 20 | +import { |
| 21 | + BLESSED, |
| 22 | + BLESSED_CONTRIB, |
| 23 | + EXT_LOCK, |
| 24 | + EXT_LOCKB, |
| 25 | + NODE_MODULES, |
| 26 | + NPM_BUGGY_OVERRIDES_PATCHED_VERSION, |
| 27 | + PACKAGE_JSON, |
| 28 | + PACKAGE_LOCK_JSON, |
| 29 | + PNPM_LOCK_YAML, |
| 30 | + PYTHON_MIN_VERSION, |
| 31 | + SENTRY_NODE, |
| 32 | + SOCKET_CLI_BIN_NAME, |
| 33 | + SOCKET_CLI_BIN_NAME_ALIAS, |
| 34 | + SOCKET_CLI_LEGACY_PACKAGE_NAME, |
| 35 | + SOCKET_CLI_NPM_BIN_NAME, |
| 36 | + SOCKET_CLI_NPX_BIN_NAME, |
| 37 | + SOCKET_CLI_PACKAGE_NAME, |
| 38 | + SOCKET_CLI_PNPM_BIN_NAME, |
| 39 | + SOCKET_CLI_SENTRY_BIN_NAME, |
| 40 | + SOCKET_CLI_SENTRY_BIN_NAME_ALIAS, |
| 41 | + SOCKET_CLI_SENTRY_NPM_BIN_NAME, |
| 42 | + SOCKET_CLI_SENTRY_NPX_BIN_NAME, |
| 43 | + SOCKET_CLI_SENTRY_PACKAGE_NAME, |
| 44 | + SOCKET_CLI_SENTRY_PNPM_BIN_NAME, |
| 45 | + SOCKET_CLI_SENTRY_YARN_BIN_NAME, |
| 46 | + SOCKET_CLI_YARN_BIN_NAME, |
| 47 | + SOCKET_DESCRIPTION, |
| 48 | + SOCKET_DESCRIPTION_WITH_SENTRY, |
| 49 | + SOCKET_SECURITY_REGISTRY, |
| 50 | + YARN_LOCK, |
| 51 | +} from '../../../src/constants/packages.mts' |
| 52 | + |
| 53 | +describe('packages constants', () => { |
| 54 | + describe('package manifest file constants', () => { |
| 55 | + it('has PACKAGE_JSON constant', () => { |
| 56 | + expect(PACKAGE_JSON).toBe('package.json') |
| 57 | + }) |
| 58 | + |
| 59 | + it('has PACKAGE_LOCK_JSON constant', () => { |
| 60 | + expect(PACKAGE_LOCK_JSON).toBe('package-lock.json') |
| 61 | + }) |
| 62 | + |
| 63 | + it('has PNPM_LOCK_YAML constant', () => { |
| 64 | + expect(PNPM_LOCK_YAML).toBe('pnpm-lock.yaml') |
| 65 | + }) |
| 66 | + |
| 67 | + it('has YARN_LOCK constant', () => { |
| 68 | + expect(YARN_LOCK).toBe('yarn.lock') |
| 69 | + }) |
| 70 | + }) |
| 71 | + |
| 72 | + describe('directory name constants', () => { |
| 73 | + it('has NODE_MODULES constant', () => { |
| 74 | + expect(NODE_MODULES).toBe('node_modules') |
| 75 | + }) |
| 76 | + }) |
| 77 | + |
| 78 | + describe('file extension constants', () => { |
| 79 | + it('has EXT_LOCK constant', () => { |
| 80 | + expect(EXT_LOCK).toBe('.lock') |
| 81 | + }) |
| 82 | + |
| 83 | + it('has EXT_LOCKB constant', () => { |
| 84 | + expect(EXT_LOCKB).toBe('.lockb') |
| 85 | + }) |
| 86 | + }) |
| 87 | + |
| 88 | + describe('npm version constants', () => { |
| 89 | + it('has NPM_BUGGY_OVERRIDES_PATCHED_VERSION constant', () => { |
| 90 | + expect(NPM_BUGGY_OVERRIDES_PATCHED_VERSION).toBe('11.2.0') |
| 91 | + }) |
| 92 | + }) |
| 93 | + |
| 94 | + describe('external package name constants', () => { |
| 95 | + it('has BLESSED constant', () => { |
| 96 | + expect(BLESSED).toBe('blessed') |
| 97 | + }) |
| 98 | + |
| 99 | + it('has BLESSED_CONTRIB constant', () => { |
| 100 | + expect(BLESSED_CONTRIB).toBe('blessed-contrib') |
| 101 | + }) |
| 102 | + |
| 103 | + it('has SENTRY_NODE constant', () => { |
| 104 | + expect(SENTRY_NODE).toBe('@sentry/node') |
| 105 | + }) |
| 106 | + |
| 107 | + it('has SOCKET_SECURITY_REGISTRY constant', () => { |
| 108 | + expect(SOCKET_SECURITY_REGISTRY).toBe('@socketsecurity/registry') |
| 109 | + }) |
| 110 | + }) |
| 111 | + |
| 112 | + describe('Socket CLI package name constants', () => { |
| 113 | + it('has SOCKET_CLI_PACKAGE_NAME constant', () => { |
| 114 | + expect(SOCKET_CLI_PACKAGE_NAME).toBe('socket') |
| 115 | + }) |
| 116 | + |
| 117 | + it('has SOCKET_CLI_LEGACY_PACKAGE_NAME constant', () => { |
| 118 | + expect(SOCKET_CLI_LEGACY_PACKAGE_NAME).toBe('socket-npm') |
| 119 | + }) |
| 120 | + |
| 121 | + it('has SOCKET_CLI_SENTRY_PACKAGE_NAME constant', () => { |
| 122 | + expect(SOCKET_CLI_SENTRY_PACKAGE_NAME).toBe( |
| 123 | + '@socketsecurity/cli-with-sentry', |
| 124 | + ) |
| 125 | + }) |
| 126 | + }) |
| 127 | + |
| 128 | + describe('Socket CLI binary name constants', () => { |
| 129 | + it('has SOCKET_CLI_BIN_NAME constant', () => { |
| 130 | + expect(SOCKET_CLI_BIN_NAME).toBe('socket') |
| 131 | + }) |
| 132 | + |
| 133 | + it('has SOCKET_CLI_BIN_NAME_ALIAS constant', () => { |
| 134 | + expect(SOCKET_CLI_BIN_NAME_ALIAS).toBe('socket-dev') |
| 135 | + }) |
| 136 | + |
| 137 | + it('has SOCKET_CLI_NPM_BIN_NAME constant', () => { |
| 138 | + expect(SOCKET_CLI_NPM_BIN_NAME).toBe('socket-npm') |
| 139 | + }) |
| 140 | + |
| 141 | + it('has SOCKET_CLI_NPX_BIN_NAME constant', () => { |
| 142 | + expect(SOCKET_CLI_NPX_BIN_NAME).toBe('socket-npx') |
| 143 | + }) |
| 144 | + |
| 145 | + it('has SOCKET_CLI_PNPM_BIN_NAME constant', () => { |
| 146 | + expect(SOCKET_CLI_PNPM_BIN_NAME).toBe('socket-pnpm') |
| 147 | + }) |
| 148 | + |
| 149 | + it('has SOCKET_CLI_YARN_BIN_NAME constant', () => { |
| 150 | + expect(SOCKET_CLI_YARN_BIN_NAME).toBe('socket-yarn') |
| 151 | + }) |
| 152 | + }) |
| 153 | + |
| 154 | + describe('Socket CLI Sentry binary name constants', () => { |
| 155 | + it('has SOCKET_CLI_SENTRY_BIN_NAME constant', () => { |
| 156 | + expect(SOCKET_CLI_SENTRY_BIN_NAME).toBe('@socketsecurity/cli-with-sentry') |
| 157 | + }) |
| 158 | + |
| 159 | + it('has SOCKET_CLI_SENTRY_BIN_NAME_ALIAS constant', () => { |
| 160 | + expect(SOCKET_CLI_SENTRY_BIN_NAME_ALIAS).toBe('socket-dev-with-sentry') |
| 161 | + }) |
| 162 | + |
| 163 | + it('has SOCKET_CLI_SENTRY_NPM_BIN_NAME constant', () => { |
| 164 | + expect(SOCKET_CLI_SENTRY_NPM_BIN_NAME).toBe( |
| 165 | + '@socketsecurity/cli-with-sentry-npm', |
| 166 | + ) |
| 167 | + }) |
| 168 | + |
| 169 | + it('has SOCKET_CLI_SENTRY_NPX_BIN_NAME constant', () => { |
| 170 | + expect(SOCKET_CLI_SENTRY_NPX_BIN_NAME).toBe( |
| 171 | + '@socketsecurity/cli-with-sentry-npx', |
| 172 | + ) |
| 173 | + }) |
| 174 | + |
| 175 | + it('has SOCKET_CLI_SENTRY_PNPM_BIN_NAME constant', () => { |
| 176 | + expect(SOCKET_CLI_SENTRY_PNPM_BIN_NAME).toBe( |
| 177 | + '@socketsecurity/cli-with-sentry-pnpm', |
| 178 | + ) |
| 179 | + }) |
| 180 | + |
| 181 | + it('has SOCKET_CLI_SENTRY_YARN_BIN_NAME constant', () => { |
| 182 | + expect(SOCKET_CLI_SENTRY_YARN_BIN_NAME).toBe( |
| 183 | + '@socketsecurity/cli-with-sentry-yarn', |
| 184 | + ) |
| 185 | + }) |
| 186 | + }) |
| 187 | + |
| 188 | + describe('description constants', () => { |
| 189 | + it('has SOCKET_DESCRIPTION constant', () => { |
| 190 | + expect(SOCKET_DESCRIPTION).toBe('CLI for Socket.dev') |
| 191 | + }) |
| 192 | + |
| 193 | + it('has SOCKET_DESCRIPTION_WITH_SENTRY constant', () => { |
| 194 | + expect(SOCKET_DESCRIPTION_WITH_SENTRY).toContain(SOCKET_DESCRIPTION) |
| 195 | + expect(SOCKET_DESCRIPTION_WITH_SENTRY).toContain('Sentry') |
| 196 | + }) |
| 197 | + }) |
| 198 | + |
| 199 | + describe('Python version constants', () => { |
| 200 | + it('has PYTHON_MIN_VERSION constant', () => { |
| 201 | + expect(PYTHON_MIN_VERSION).toBe('3.9.0') |
| 202 | + }) |
| 203 | + }) |
| 204 | +}) |
0 commit comments