mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
add unit test
This commit is contained in:
parent
1b90609fc6
commit
efd24b0680
@ -51,7 +51,7 @@ make init componentName
|
|||||||
在`docs/nav.config.json`文件里合适的地方写入组件声明,根据组件类型(JS组件,CSS组件,Form等)进行区分 在`docs/examples-docs`目录里新建同名的md文件,如`waterfall.md`,在项目的根目录下执行以下命令,启动server:
|
在`docs/nav.config.json`文件里合适的地方写入组件声明,根据组件类型(JS组件,CSS组件,Form等)进行区分 在`docs/examples-docs`目录里新建同名的md文件,如`waterfall.md`,在项目的根目录下执行以下命令,启动server:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
make dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
浏览器访问[http://localhost:8080](http://localhost:8080)就可以看到所有组件的示例了。
|
浏览器访问[http://localhost:8080](http://localhost:8080)就可以看到所有组件的示例了。
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
"css-loader": "^0.24.0",
|
"css-loader": "^0.24.0",
|
||||||
"decamelize": "^1.2.0",
|
"decamelize": "^1.2.0",
|
||||||
"eslint-loader": "^1.7.1",
|
"eslint-loader": "^1.7.1",
|
||||||
|
"eslint-plugin-vue": "^2.0.1",
|
||||||
"extract-text-webpack-plugin": "^2.0.0-beta.5",
|
"extract-text-webpack-plugin": "^2.0.0-beta.5",
|
||||||
"favicons-webpack-plugin": "0.0.7",
|
"favicons-webpack-plugin": "0.0.7",
|
||||||
"felint": "^0.5.0-alpha.3",
|
"felint": "^0.5.0-alpha.3",
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ZanIcon from 'packages/icon';
|
import VanIcon from 'packages/icon';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-search',
|
name: 'van-search',
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
ZanIcon
|
VanIcon
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
*/
|
*/
|
||||||
handleTabClick(index, el) {
|
handleTabClick(index, el) {
|
||||||
if (el.disabled) {
|
if (el.disabled) {
|
||||||
el.$emit('disabled', index);
|
this.$emit('disabled', index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<van-tabs>
|
<van-tabs :active="active">
|
||||||
<van-tab title="选项一">内容一</van-tab>
|
<van-tab title="选项一">内容一</van-tab>
|
||||||
<van-tab title="选项二" disabled>内容二</van-tab>
|
<van-tab title="选项二">内容二</van-tab>
|
||||||
<van-tab title="选项三">内容三</van-tab>
|
<van-tab title="选项三" disabled>内容三</van-tab>
|
||||||
<van-tab title="选项四">内容四</van-tab>
|
<van-tab title="选项四">内容四</van-tab>
|
||||||
<van-tab title="选项五">内容五</van-tab>
|
<van-tab title="选项五">内容五</van-tab>
|
||||||
</van-tabs>
|
</van-tabs>
|
||||||
@ -16,6 +16,12 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
'van-tab': Tab,
|
'van-tab': Tab,
|
||||||
'van-tabs': Tabs
|
'van-tabs': Tabs
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
active: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -16,7 +16,6 @@ describe('Field', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.hasClass('van-field')).to.be.true;
|
expect(wrapper.hasClass('van-field')).to.be.true;
|
||||||
expect(wrapper.propsData().type).to.equal('text');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create a text field with initialize value', (done) => {
|
it('create a text field with initialize value', (done) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Tabs from 'packages/tabs';
|
import Tabs from 'packages/tabs';
|
||||||
import { mount } from 'avoriaz';
|
import { mount } from 'avoriaz';
|
||||||
// import TabsTestComponent from '../components/tabs';
|
import TabsTestComponent from '../components/tabs';
|
||||||
|
|
||||||
describe('Tabs', () => {
|
describe('Tabs', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
@ -20,22 +20,20 @@ describe('Tabs', () => {
|
|||||||
expect(wrapper.hasClass('van-tabs--card')).to.be.true;
|
expect(wrapper.hasClass('van-tabs--card')).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create a tabs with four tab', () => {
|
it('create a tabs with four tab', (done) => {
|
||||||
// wrapper = mount(TabsTestComponent);
|
wrapper = mount(TabsTestComponent);
|
||||||
|
|
||||||
// expect(wrapper.hasClass('van-tabs')).to.be.true;
|
expect(wrapper.hasClass('van-tabs')).to.be.true;
|
||||||
// expect(wrapper.hasClass('van-tabs--line')).to.be.true;
|
expect(wrapper.hasClass('van-tabs--line')).to.be.true;
|
||||||
|
|
||||||
// const eventStub = sinon.stub(wrapper.vNode.child, '$emit');
|
const tabsContainer = wrapper.find('.van-tabs')[0];
|
||||||
|
expect(tabsContainer.vNode.child.curActive).to.equal(0);
|
||||||
|
|
||||||
// const tabTitle = wrapper.find('.van-tab__pane')[2];
|
wrapper.vm.active = 1;
|
||||||
// tabTitle.simulate('click');
|
wrapper.update();
|
||||||
|
wrapper.vm.$nextTick(() => {
|
||||||
// wrapper.vm.$nextTick(() => {
|
expect(tabsContainer.vNode.child.curActive).to.equal(1);
|
||||||
// // expect(.curActive).to.equal(2);
|
done();
|
||||||
// console.log(wrapper.vNode.child);
|
});
|
||||||
// expect(eventStub.calledWith('click'));
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,13 +15,7 @@ describe('Uploader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.contains('input')).to.equal(true);
|
expect(wrapper.contains('input')).to.equal(true);
|
||||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [] }})).to.equal(undefined);
|
expect(wrapper.vm.onValueChange({ target: { files: [] }})).to.equal(undefined);
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Uploader', () => {
|
|
||||||
let wrapper;
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper && wrapper.destroy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disabled', () => {
|
it('disabled', () => {
|
||||||
@ -32,13 +26,7 @@ describe('Uploader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.contains('input')).to.equal(true);
|
expect(wrapper.contains('input')).to.equal(true);
|
||||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [] }})).to.equal(undefined);
|
expect(wrapper.vm.onValueChange({ target: { files: [] }})).to.equal(undefined);
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Uploader', () => {
|
|
||||||
let wrapper;
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper && wrapper.destroy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('before read', () => {
|
it('before read', () => {
|
||||||
@ -52,13 +40,7 @@ describe('Uploader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.contains('input')).to.equal(true);
|
expect(wrapper.contains('input')).to.equal(true);
|
||||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '')] }})).to.equal(undefined);
|
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '')] }})).to.equal(undefined);
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Uploader', () => {
|
|
||||||
let wrapper;
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper && wrapper.destroy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('read text', () => {
|
it('read text', () => {
|
||||||
@ -73,13 +55,7 @@ describe('Uploader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.contains('input')).to.equal(true);
|
expect(wrapper.contains('input')).to.equal(true);
|
||||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Uploader', () => {
|
|
||||||
let wrapper;
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper && wrapper.destroy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('read text no after hook', () => {
|
it('read text no after hook', () => {
|
||||||
@ -91,13 +67,7 @@ describe('Uploader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.contains('input')).to.equal(true);
|
expect(wrapper.contains('input')).to.equal(true);
|
||||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Uploader', () => {
|
|
||||||
let wrapper;
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper && wrapper.destroy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('read dataUrl', () => {
|
it('read dataUrl', () => {
|
||||||
@ -112,6 +82,6 @@ describe('Uploader', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.contains('input')).to.equal(true);
|
expect(wrapper.contains('input')).to.equal(true);
|
||||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user