feat(Cascader): add option slot (#9036)
* feat(Cascader): add option-text slot * chore: adjust slot
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user