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
32 lines · 995 BRaw
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('settings with no env pin nothing', () => {
26 expect(
27 [Fixtures.MANAGED_POLICY, {}, { env: {} }].map(policy =>
28 Policy.isPinnedVariable(policy, 'CORP_PROXY'),
29 ),
30 ).toEqual([false, false, false])
31 })
32})