test(Loading): update test cases

This commit is contained in:
chenjiahan 2020-11-14 06:57:02 +08:00
parent a13f4fd1e4
commit 2b34fac38d
4 changed files with 30 additions and 31 deletions

View File

@ -67,7 +67,7 @@ test('should render badge correctly', () => {
expect(wrapper.find('.van-badge').html()).toMatchSnapshot();
});
test('should change icon size after using size prop', () => {
test('should change icon size when using size prop', () => {
const wrapper = mount(Icon, {
props: {
size: 20,

View File

@ -1,5 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`size prop 1`] = `<div class="van-loading van-loading--circular"><span class="van-loading__spinner van-loading__spinner--circular" style="width: 20px; height: 20px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>`;
exports[`text-size prop 1`] = `<div class="van-loading van-loading--circular"><span class="van-loading__spinner van-loading__spinner--circular"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span><span class="van-loading__text" style="font-size: 20px;">Text</span></div>`;

View File

@ -1,25 +0,0 @@
import { mount } from '@vue/test-utils';
import Loading from '..';
test('size prop', () => {
const wrapper = mount(Loading, {
props: {
size: 20,
},
});
expect(wrapper.html()).toMatchSnapshot();
});
test('text-size prop', () => {
const wrapper = mount(Loading, {
props: {
textSize: 20,
},
slots: {
default: () => 'Text',
},
});
expect(wrapper.html()).toMatchSnapshot();
});

View File

@ -0,0 +1,29 @@
import { mount } from '@vue/test-utils';
import Loading from '..';
test('should change loading size when using size prop', () => {
const wrapper = mount(Loading, {
props: {
size: 20,
},
});
const spinner = wrapper.find('.van-loading__spinner').element;
expect(spinner.style.width).toEqual('20px');
expect(spinner.style.height).toEqual('20px');
});
test('should change text font-size when using text-size prop', () => {
const wrapper = mount(Loading, {
props: {
textSize: 20,
},
slots: {
default: () => 'Text',
},
});
expect(wrapper.find('.van-loading__text').element.style.fontSize).toEqual(
'20px'
);
});