spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / tests / policy / is-pinned-variable.test.ts
38 lines · 1.2 KBRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Policy from '../../hooks/policy'
4import Fixtures from '../fixtures'
5
6tier('prepend')
7
8describe('is-pinned-variable', () => {
9 test('a name managed env sets is pinned, in any case; no other is', () => {
10 expect(
11 ['CORP_PROXY', 'corp_proxy', 'Corp_Proxy', 'CORP', 'CORP_PROXY_2'].map(
12 name => Policy.isPinnedVariable(Fixtures.PINNING_POLICY, name),
13 ),
14 ).toEqual([true, true, true, false, false])
15 })
16
17 test('whichever case managed env itself spells it in', () => {
18 expect(
19 ['CORP_PROXY', 'corp_proxy', 'CORP'].map(name =>
20 Policy.isPinnedVariable(Fixtures.LOWER_CASE_PINNING_POLICY, name),
21 ),
22 ).toEqual([true, true, false])
23 })
24
25 test('a name managed env sets to nothing is pinned all the same', () => {
26 expect(
27 Policy.isPinnedVariable({ env: { CORP_PROXY: '' } }, 'CORP_PROXY'),
28 ).toBe(true)
29 })
30
31 test('settings with no env pin nothing', () => {
32 expect(
33 [Fixtures.MANAGED_POLICY, {}, { env: {} }].map(policy =>
34 Policy.isPinnedVariable(policy, 'CORP_PROXY'),
35 ),
36 ).toEqual([false, false, false])
37 })
38})