-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathagentDetector.test.ts
More file actions
36 lines (30 loc) · 1.17 KB
/
agentDetector.test.ts
File metadata and controls
36 lines (30 loc) · 1.17 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
import { expect } from 'chai';
import detectAgent from '../../../lib/utils/agentDetector';
describe('detectAgent', () => {
const allAgents = [
{ envVar: 'ANTIGRAVITY_AGENT', product: 'antigravity' },
{ envVar: 'CLAUDECODE', product: 'claude-code' },
{ envVar: 'CLINE_ACTIVE', product: 'cline' },
{ envVar: 'CODEX_CI', product: 'codex' },
{ envVar: 'CURSOR_AGENT', product: 'cursor' },
{ envVar: 'GEMINI_CLI', product: 'gemini-cli' },
{ envVar: 'OPENCODE', product: 'opencode' },
];
for (const { envVar, product } of allAgents) {
it(`detects ${product} when ${envVar} is set`, () => {
expect(detectAgent({ [envVar]: '1' })).to.equal(product);
});
}
it('returns empty string when no agent is detected', () => {
expect(detectAgent({})).to.equal('');
});
it('returns empty string when multiple agents are detected', () => {
expect(detectAgent({ CLAUDECODE: '1', CURSOR_AGENT: '1' })).to.equal('');
});
it('ignores empty env var values', () => {
expect(detectAgent({ CLAUDECODE: '' })).to.equal('');
});
it('ignores undefined env var values', () => {
expect(detectAgent({ CLAUDECODE: undefined })).to.equal('');
});
});