[improvement] Functional: ContactList, NavBar, Panel, SubmitBar, SwitchCell, Tag (#2675)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`submit 1`] = `
|
||||
exports[`disable submit 1`] = `
|
||||
<div class="van-submit-bar">
|
||||
<div class="van-submit-bar__bar">
|
||||
<div class="van-submit-bar__text"><span>合计:</span><span class="van-submit-bar__price">¥ 0.00</span></div><button disabled="disabled" class="van-button van-button--danger van-button--large van-button--square van-button--disabled"><span class="van-button__text"></span></button>
|
||||
|
||||
@@ -2,10 +2,30 @@ import SubmitBar from '..';
|
||||
import { mount } from '../../../test/utils';
|
||||
|
||||
test('submit', () => {
|
||||
const submit = jest.fn();
|
||||
const wrapper = mount(SubmitBar, {
|
||||
propsData: {
|
||||
price: 0.01,
|
||||
disabled: true
|
||||
context: {
|
||||
props: {
|
||||
price: 0.01
|
||||
},
|
||||
on: { submit }
|
||||
}
|
||||
});
|
||||
|
||||
const button = wrapper.find('.van-button');
|
||||
button.trigger('click');
|
||||
expect(submit.mock.calls[0]).toBeTruthy();
|
||||
});
|
||||
|
||||
test('disable submit', () => {
|
||||
const submit = jest.fn();
|
||||
const wrapper = mount(SubmitBar, {
|
||||
context: {
|
||||
props: {
|
||||
price: 0.01,
|
||||
disabled: true
|
||||
},
|
||||
on: { submit }
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,10 +34,5 @@ test('submit', () => {
|
||||
// disabled
|
||||
const button = wrapper.find('.van-button');
|
||||
button.trigger('click');
|
||||
expect(wrapper.emitted('submit')).toBeFalsy();
|
||||
|
||||
// submit
|
||||
wrapper.vm.disabled = false;
|
||||
button.trigger('click');
|
||||
expect(wrapper.emitted('submit')).toBeTruthy();
|
||||
expect(submit.mock.calls[0]).toBeFalsy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user