mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
Merge branch 'feature/unit_test'
This commit is contained in:
commit
dcdad916e0
11
package.json
11
package.json
@ -22,7 +22,7 @@
|
|||||||
"deploy:docs": "rimraf docs/dist && npm run build:example && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.js",
|
"deploy:docs": "rimraf docs/dist && npm run build:example && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.js",
|
||||||
"dist": "npm run clean && npm run build:file && npm run lint && npm run build:zanui && npm run build:components && npm run build:utils && npm run build:zanui-css",
|
"dist": "npm run clean && npm run build:file && npm run lint && npm run build:zanui && npm run build:components && npm run build:utils && npm run build:zanui-css",
|
||||||
"clean": "rimraf lib && rimraf packages/*/lib",
|
"clean": "rimraf lib && rimraf packages/*/lib",
|
||||||
"lint": "eslint src/**/*.js packages/**/*.{js,vue} build/**/*.js --quiet",
|
"lint": "felint lint src/**/*.js packages/**/*.{js,vue} build/**/*.js",
|
||||||
"test": "karma start test/unit/karma.conf.js --single-run; npm run coverage",
|
"test": "karma start test/unit/karma.conf.js --single-run; npm run coverage",
|
||||||
"test:watch": "karma start test/unit/karma.conf.js",
|
"test:watch": "karma start test/unit/karma.conf.js",
|
||||||
"coverage": "find test/unit/coverage/lcov-report -name 'index.html' | sed -n 1,1p | xargs -I {} open {} ",
|
"coverage": "find test/unit/coverage/lcov-report -name 'index.html' | sed -n 1,1p | xargs -I {} open {} ",
|
||||||
@ -69,15 +69,8 @@
|
|||||||
"cp-cli": "^1.0.2",
|
"cp-cli": "^1.0.2",
|
||||||
"cross-env": "^3.1.3",
|
"cross-env": "^3.1.3",
|
||||||
"css-loader": "^0.24.0",
|
"css-loader": "^0.24.0",
|
||||||
"eslint": "^3.15.0",
|
|
||||||
"eslint-config-standard": "^5.1.0",
|
|
||||||
"eslint-friendly-formatter": "^2.0.5",
|
|
||||||
"eslint-loader": "^1.3.0",
|
|
||||||
"eslint-plugin-html": "^1.3.0",
|
|
||||||
"eslint-plugin-promise": "^1.0.8",
|
|
||||||
"eslint-plugin-standard": "^1.3.2",
|
|
||||||
"eslint-plugin-vue": "^2.0.1",
|
|
||||||
"extract-text-webpack-plugin": "^2.0.0-beta.5",
|
"extract-text-webpack-plugin": "^2.0.0-beta.5",
|
||||||
|
"felint": "^0.5.0-alpha.3",
|
||||||
"file-loader": "^0.9.0",
|
"file-loader": "^0.9.0",
|
||||||
"file-save": "^0.2.0",
|
"file-save": "^0.2.0",
|
||||||
"gh-pages": "^0.12.0",
|
"gh-pages": "^0.12.0",
|
||||||
|
@ -16,9 +16,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onItemClick() {
|
onItemClick() {}
|
||||||
console.log('click');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -19,65 +19,64 @@ describe('Field', () => {
|
|||||||
expect(wrapper.propsData().type).to.equal('text');
|
expect(wrapper.propsData().type).to.equal('text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create a text field with initialize value', () => {
|
it('create a text field with initialize value', (done) => {
|
||||||
// wrapper = mount(Field, {
|
wrapper = mount(Field, {
|
||||||
// propsData: {
|
propsData: {
|
||||||
// value: 'test'
|
value: 'test'
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// expect(wrapper.hasClass('zan-field')).to.be.true;
|
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||||
// expect(wrapper.data().currentValue).to.equal('test');
|
expect(wrapper.data().currentValue).to.equal('test');
|
||||||
|
|
||||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||||
|
|
||||||
// wrapper.vm.value = 'test2';
|
wrapper.vm.value = 'test2';
|
||||||
// wrapper.update();
|
wrapper.update();
|
||||||
// wrapper.vm.$nextTick(() => {
|
wrapper.vm.$nextTick(() => {
|
||||||
// expect(wrapper.data().currentValue).to.equal('test2');
|
expect(wrapper.data().currentValue).to.equal('test2');
|
||||||
// expect(eventStub.calledOnce).to.be.true;
|
expect(eventStub.calledWith('input'));
|
||||||
// expect(eventStub.calledWith('input'));
|
done();
|
||||||
// done();
|
});
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('emit a focus event', () => {
|
it('input some value to filed', (done) => {
|
||||||
// wrapper = mount(Field, {
|
wrapper = mount(Field, {
|
||||||
// propsData: {}
|
propsData: {}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// const input = wrapper.find('.zan-field__control')[0];
|
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
const input = wrapper.find('.zan-field__control')[0];
|
||||||
|
input.element.focus();
|
||||||
|
|
||||||
// input.simulate('focus');
|
wrapper.update();
|
||||||
|
wrapper.vm.$nextTick(() => {
|
||||||
// expect(eventStub.calledOnce).to.be.true;
|
expect(eventStub.calledWith('focus'));
|
||||||
// expect(eventStub.calledWith('focus')).to.be.true;
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('input some value to filed', () => {
|
|
||||||
// wrapper = mount(Field, {
|
|
||||||
// propsData: {}
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const input = wrapper.find('.zan-field__control')[0];
|
|
||||||
// input.element.value = 'test';
|
|
||||||
|
|
||||||
// wrapper.update();
|
|
||||||
// wrapper.vm.$nextTick(() => {
|
|
||||||
// expect(wrapper.data().currentValue).to.equal('test');
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create a textarea field', () => {
|
it('create a textarea field', () => {
|
||||||
// wrapper = mount(Field, {
|
wrapper = mount(Field, {
|
||||||
// propsData: {
|
propsData: {
|
||||||
// type: 'textarea',
|
type: 'textarea',
|
||||||
// autosize: false
|
autosize: false
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
|
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||||
|
expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create a autosize textarea field', () => {
|
||||||
|
wrapper = mount(Field, {
|
||||||
|
propsData: {
|
||||||
|
type: 'textarea',
|
||||||
|
autosize: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||||
|
expect(wrapper.hasClass('zan-field--autosize')).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user