[bugfix] Area: fix test cases (#1392)

This commit is contained in:
neverland
2018-07-03 23:59:13 +08:00
committed by GitHub
parent 7f4ad6a28d
commit 541299ccd5
4 changed files with 72 additions and 36 deletions
+11 -5
View File
@@ -2,6 +2,12 @@ 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', async() => {
const wrapper = mount(Area, {
propsData: {
@@ -14,11 +20,11 @@ test('confirm & cancel event', async() => {
wrapper.find('.van-picker__confirm').trigger('click');
wrapper.find('.van-picker__cancel').trigger('click');
expect(wrapper.emitted('confirm')).toBeTruthy();
expect(wrapper.emitted('cancel')[0][0]).toBeTruthy();
expect(wrapper.emitted('confirm')[0][0]).toEqual(firstOption);
expect(wrapper.emitted('cancel')[0][0]).toEqual(firstOption);
});
test('watch code', async() => {
test('watch areaList & code', async() => {
const wrapper = mount(Area, {
propsData: {
areaList
@@ -57,9 +63,9 @@ test('change option', () => {
test('getValues method', () => {
const wrapper = mount(Area, {
propsData: {
areaList: {}
areaList
}
});
expect(wrapper.vm.getValues()).toBeTruthy();
expect(wrapper.vm.getValues()).toEqual(firstOption);
});