[Improvement] Area: watch area list (#1381)

This commit is contained in:
neverland
2018-07-02 21:28:23 +08:00
committed by GitHub
parent c53be5bf6f
commit ce023b0824
7 changed files with 173 additions and 400 deletions
+16 -18
View File
@@ -2,28 +2,29 @@ import Area from '..';
import areaList from '../demo/area.simple';
import { mount, later, triggerDrag } from '../../../test/utils';
const firstOption = [
{ code: '110000', name: '北京市' },
{ code: '110100', name: '北京市' },
{ code: '110101', name: '东城区' }
];
test('confirm & cancel event', () => {
test('confirm & cancel event', async() => {
const wrapper = mount(Area, {
propsData: {
areaList
}
});
await later();
wrapper.find('.van-picker__confirm').trigger('click');
wrapper.find('.van-picker__cancel').trigger('click');
expect(wrapper.emitted('confirm')[0][0]).toEqual(firstOption);
expect(wrapper.emitted('cancel')[0][0]).toEqual(firstOption);
expect(wrapper.emitted('confirm')).toBeTruthy();
expect(wrapper.emitted('cancel')[0][0]).toBeTruthy();
});
test('watch areaList & code', async() => {
const wrapper = mount(Area);
test('watch code', async() => {
const wrapper = mount(Area, {
propsData: {
areaList
}
});
expect(wrapper).toMatchSnapshot();
wrapper.setProps({ areaList });
expect(wrapper).toMatchSnapshot();
@@ -33,8 +34,7 @@ test('watch areaList & code', async() => {
expect(wrapper).toMatchSnapshot();
wrapper.setProps({
value: '',
areaList: null
value: ''
});
expect(wrapper).toMatchSnapshot();
});
@@ -57,11 +57,9 @@ test('change option', () => {
test('getValues method', () => {
const wrapper = mount(Area, {
propsData: {
areaList
},
created() {
expect(this.getValues()).toEqual([]);
areaList: {}
}
});
expect(wrapper.vm.getValues()).toEqual(firstOption);
expect(wrapper.vm.getValues()).toBeTruthy();
});