如何为下拉菜单相关功能编写测试用例,该功能将默认值设置为单击的默认值。这是我的功能:
setDefaultValue = (value, options) => {
let matchedLabel = options.find(el => el.value === value);
return [{ value, label: matchedLabel.label }]
}
options
是一个对象数组,例如:
options = [
{ value: "", label: "" },
{ value: "R", label: "R - Reinvest" },
...
]