Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('blur keyboard', (done) => {
wrapper = mount(NumberKeyboard, {
attachToDocument: true
});
const blur = sinon.spy();
wrapper.vm.$on('blur', blur);
triggerTouch(document.body, 'touchstart');
wrapper.vm.$nextTick(() => {
expect(blur.calledOnce).to.be.true;
done();
});
});
it('create a time picker', () => {
wrapper = mount(DatetimePicker, {
attachToDocument: true,
propsData: {
type: 'time',
value: testTime
}
});
expect(wrapper.vm.innerValue).to.equal(testTime);
});
it('loading size', () => {
wrapper = mount(Loading, {
propsData: {
size: '100px'
}
});
expect(wrapper.vm.$el.style.width).to.equal('100px');
expect(wrapper.vm.$el.style.height).to.equal('100px');
});
});
it('displayedCouponIndex out of range', (done) => {
wrapper = mount(CouponList, {
propsData: {
displayedCouponIndex: -100,
coupons: [coupon, discountCoupon, emptyCoupon]
}
});
wrapper.vm.$nextTick(() => {
expect(wrapper.vm.chosenCoupon).to.equal(-1);
done();
});
});
});
it('create an area with invalid areaList', () => {
wrapper = mount(Area, {
propsData: {
areaList: null
}
});
expect(wrapper.vm.columns.length).to.equal(0);
});
it('only disable stepper input', () => {
wrapper = mount(Stepper, {
propsData: {
disableInput: true
}
});
const input = wrapper.find('.van-stepper__input')[0];
expect(input.hasAttribute('disabled', 'disabled')).to.be.true;
});
it('emit a click event when click badge', () => {
wrapper = mount(BadgeTestComponent);
const badge = wrapper.find('.van-badge')[0];
const eventStub = sinon.stub(badge.vNode.child, '$emit');
badge.trigger('click');
expect(eventStub.calledWith('click')).to.be.true;
});
});
it('create a AddressList with three items', () => {
wrapper = mount(AddressList, {
propsData: {
value: '1',
list
}
});
expect(wrapper.find('.van-address-list__group .van-cell').length).to.equal(3);
expect(wrapper.find('.van-icon-checked').length).to.equal(1);
});
it('shopLink prop', () => {
wrapper = mount(OrderGoods, {
attachToDocument: true,
propsData: {
itemList: [item1],
shopLink: 'http://www.youzan.com'
}
});
expect(wrapper.find('.van-order-goods-header a')[0].element.getAttribute('href')).to.equal('http://www.youzan.com');
});
it('create a tabs with four tab', (done) => {
wrapper = mount(TabsTestComponent);
expect(wrapper.hasClass('van-tabs')).to.be.true;
expect(wrapper.hasClass('van-tabs--line')).to.be.true;
const tabsContainer = wrapper.find('.van-tabs')[0];
expect(tabsContainer.vNode.child.curActive).to.equal(0);
wrapper.vm.active = 1;
wrapper.update();
wrapper.vm.$nextTick(() => {
expect(tabsContainer.vNode.child.curActive).to.equal(1);
done();
});
});