[new feature] Toast: add icon prop (#3485)

This commit is contained in:
neverland
2019-06-12 17:21:59 +08:00
committed by GitHub
parent 2d18f67a7d
commit 153fb9d69f
15 changed files with 185 additions and 48 deletions
@@ -15,6 +15,11 @@ exports[`renders demo correctly 1`] = `
</span></button> <button class="van-button van-button--danger van-button--normal"><span class="van-button__text">
失败提示
</span></button></div>
<div><button class="van-button van-button--primary van-button--normal"><span class="van-button__text">
自定义图标
</span></button> <button class="van-button van-button--primary van-button--normal"><span class="van-button__text">
展示图片
</span></button></div>
<div><button class="van-button van-button--primary van-button--normal"><span class="van-button__text">
高级用法
</span></button></div>
@@ -1,7 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`create a forbidClick toast 1`] = `
<div class="van-toast van-toast--text van-toast--middle" style="display: none;" name="van-fade">
<div></div>
<div class="van-toast van-toast--middle" style="z-index: 2000;" name="van-fade"><i class="van-icon van-icon-success van-toast__icon">
<!----></i></div>
`;
exports[`icon prop 1`] = `
<div class="van-toast van-toast--middle" style="z-index: 2004;" name="van-fade"><i class="van-icon van-icon-star-o van-toast__icon">
<!----></i>
<div class="van-toast__text">Message</div>
</div>
`;
exports[`show html toast 1`] = `
<div class="van-toast van-toast--middle van-toast--text" style="z-index: 2003;" name="van-fade">
<div class="van-toast__text">
<div>Message</div>
</div>
</div>
`;
exports[`show loading toast 1`] = `
<div class="van-toast van-toast--middle" style="z-index: 2002;" name="van-fade">
<div class="van-loading van-loading--circular van-toast__loading"><span class="van-loading__spinner van-loading__spinner--circular" style="color: white;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
<div class="van-toast__text">Message</div>
</div>
`;
+30
View File
@@ -11,6 +11,7 @@ test('create a forbidClick toast', async () => {
type: 'success'
});
await later();
expect(toast.$el.outerHTML).toMatchSnapshot();
await later();
@@ -30,6 +31,35 @@ it('toast disappeared after duration', async () => {
expect(toast.$el.style.display).toEqual('none');
});
test('show loading toast', async () => {
const toast = Toast.loading({
message: 'Message'
});
await later();
expect(toast.$el.outerHTML).toMatchSnapshot();
});
test('show html toast', async () => {
const toast = Toast({
type: 'html',
message: '<div>Message</div>'
});
await later();
expect(toast.$el.outerHTML).toMatchSnapshot();
});
test('icon prop', async () => {
const toast = Toast({
message: 'Message',
icon: 'star-o'
});
await later();
expect(toast.$el.outerHTML).toMatchSnapshot();
});
test('clear toast', () => {
const toast1 = Toast();
expect(toast1.value).toBeTruthy();