feat(Button): add icon slot (#8783)

This commit is contained in:
neverland
2021-05-30 20:49:21 +08:00
committed by GitHub
parent ba876d286b
commit 36dae5ae8c
5 changed files with 39 additions and 8 deletions
@@ -22,6 +22,21 @@ exports[`should render icon in the right side when setting icon-position to righ
</button>
`;
exports[`should render icon slot correctly 1`] = `
<button type="button"
class="van-button van-button--default van-button--normal"
>
<div class="van-button__content">
<div class="van-button__icon">
Custom Icon
</div>
<span class="van-button__text">
Text
</span>
</div>
</button>
`;
exports[`should render loading slot correctly 1`] = `
<button type="button"
class="van-button van-button--default van-button--normal van-button--loading"
+10
View File
@@ -86,3 +86,13 @@ test('should render icon in the right side when setting icon-position to right',
});
expect(wrapper.html()).toMatchSnapshot();
});
test('should render icon slot correctly', () => {
const wrapper = mount(Button, {
slots: {
default: () => 'Text',
icon: () => 'Custom Icon',
},
});
expect(wrapper.html()).toMatchSnapshot();
});