mirror of
https://github.com/youzan/vant.git
synced 2025-12-24 02:02:09 +08:00
Merge branch 'master' of gitlab.qima-inc.com:fe/zanui-vue
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import Vue from 'vue';
|
||||
import ActionSheet from 'packages/actionsheet';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
@@ -8,7 +7,7 @@ describe('ActionSheet', () => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create', () => {
|
||||
it('create a actionsheet', () => {
|
||||
wrapper = mount(ActionSheet, {
|
||||
propsData: {}
|
||||
});
|
||||
@@ -98,18 +97,21 @@ describe('ActionSheet', () => {
|
||||
expect(cancelButton.text()).to.equal('cancel');
|
||||
});
|
||||
|
||||
it('toggle actionsheet value', () => {
|
||||
it('toggle actionsheet value from v-model', (done) => {
|
||||
wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: false
|
||||
}
|
||||
});
|
||||
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
expect(wrapper.data().currentValue).to.be.false;
|
||||
|
||||
wrapper.vm.value = true;
|
||||
wrapper.update();
|
||||
Vue.nextTick(() => {
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.data().currentValue).to.be.true;
|
||||
expect(eventStub.calledWith('input'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import Badge from 'packages/badge';
|
||||
// import Badge from 'packages/badge';
|
||||
import BadgeGroup from 'packages/badge-group';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Badge', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('BadgeGroup', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Checkbox from 'packages/checkbox';
|
||||
import CheckboxGroup from 'packages/checkbox-group';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Checkbox', () => {
|
||||
@@ -7,7 +8,7 @@ describe('Checkbox', () => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create', () => {
|
||||
it('create a checkbox', () => {
|
||||
wrapper = mount(Checkbox, {
|
||||
propsData: {}
|
||||
});
|
||||
@@ -15,3 +16,36 @@ describe('Checkbox', () => {
|
||||
expect(wrapper.hasClass('zan-checkbox')).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe('CheckboxGroup', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a checkbox-group', () => {
|
||||
wrapper = mount(CheckboxGroup, {
|
||||
propsData: {}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('zan-checkbox-group')).to.be.true;
|
||||
});
|
||||
|
||||
// it('emit a change event', () => {
|
||||
// wrapper = mount(CheckboxGroup, {
|
||||
// propsData: {
|
||||
// value: false
|
||||
// }
|
||||
// });
|
||||
|
||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
|
||||
// wrapper.vm.value = true;
|
||||
// wrapper.update();
|
||||
// Vue.nextTick(() => {
|
||||
// expect(eventStub.calledOnce).to.be.true;
|
||||
// expect(eventStub.calledWith('change'));
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
@@ -1,17 +1,80 @@
|
||||
import Field from 'packages/field';
|
||||
import { mount } from 'avoriaz';
|
||||
// import Vue from 'vue';
|
||||
// import Field from 'packages/field';
|
||||
// import { mount } from 'avoriaz';
|
||||
|
||||
describe('Field', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
// describe('Field', () => {
|
||||
// let wrapper;
|
||||
// afterEach(() => {
|
||||
// wrapper && wrapper.destroy();
|
||||
// });
|
||||
|
||||
it('create', () => {
|
||||
wrapper = mount(Field, {
|
||||
propsData: {}
|
||||
});
|
||||
// it('create a text field', () => {
|
||||
// wrapper = mount(Field, {
|
||||
// propsData: {}
|
||||
// });
|
||||
|
||||
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||
});
|
||||
});
|
||||
// expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||
// });
|
||||
|
||||
// it('create a text field with initialize value', (done) => {
|
||||
// wrapper = mount(Field, {
|
||||
// propsData: {
|
||||
// value: 'test'
|
||||
// }
|
||||
// });
|
||||
|
||||
// expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||
// expect(wrapper.data().currentValue).to.equal('test');
|
||||
|
||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
|
||||
// wrapper.vm.value = 'test2';
|
||||
// wrapper.update();
|
||||
// Vue.nextTick(() => {
|
||||
// expect(wrapper.data().currentValue).to.equal('test2');
|
||||
// expect(eventStub.calledOnce).to.be.true;
|
||||
// expect(eventStub.calledWith('input'));
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('emit a focus event', () => {
|
||||
// wrapper = mount(Field, {
|
||||
// propsData: {}
|
||||
// });
|
||||
|
||||
// const input = wrapper.find('.zan-field__control')[0];
|
||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
|
||||
// input.simulate('focus');
|
||||
|
||||
// expect(eventStub.calledOnce).to.be.true;
|
||||
// expect(eventStub.calledWith('focus')).to.be.true;
|
||||
// });
|
||||
|
||||
// it('input some value to filed', () => {
|
||||
// // wrapper = mount(Field, {
|
||||
// // propsData: {}
|
||||
// // });
|
||||
|
||||
// // const input = wrapper.find('.zan-field__control')[0];
|
||||
// // input.element.value = 'test';
|
||||
|
||||
// // wrapper.update();
|
||||
// // Vue.nextTick(() => {
|
||||
// // expect(wrapper.data().currentValue).to.equal('test');
|
||||
// // done();
|
||||
// // });
|
||||
// });
|
||||
|
||||
// it('create a textarea field', () => {
|
||||
// wrapper = mount(Field, {
|
||||
// propsData: {
|
||||
// type: 'textarea',
|
||||
// autosize: false
|
||||
// }
|
||||
// });
|
||||
|
||||
// expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
|
||||
// });
|
||||
// });
|
||||
|
||||
49
test/unit/specs/popup.spec.js
Normal file
49
test/unit/specs/popup.spec.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import Popup from 'packages/popup';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Popup', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a popup', () => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
position: 'bottom'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('zan-popup')).to.be.true;
|
||||
expect(wrapper.instance().currentTransition).to.equal('popup-slide-bottom');
|
||||
});
|
||||
|
||||
it('create a show popup', (done) => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
value: false
|
||||
}
|
||||
});
|
||||
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
expect(wrapper.data().currentValue).to.be.false;
|
||||
|
||||
wrapper.vm.value = true;
|
||||
wrapper.update();
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.data().currentValue).to.be.true;
|
||||
expect(eventStub.calledWith('input'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('toggle popup show', () => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
value: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.data().currentValue).to.be.true;
|
||||
});
|
||||
});
|
||||
16
test/unit/specs/quantity.spec.js
Normal file
16
test/unit/specs/quantity.spec.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import Quantity from 'packages/quantity';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Quantity', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a quantity', () => {
|
||||
wrapper = mount(Quantity);
|
||||
|
||||
expect(wrapper.hasClass('zan-quantity')).to.be.true;
|
||||
});
|
||||
});
|
||||
41
test/unit/specs/search.spec.js
Normal file
41
test/unit/specs/search.spec.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import Search from 'packages/search';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Search', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a quantity', () => {
|
||||
wrapper = mount(Search);
|
||||
|
||||
expect(wrapper.hasClass('zan-search')).to.be.true;
|
||||
expect(wrapper.data().focusStatus).to.be.false;
|
||||
expect(wrapper.data().isFocus).to.be.false;
|
||||
});
|
||||
|
||||
it('focus on input', () => {
|
||||
wrapper = mount(Search);
|
||||
|
||||
const input = wrapper.find('.zan-search__input')[0];
|
||||
input.simulate('focus');
|
||||
|
||||
expect(wrapper.data().isFocus).to.be.true;
|
||||
});
|
||||
|
||||
it('emit change event', (done) => {
|
||||
wrapper = mount(Search);
|
||||
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
wrapper.setData({ value: 'test' });
|
||||
wrapper.update();
|
||||
wrapper.vm.$nextTick(() => {
|
||||
expect(wrapper.data().value).to.be.equal('test');
|
||||
expect(eventStub.calledOnce).to.be.true;
|
||||
expect(eventStub.calledWith('change'));
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -1,36 +1,36 @@
|
||||
import Toast from 'packages/toast';
|
||||
import { mount } from 'avoriaz';
|
||||
// import Toast from 'packages/toast';
|
||||
// import { mount } from 'avoriaz';
|
||||
|
||||
describe('Toast', () => {
|
||||
// it('create simple toast', () => {
|
||||
// Toast('a message');
|
||||
// var toast = document.querySelector('.zan-toast');
|
||||
// describe('Toast', () => {
|
||||
// // it('create simple toast', () => {
|
||||
// // Toast('a message');
|
||||
// // var toast = document.querySelector('.zan-toast');
|
||||
|
||||
// expect(toast).not.to.be.underfined;
|
||||
// // expect(toast).not.to.be.underfined;
|
||||
|
||||
// setTimeout(() => {
|
||||
// expect(toast.hidden).to.be.true;
|
||||
// }, 301);
|
||||
// });
|
||||
// // setTimeout(() => {
|
||||
// // expect(toast.hidden).to.be.true;
|
||||
// // }, 301);
|
||||
// // });
|
||||
|
||||
// it('create loading toast', () => {
|
||||
// Toast.loading('');
|
||||
// var toast = document.querySelector('.zan-toast');
|
||||
// // it('create loading toast', () => {
|
||||
// // Toast.loading('');
|
||||
// // var toast = document.querySelector('.zan-toast');
|
||||
|
||||
// expect(toast).not.to.be.underfined;
|
||||
// // expect(toast).not.to.be.underfined;
|
||||
|
||||
// setTimeout(() => {
|
||||
// expect(toast.hidden).to.be.true;
|
||||
// }, 301);
|
||||
// });
|
||||
// it('create loading toast', () => {
|
||||
// Toast.success('');
|
||||
// var toast = document.querySelector('.zan-toast');
|
||||
// // setTimeout(() => {
|
||||
// // expect(toast.hidden).to.be.true;
|
||||
// // }, 301);
|
||||
// // });
|
||||
// // it('create loading toast', () => {
|
||||
// // Toast.success('');
|
||||
// // var toast = document.querySelector('.zan-toast');
|
||||
|
||||
// expect(toast).not.to.be.underfined;
|
||||
// // expect(toast).not.to.be.underfined;
|
||||
|
||||
// setTimeout(() => {
|
||||
// expect(toast.hidden).to.be.true;
|
||||
// }, 301);
|
||||
// });
|
||||
});
|
||||
// // setTimeout(() => {
|
||||
// // expect(toast.hidden).to.be.true;
|
||||
// // }, 301);
|
||||
// // });
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user