-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathParameterHoverProvider.test.ts
More file actions
51 lines (46 loc) · 2.35 KB
/
Copy pathParameterHoverProvider.test.ts
File metadata and controls
51 lines (46 loc) · 2.35 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
45
46
47
48
49
50
51
import { describe, it, expect } from 'vitest';
import { ParameterType } from '../../../src/context/semantic/ParameterType';
import { ParameterHoverProvider } from '../../../src/hover/ParameterHoverProvider';
import { createParameterContext } from '../../utils/MockContext';
describe('ParameterHoverProvider', () => {
const parameterHoverProvider = new ParameterHoverProvider();
describe('Parameter Hover', () => {
it('should return parameter information from template', () => {
const mockContext = createParameterContext('EnvironmentType', {
data: {
Type: ParameterType.String,
Default: 'dev',
Description: 'Environment type',
AllowedValues: ['dev', 'test', 'prod'],
ConstraintDescription: 'Must be dev, test, or prod',
},
});
const result = parameterHoverProvider.getInformation(mockContext);
expect(result).toContain('(parameter) EnvironmentType: string');
expect(result).toContain('Environment type');
expect(result).toContain('**Type:** String');
expect(result).toContain('**Default Value:** "dev"');
expect(result).toContain('**Allowed Values:**');
expect(result).toContain('- dev');
expect(result).toContain('- test');
expect(result).toContain('- prod');
expect(result).toContain('**Constraint Description:** Must be dev, test, or prod');
});
it('should handle parameter with intrinsic function in Description without crashing', () => {
const mockContext = createParameterContext('EcrRepoName', {
data: {
Type: 'String' as any,
Default: 'my-repo',
Description: { 'Fn::Sub': 'Repository for ${AWS::StackName}' },
},
});
// Should not throw an error
const result = parameterHoverProvider.getInformation(mockContext);
expect(result).toContain('(parameter) EcrRepoName: string');
expect(result).toContain('**Type:** String');
expect(result).toContain('**Default Value:** "my-repo"');
expect(result).not.toContain('Description');
expect(result).not.toContain('Fn::Sub');
});
});
});