feat(Cascader): add option slot (#9036)

* feat(Cascader): add option-text slot

* chore: adjust slot
This commit is contained in:
neverland
2021-07-15 14:44:07 +08:00
committed by GitHub
parent 69524def7b
commit 4de5f5ac5a
5 changed files with 71 additions and 40 deletions
@@ -5,6 +5,12 @@ exports[`should change close icon when using close-icon prop 1`] = `
</i>
`;
exports[`should render option slot correctly 1`] = `
<li class="van-cascader__option">
Custom Option foo
</li>
`;
exports[`should render title slot correctly 1`] = `
<h2 class="van-cascader__title">
Custom Title
+14
View File
@@ -88,6 +88,20 @@ test('should render title slot correctly', () => {
expect(wrapper.find('.van-cascader__title').html()).toMatchSnapshot();
});
test('should render option slot correctly', async () => {
const option = { value: '1', text: 'foo' };
const wrapper = mount(Cascader, {
props: {
options: [option],
},
slots: {
option: ({ option }) => `Custom Option ${option.text}`,
},
});
await later();
expect(wrapper.find('.van-cascader__option').html()).toMatchSnapshot();
});
// TODO
// test('should select correct option when value changed', async () => {
// const wrapper = mount(Cascader, {