fix: Mock dropdown in tests correctly

This commit is contained in:
Prathmesh Vhatkar
2025-01-29 09:14:16 +05:30
parent db0339b228
commit 7e38e50d79
2 changed files with 15 additions and 0 deletions

View File

@@ -144,6 +144,7 @@ const ApiConfigManager = ({
style={{
minWidth: 130,
}}
role="combobox"
options={listApiConfigMeta.map((config) => ({
value: config.name,
label: config.name,

View File

@@ -19,6 +19,20 @@ jest.mock("@vscode/webview-ui-toolkit/react", () => ({
),
}))
jest.mock("vscrui", () => ({
Dropdown: ({ id, value, onChange, options, role }: any) => (
<div data-testid={`mock-dropdown-${id}`}>
<select value={value} onChange={(e) => onChange({ value: e.target.value })} data-testid={id} role={role}>
{options.map((opt: any) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
</div>
),
}))
describe("ApiConfigManager", () => {
const mockOnSelectConfig = jest.fn()
const mockOnDeleteConfig = jest.fn()