mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 09:24:25 +00:00
Merge branch 'dev' into feature/sku_migration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import OrderCoupon from 'packages/order-coupon';
|
||||
import OrderCouponList from 'packages/order-coupon-list';
|
||||
import CouponCell from 'packages/coupon-cell';
|
||||
import CouponList from 'packages/coupon-list';
|
||||
import { mount } from 'avoriaz';
|
||||
import { DOMChecker } from '../utils';
|
||||
|
||||
@@ -42,14 +42,14 @@ const disabledDiscountCoupon = {
|
||||
reason: '未满足使用门槛'
|
||||
};
|
||||
|
||||
describe('OrderCoupon', () => {
|
||||
describe('CouponCell', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('no coupon', () => {
|
||||
wrapper = mount(OrderCoupon, {});
|
||||
wrapper = mount(CouponCell, {});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
@@ -59,7 +59,7 @@ describe('OrderCoupon', () => {
|
||||
});
|
||||
|
||||
it('has two coupon', () => {
|
||||
wrapper = mount(OrderCoupon, {
|
||||
wrapper = mount(CouponCell, {
|
||||
propsData: {
|
||||
coupons: [coupon, discountCoupon]
|
||||
}
|
||||
@@ -73,7 +73,7 @@ describe('OrderCoupon', () => {
|
||||
});
|
||||
|
||||
it('select first coupon', () => {
|
||||
wrapper = mount(OrderCoupon, {
|
||||
wrapper = mount(CouponCell, {
|
||||
propsData: {
|
||||
chosenCoupon: 0,
|
||||
coupons: [coupon, discountCoupon]
|
||||
@@ -92,7 +92,7 @@ describe('OrderCoupon', () => {
|
||||
});
|
||||
|
||||
it('not editable', () => {
|
||||
wrapper = mount(OrderCoupon, {
|
||||
wrapper = mount(CouponCell, {
|
||||
propsData: {
|
||||
chosenCoupon: 0,
|
||||
coupons: [coupon, discountCoupon],
|
||||
@@ -112,14 +112,14 @@ describe('OrderCoupon', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('OrderCouponList', () => {
|
||||
describe('CouponList', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('no coupon', () => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
propsData: {
|
||||
chosenCoupon: -1
|
||||
}
|
||||
@@ -127,15 +127,15 @@ describe('OrderCouponList', () => {
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-order-coupon-coupon': 0,
|
||||
'.van-order-coupon-coupon--disabled': 0,
|
||||
'.van-order-coupon-list__list h3': 0
|
||||
'.van-coupon-item': 0,
|
||||
'.van-coupon-item--disabled': 0,
|
||||
'.van-coupon-list__list h3': 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('has two coupon', () => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
propsData: {
|
||||
chosenCoupon: -1,
|
||||
coupons: [coupon, discountCoupon],
|
||||
@@ -144,15 +144,15 @@ describe('OrderCouponList', () => {
|
||||
});
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-order-coupon-coupon': 4,
|
||||
'.van-order-coupon-coupon--disabled': 2,
|
||||
'.van-order-coupon-list__list h3': 1
|
||||
'.van-coupon-item': 4,
|
||||
'.van-coupon-item--disabled': 2,
|
||||
'.van-coupon-list__list h3': 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('switch to first coupon', (done) => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
show: true,
|
||||
@@ -168,8 +168,8 @@ describe('OrderCouponList', () => {
|
||||
|
||||
// 弹出 popup
|
||||
setTimeout(() => {
|
||||
expect(wrapper.find('.van-order-coupon-list')[0].hasStyle('display', 'none')).to.equal(false);
|
||||
wrapper.find('.van-order-coupon-coupon')[0].trigger('click');
|
||||
expect(wrapper.find('.van-coupon-list')[0].hasStyle('display', 'none')).to.equal(false);
|
||||
wrapper.find('.van-coupon-item')[0].trigger('click');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.chosenCoupon).to.equal(0);
|
||||
@@ -179,7 +179,7 @@ describe('OrderCouponList', () => {
|
||||
});
|
||||
|
||||
it('cancel select coupon', (done) => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
show: false,
|
||||
@@ -198,17 +198,17 @@ describe('OrderCouponList', () => {
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
wrapper.find('.van-order-coupon-list__close')[0].trigger('click');
|
||||
wrapper.find('.van-coupon-list__close')[0].trigger('click');
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.chosenCoupon).to.equal(-1);
|
||||
expect(wrapper.find('.van-order-coupon-list')[0].hasStyle('display', 'none')).to.equal(true);
|
||||
expect(wrapper.find('.van-coupon-list')[0].hasStyle('display', 'none')).to.equal(true);
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('denominations format', () => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
coupons: [coupon, {
|
||||
@@ -227,15 +227,15 @@ describe('OrderCouponList', () => {
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[0].text()).to.equal('¥ 1.5');
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[1].text()).to.equal('¥ 0.1');
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[2].text()).to.equal('¥ 1');
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[3].text()).to.equal('¥ 1.35');
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[4].text()).to.equal('');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[0].text()).to.equal('¥ 1.5');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[1].text()).to.equal('¥ 0.1');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[2].text()).to.equal('¥ 1');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[3].text()).to.equal('¥ 1.35');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[4].text()).to.equal('');
|
||||
});
|
||||
|
||||
it('discount format', () => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
coupons: [discountCoupon, {
|
||||
@@ -248,13 +248,13 @@ describe('OrderCouponList', () => {
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[0].text()).to.equal('8.8折');
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[1].text()).to.equal('1折');
|
||||
expect(wrapper.find('.van-order-coupon-coupon__gradient h2')[2].text()).to.equal('');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[0].text()).to.equal('8.8折');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[1].text()).to.equal('1折');
|
||||
expect(wrapper.find('.van-coupon-item__gradient h2')[2].text()).to.equal('');
|
||||
});
|
||||
|
||||
it('add coupon', (done) => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
show: true,
|
||||
@@ -282,7 +282,7 @@ describe('OrderCouponList', () => {
|
||||
wrapper.find('.van-field__control')[0].trigger('input');
|
||||
|
||||
setTimeout(() => {
|
||||
wrapper.find('.van-order-coupon-list__exchange')[0].trigger('click');
|
||||
wrapper.find('.van-coupon-list__exchange')[0].trigger('click');
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-button--disabled': 0
|
||||
@@ -290,12 +290,12 @@ describe('OrderCouponList', () => {
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.find('.van-order-coupon-list')[0].hasStyle('display', 'none')).to.equal(false);
|
||||
expect(wrapper.find('.van-coupon-list')[0].hasStyle('display', 'none')).to.equal(false);
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-button--disabled': 1,
|
||||
'.van-order-coupon-coupon': 6,
|
||||
'.van-order-coupon-coupon--disabled': 2
|
||||
'.van-coupon-item': 6,
|
||||
'.van-coupon-item--disabled': 2
|
||||
}
|
||||
});
|
||||
done();
|
||||
@@ -305,7 +305,7 @@ describe('OrderCouponList', () => {
|
||||
});
|
||||
|
||||
it('displayedCouponIndex out of range', (done) => {
|
||||
wrapper = mount(OrderCouponList, {
|
||||
wrapper = mount(CouponList, {
|
||||
propsData: {
|
||||
show: true,
|
||||
displayedCouponIndex: -100,
|
@@ -1,201 +0,0 @@
|
||||
import ExpressWay from 'packages/express-way';
|
||||
import { mount } from 'avoriaz';
|
||||
import { DOMChecker } from '../utils';
|
||||
|
||||
const mockData = [{
|
||||
'postage': 10050,
|
||||
'postage_desc': '由商家门店提供配送服务, 起送价 0.01 元',
|
||||
'postage_title': '同城配送',
|
||||
'express_type': 1
|
||||
}, {
|
||||
'postage': 0,
|
||||
'postage_desc': '由商家选择合作快递为您服务',
|
||||
'postage_title': '快递发货',
|
||||
'express_type': 2,
|
||||
'postage_warn_desc': '3天后发货'
|
||||
}];
|
||||
|
||||
describe('ExpressWay', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('default', () => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-cell__text': '配送方式',
|
||||
'.van-express-way__fee': '¥100.50',
|
||||
'.van-express-way__type': mockData[0].postage_title,
|
||||
'.van-actionsheet__header h3': '配送方式',
|
||||
'.van-express-way-option__title span': mockData[0].postage_title,
|
||||
'.van-express-way-option__content p': mockData[0].postage_desc
|
||||
},
|
||||
count: {
|
||||
'.van-icon-arrow': 1
|
||||
},
|
||||
style: {
|
||||
'.van-actionsheet': {
|
||||
display: 'none'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('show actionsheet', (done) => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
// 点击后弹出 actionsheet
|
||||
const cells = wrapper.find('.van-cell');
|
||||
cells[cells.length - 1].trigger('click');
|
||||
setTimeout(() => {
|
||||
expect(wrapper.find('.van-actionsheet')[0].hasStyle('display', 'none')).to.equal(false);
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('change express way', (done) => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.vm.$on('input', val => {
|
||||
wrapper.vm.value = val;
|
||||
});
|
||||
|
||||
// 点击后弹出 actionsheet
|
||||
const cells = wrapper.find('.van-cell');
|
||||
cells[cells.length - 1].trigger('click');
|
||||
|
||||
// 监听 change 事件
|
||||
const submitSpyFunc = sinon.spy();
|
||||
wrapper.vm.$on('change', submitSpyFunc);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.find('.van-actionsheet')[0].hasStyle('display', 'none')).to.equal(false);
|
||||
|
||||
const secondOption = wrapper.find('.van-express-way-option')[1];
|
||||
secondOption.trigger('click');
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.find('.van-actionsheet')[0].hasStyle('display', 'none')).to.equal(true);
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-express-way__fee': '免运费',
|
||||
'.van-express-way__type': mockData[1].postage_title
|
||||
}
|
||||
});
|
||||
|
||||
// 修改后触发 change 事件
|
||||
expect(submitSpyFunc.calledOnce).to.be.true;
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('cellTitle prop', () => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
cellTitle: '测试标题',
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-cell__text': '测试标题'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('actionsheetTitle prop', () => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
actionsheetTitle: '测试标题',
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-actionsheet__header h3': '测试标题'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('set editable false ', () => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
editable: false,
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-icon-arrow': 0,
|
||||
'.van-actionsheet': 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('not editable when only one option', () => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: 1,
|
||||
editable: true,
|
||||
expressList: mockData.slice(0, 1)
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-icon-arrow': 0,
|
||||
'.van-actionsheet': 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('unexist express type', () => {
|
||||
wrapper = mount(ExpressWay, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
value: -1,
|
||||
expressList: mockData
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-express-way__fee': '',
|
||||
'.van-express-way__type': ''
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,81 +0,0 @@
|
||||
import InvalidGoods from 'packages/invalid-goods/index';
|
||||
import { mount } from 'avoriaz';
|
||||
import { DOMChecker } from '../utils';
|
||||
|
||||
const mockItem = {
|
||||
sku: [{ v: '商品SKU1' }, { v: '商品SKU2' }],
|
||||
num: 2,
|
||||
'sku_id': 123,
|
||||
title: '商品名称',
|
||||
price: 12200,
|
||||
'unavailable_desc': '超出配送区域',
|
||||
'img_url': 'https://img.yzcdn.cn/upload_files/2017/06/29/FnPSAKkEeh4FnDA09oIbmnlzWQrw.png'
|
||||
};
|
||||
|
||||
describe('InvalidGoods', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('default', () => {
|
||||
wrapper = mount(InvalidGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
goods: [mockItem, mockItem, mockItem]
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-invalid-goods__title': '以下商品无法一起购买,点击查看原因',
|
||||
'.van-actionsheet__header h3': '以下商品无法一起下单',
|
||||
'.van-invalid-goods-card__price': '¥122.00',
|
||||
'.van-invalid-goods-card__sku': '商品SKU1, 商品SKU2',
|
||||
'.van-invalid-goods-card__title': mockItem.title,
|
||||
'.van-invalid-goods-card__num': 'x' + mockItem.num,
|
||||
'.van-invalid-goods-card__desc': mockItem.unavailable_desc,
|
||||
'.van-invalid-goods__count span': '共3件'
|
||||
},
|
||||
count: {
|
||||
'.van-invalid-goods-card': 3,
|
||||
'.van-invalid-goods__gallery img': 3
|
||||
},
|
||||
src: {
|
||||
'.van-invalid-goods__thumb img': mockItem.img_url
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('title prop', () => {
|
||||
wrapper = mount(InvalidGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
goods: [mockItem],
|
||||
title: '标题'
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-invalid-goods__title': '标题'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('actionsheetTitle prop', () => {
|
||||
wrapper = mount(InvalidGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
goods: [mockItem],
|
||||
actionsheetTitle: 'actionsheet标题'
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-actionsheet__header h3': 'actionsheet标题'
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
43
test/unit/specs/nav-bar.spec.js
Normal file
43
test/unit/specs/nav-bar.spec.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import NavBar from 'packages/nav-bar';
|
||||
import { mount } from 'avoriaz';
|
||||
import { DOMChecker } from '../utils';
|
||||
|
||||
describe('NavBar', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a NavBar', () => {
|
||||
wrapper = mount(NavBar, {
|
||||
propsData: {
|
||||
title: '标题',
|
||||
leftText: '返回',
|
||||
rightText: '按钮',
|
||||
leftArrow: true
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-nav-bar__title': '标题',
|
||||
'.van-nav-bar__left .van-nav-bar__text': '返回',
|
||||
'.van-nav-bar__right .van-nav-bar__text': '按钮'
|
||||
},
|
||||
count: {
|
||||
'.van-nav-bar__arrow': 1
|
||||
}
|
||||
});
|
||||
expect(wrapper.hasClass('van-nav-bar')).to.be.true;
|
||||
});
|
||||
|
||||
it('NavBar fixed', () => {
|
||||
wrapper = mount(NavBar, {
|
||||
propsData: {
|
||||
fixed: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-nav-bar')).to.be.true;
|
||||
});
|
||||
});
|
@@ -1,311 +0,0 @@
|
||||
import OrderGoods from 'packages/order-goods';
|
||||
import { mount } from 'avoriaz';
|
||||
import { DOMChecker } from '../utils';
|
||||
|
||||
const item1 = {
|
||||
img_url: 'https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg',
|
||||
pay_price: 1050,
|
||||
title: '商品 A',
|
||||
num: '1'
|
||||
};
|
||||
|
||||
const item2 = {
|
||||
points_price: 200,
|
||||
pay_price: 50,
|
||||
img_url: 'https://img.yzcdn.cn/upload_files/2017/07/02/e89d56cd92ad8ce3b9d8e1babc3758b6.jpg',
|
||||
title: '商品 B',
|
||||
num: '15',
|
||||
sku: [{ v: '商品SKU1' }, { v: '商品SKU2' }]
|
||||
};
|
||||
|
||||
const item3 = {
|
||||
pay_price: 50,
|
||||
img_url: 'https://img.yzcdn.cn/upload_files/2017/07/02/e89d56cd92ad8ce3b9d8e1babc3758b6.jpg',
|
||||
title: '商品 C',
|
||||
num: '15',
|
||||
is_presale: true,
|
||||
delivery_time: '三天后发货',
|
||||
show_delivery_time: true,
|
||||
is_presale: true,
|
||||
is_present: true,
|
||||
message: {
|
||||
'留言1': '留言1内容',
|
||||
'留言2': 'https://img.yzcdn.cn/upload_files/2017/07/02/e89d56cd92ad8ce3b9d8e1babc3758b6.jpg'
|
||||
}
|
||||
};
|
||||
|
||||
describe('OrderGoods', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('default', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
shopName: '起码运动馆',
|
||||
price: item1.pay_price,
|
||||
itemList: [item1],
|
||||
message: '留言留言'
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-header a': '起码运动馆',
|
||||
'.van-order-goods-price .van-cell__value span': '¥10.50',
|
||||
'.van-card__title': item1.title,
|
||||
'.van-card__num': 'x ' + item1.num,
|
||||
'.van-card__price': '¥10.50'
|
||||
},
|
||||
value: {
|
||||
'.van-order-goods-message textarea': '留言留言'
|
||||
},
|
||||
src: {
|
||||
'.van-card__thumb img': item1.img_url
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('empty list', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: []
|
||||
}
|
||||
});
|
||||
|
||||
const submitSpyFunc = sinon.spy();
|
||||
wrapper.vm.$on('clickEmptyButton', submitSpyFunc);
|
||||
|
||||
wrapper.find('.van-button')[0].trigger('click');
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-empty p': '当前没有可购买的商品,请重新选择',
|
||||
'.van-order-goods-empty button': '返回重新选择'
|
||||
},
|
||||
src: {
|
||||
'.van-order-goods-empty img': 'http://b.yzcdn.cn/v2/image/wap/trade/new_order/empty@2x.png'
|
||||
}
|
||||
});
|
||||
|
||||
expect(submitSpyFunc.calledOnce).to.be.true;
|
||||
});
|
||||
|
||||
it('empty list config', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
emptyIcon: 'https://img.yzcdn.cn/upload_files/2017/07/01/FlIeRrn5bMRoWhcwp4Dp1TmVAXKy.jpg',
|
||||
emptyMessage: '测试',
|
||||
emptyButtonText: '测试'
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-empty p': '测试',
|
||||
'.van-order-goods-empty button': '测试'
|
||||
},
|
||||
src: {
|
||||
'.van-order-goods-empty img': 'https://img.yzcdn.cn/upload_files/2017/07/01/FlIeRrn5bMRoWhcwp4Dp1TmVAXKy.jpg'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('edit message', (done) => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item1],
|
||||
message: ''
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.vm.$on('input', val => {
|
||||
wrapper.vm.message = val;
|
||||
expect(wrapper.vm.message).to.equal('测试留言');
|
||||
done();
|
||||
});
|
||||
|
||||
const textarea = wrapper.find('textarea')[0];
|
||||
textarea.element.value = '测试留言';
|
||||
textarea.trigger('input');
|
||||
});
|
||||
|
||||
it('message not editable', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item1],
|
||||
message: '留言留言',
|
||||
messageEditable: false
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-message p': '留言留言'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('message not editable && empty', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item1],
|
||||
message: '',
|
||||
messageEditable: false
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-message p': ''
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('points props', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item1],
|
||||
points: 100
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-price .van-cell__value span': '100积分'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('points prop and price prop', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item1],
|
||||
points: 100,
|
||||
price: 1050
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-order-goods-price .van-cell__value span': '100积分 + ¥10.50'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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('item with points', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item2]
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-card__price': '200积分 + ¥0.50',
|
||||
'.van-card__title': item2.title,
|
||||
'.van-card__num': 'x ' + item2.num
|
||||
},
|
||||
src: {
|
||||
'.van-card__thumb img': item2.img_url
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('presable item with deliveryTime', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item3]
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-card__price': '¥0.50',
|
||||
'.van-card__title': item3.title,
|
||||
'.van-card__num': 'x ' + item3.num,
|
||||
'.van-order-goods-card__delivery .van-cell__value span': item3.delivery_time
|
||||
},
|
||||
count: {
|
||||
'.van-order-goods-card__present': 1,
|
||||
'.van-order-goods-card__tag-green': 1
|
||||
},
|
||||
src: {
|
||||
'.van-card__thumb img': item3.img_url
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('item with message', (done) => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item3]
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-order-goods-card__message-button': 1,
|
||||
'.van-order-goods-card__message li': 2
|
||||
},
|
||||
style: {
|
||||
'.van-order-goods-card__message': {
|
||||
'display': 'none'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const messageButton = wrapper.find('.van-order-goods-card__message-button')[0];
|
||||
messageButton.trigger('click');
|
||||
|
||||
setTimeout(function() {
|
||||
DOMChecker(wrapper, {
|
||||
noStyle: {
|
||||
'.van-order-goods-card__message': {
|
||||
'display': 'none'
|
||||
}
|
||||
}
|
||||
});
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('multi items', () => {
|
||||
wrapper = mount(OrderGoods, {
|
||||
attachToDocument: true,
|
||||
propsData: {
|
||||
itemList: [item1, item2, item3]
|
||||
}
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
count: {
|
||||
'.van-order-goods-card': 3
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@@ -8,7 +8,7 @@ describe('Search', () => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a quantity', () => {
|
||||
it('create a stepper', () => {
|
||||
wrapper = mount(Search);
|
||||
|
||||
expect(wrapper.hasClass('van-search')).to.be.true;
|
||||
|
@@ -1,43 +1,43 @@
|
||||
import Quantity from 'packages/quantity';
|
||||
import Stepper from 'packages/stepper';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('Quantity', () => {
|
||||
describe('Stepper', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create a quantity', () => {
|
||||
wrapper = mount(Quantity, {
|
||||
it('create a stepper', () => {
|
||||
wrapper = mount(Stepper, {
|
||||
propsData: {
|
||||
defaultValue: 1
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-quantity')).to.be.true;
|
||||
expect(wrapper.hasClass('van-stepper')).to.be.true;
|
||||
expect(wrapper.data().currentValue).to.equal(1);
|
||||
|
||||
const plusButton = wrapper.find('.van-quantity__plus')[0];
|
||||
const plusButton = wrapper.find('.van-stepper__plus')[0];
|
||||
plusButton.trigger('click');
|
||||
|
||||
expect(wrapper.data().currentValue).to.equal(2);
|
||||
|
||||
const minusButton = wrapper.find('.van-quantity__minus')[0];
|
||||
const minusButton = wrapper.find('.van-stepper__minus')[0];
|
||||
minusButton.trigger('click');
|
||||
expect(wrapper.data().currentValue).to.equal(1);
|
||||
});
|
||||
|
||||
it('create a disabled quantity', (done) => {
|
||||
wrapper = mount(Quantity, {
|
||||
it('create a disabled stepper', (done) => {
|
||||
wrapper = mount(Stepper, {
|
||||
propsData: {
|
||||
disabled: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-quantity')).to.be.true;
|
||||
const minusButton = wrapper.find('.van-quantity__minus')[0];
|
||||
expect(minusButton.hasClass('van-quantity__minus--disabled')).to.be.true;
|
||||
expect(wrapper.hasClass('van-stepper')).to.be.true;
|
||||
const minusButton = wrapper.find('.van-stepper__minus')[0];
|
||||
expect(minusButton.hasClass('van-stepper__minus--disabled')).to.be.true;
|
||||
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
minusButton.trigger('click');
|
||||
@@ -48,8 +48,8 @@ describe('Quantity', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
const plusButton = wrapper.find('.van-quantity__plus')[0];
|
||||
expect(plusButton.hasClass('van-quantity__plus--disabled')).to.be.true;
|
||||
const plusButton = wrapper.find('.van-stepper__plus')[0];
|
||||
expect(plusButton.hasClass('van-stepper__plus--disabled')).to.be.true;
|
||||
|
||||
plusButton.trigger('click');
|
||||
|
||||
@@ -60,14 +60,14 @@ describe('Quantity', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('update quantity value use v-model', (done) => {
|
||||
wrapper = mount(Quantity, {
|
||||
it('update stepper value use v-model', (done) => {
|
||||
wrapper = mount(Stepper, {
|
||||
propsData: {
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-quantity')).to.be.true;
|
||||
expect(wrapper.hasClass('van-stepper')).to.be.true;
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
|
||||
wrapper.vm.value = 2;
|
||||
@@ -80,14 +80,14 @@ describe('Quantity', () => {
|
||||
});
|
||||
|
||||
it('correct value when value is not correct', (done) => {
|
||||
wrapper = mount(Quantity, {
|
||||
wrapper = mount(Stepper, {
|
||||
propsData: {
|
||||
value: 50,
|
||||
max: 30
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-quantity')).to.be.true;
|
||||
expect(wrapper.hasClass('van-stepper')).to.be.true;
|
||||
expect(wrapper.vm.currentValue).to.equal(30);
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
|
||||
@@ -101,13 +101,13 @@ describe('Quantity', () => {
|
||||
});
|
||||
|
||||
it('handle when input change', (done) => {
|
||||
wrapper = mount(Quantity, {
|
||||
wrapper = mount(Stepper, {
|
||||
propsData: {
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
|
||||
const input = wrapper.find('.van-quantity__input')[0];
|
||||
const input = wrapper.find('.van-stepper__input')[0];
|
||||
input.element.value = 2;
|
||||
input.trigger('input');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import PayOrder from 'packages/pay-order';
|
||||
import SubmitBar from 'packages/submit-bar';
|
||||
import { mount } from 'avoriaz';
|
||||
import { DOMChecker } from '../utils';
|
||||
|
||||
describe('PayOrder', () => {
|
||||
describe('SubmitBar', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
@@ -15,22 +15,22 @@ describe('PayOrder', () => {
|
||||
tip: '您的收货地址不支持同城送, 我们已为您推荐快递'
|
||||
};
|
||||
|
||||
wrapper = mount(PayOrder, {
|
||||
wrapper = mount(SubmitBar, {
|
||||
propsData: props
|
||||
});
|
||||
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-button__text': props.buttonText,
|
||||
'.van-pay-order__price-interger': '¥30.',
|
||||
'.van-pay-order__price-decimal': '50',
|
||||
'.van-pay-order__tip': props.tip
|
||||
'.van-submit-bar__price-interger': '¥30.',
|
||||
'.van-submit-bar__price-decimal': '50',
|
||||
'.van-submit-bar__tip': props.tip
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('no tip', () => {
|
||||
wrapper = mount(PayOrder, {
|
||||
wrapper = mount(SubmitBar, {
|
||||
propsData: {
|
||||
price: 3005,
|
||||
buttonText: '提交订单',
|
||||
@@ -41,15 +41,15 @@ describe('PayOrder', () => {
|
||||
DOMChecker(wrapper, {
|
||||
text: {
|
||||
'.van-button__text': '提交订单',
|
||||
'.van-pay-order__price-interger': '¥30.',
|
||||
'.van-pay-order__price-decimal': '05',
|
||||
'.van-pay-order__tip': ''
|
||||
'.van-submit-bar__price-interger': '¥30.',
|
||||
'.van-submit-bar__price-decimal': '05',
|
||||
'.van-submit-bar__tip': ''
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('handle submit', () => {
|
||||
wrapper = mount(PayOrder, {
|
||||
wrapper = mount(SubmitBar, {
|
||||
propsData: {
|
||||
price: 3005,
|
||||
buttonText: '提交订单'
|
||||
@@ -65,7 +65,7 @@ describe('PayOrder', () => {
|
||||
});
|
||||
|
||||
it('can not submit when disabled', () => {
|
||||
wrapper = mount(PayOrder, {
|
||||
wrapper = mount(SubmitBar, {
|
||||
propsData: {
|
||||
disabled: true,
|
||||
buttonText: '提交订单'
|
||||
@@ -81,7 +81,7 @@ describe('PayOrder', () => {
|
||||
});
|
||||
|
||||
it('can not submit when loading', () => {
|
||||
wrapper = mount(PayOrder, {
|
||||
wrapper = mount(SubmitBar, {
|
||||
propsData: {
|
||||
loading: true,
|
||||
buttonText: '提交订单'
|
@@ -1,19 +1,19 @@
|
||||
import DeepSelect from 'packages/deep-select';
|
||||
import TreeSelect from 'packages/tree-select';
|
||||
import { mount } from 'avoriaz';
|
||||
|
||||
describe('DeepSelect', () => {
|
||||
describe('TreeSelect', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
});
|
||||
|
||||
it('create an empty deep-select', () => {
|
||||
wrapper = mount(DeepSelect);
|
||||
it('create an empty tree-select', () => {
|
||||
wrapper = mount(TreeSelect);
|
||||
expect(wrapper.hasStyle('height', '0px')).to.be.true;
|
||||
});
|
||||
|
||||
it('create a deep-select correctly', () => {
|
||||
wrapper = mount(DeepSelect, {
|
||||
it('create a tree-select correctly', () => {
|
||||
wrapper = mount(TreeSelect, {
|
||||
propsData: {
|
||||
items: [{
|
||||
text: 'A',
|
||||
@@ -25,13 +25,13 @@ describe('DeepSelect', () => {
|
||||
maxHeight: 200
|
||||
}
|
||||
});
|
||||
expect(wrapper.hasClass('van-deep-select')).to.be.true;
|
||||
expect(wrapper.hasClass('van-tree-select')).to.be.true;
|
||||
expect(wrapper.hasStyle('height', '44px')).to.be.true;
|
||||
expect(wrapper.propsData().maxHeight).to.equal(200);
|
||||
expect(wrapper.vm.maxHeight).to.equal(200);
|
||||
});
|
||||
|
||||
it('interact with this component', () => {
|
||||
wrapper = mount(DeepSelect, {
|
||||
wrapper = mount(TreeSelect, {
|
||||
propsData: {
|
||||
items: [{
|
||||
text: 'A',
|
||||
@@ -58,10 +58,10 @@ describe('DeepSelect', () => {
|
||||
wrapper.vm.$on('itemclick', item => {
|
||||
wrapper.vm.activeId = item.id;
|
||||
});
|
||||
const secondNav = wrapper.find('.van-deep-select__nitem')[1];
|
||||
const secondNav = wrapper.find('.van-tree-select__nitem')[1];
|
||||
secondNav.trigger('click');
|
||||
expect(wrapper.vm.mainActiveIndex).to.equal(1);
|
||||
const target = wrapper.find('.van-deep-select__item')[0];
|
||||
const target = wrapper.find('.van-tree-select__item')[0];
|
||||
target.trigger('click');
|
||||
expect(wrapper.vm.activeId).to.equal(345);
|
||||
});
|
Reference in New Issue
Block a user