[new feature] DropdownItem: add disabled prop

This commit is contained in:
陈嘉涵
2019-05-16 15:07:25 +08:00
parent d07c5b6547
commit 61748ad7c4
9 changed files with 91 additions and 3 deletions
@@ -26,5 +26,17 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
</div>
<div>
<div class="van-dropdown-menu van-hairline--top-bottom">
<div class="van-dropdown-menu__item van-dropdown-menu__item--disabled"><span class="van-dropdown-menu__title">全部商品</span></div>
<div class="van-dropdown-menu__item van-dropdown-menu__item--disabled"><span class="van-dropdown-menu__title">默认排序</span></div>
<div class="van-dropdown-item" style="top: 0px; z-index: 10; display: none;">
<!---->
</div>
<div class="van-dropdown-item" style="top: 0px; z-index: 10; display: none;">
<!---->
</div>
</div>
</div>
</div>
`;
@@ -45,6 +45,15 @@ exports[`didn\`t find matched option 1`] = `
</div>
`;
exports[`disable dropdown item 1`] = `
<div class="van-dropdown-menu van-hairline--top-bottom">
<div class="van-dropdown-menu__item van-dropdown-menu__item--disabled"><span class="van-dropdown-menu__title">A</span></div>
<div class="van-dropdown-item" style="top: 0px; z-index: 10; display: none;">
<!---->
</div>
</div>
`;
exports[`show dropdown item 1`] = `
<div class="van-dropdown-menu van-hairline--top-bottom">
<div class="van-dropdown-menu__item"><span class="van-dropdown-menu__title van-dropdown-menu__title--active" style="color: rgb(25, 137, 250);">A</span></div>
+26
View File
@@ -99,6 +99,32 @@ test('destroy one item', async () => {
expect(wrapper).toMatchSnapshot();
});
test('disable dropdown item', async () => {
const wrapper = mount({
template: `
<dropdown-menu>
<dropdown-item disabled v-model="value" :options="options" />
</dropdown-menu>
`,
components: {
DropdownItem,
DropdownMenu
},
data() {
return {
value: 0,
options: [
{ text: 'A', value: 0 },
{ text: 'B', value: 1 }
]
};
}
});
const title = wrapper.find('.van-dropdown-menu__title');
title.trigger('click');
expect(wrapper).toMatchSnapshot();
});
test('change event', async () => {
const onChange = jest.fn();