From 0e520f9653e6015f205d8adcae37f29ecece1fe3 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 18 Oct 2016 14:29:05 +0800 Subject: [PATCH] DatePicker: add test DatePicker: clean code --- .babelrc | 3 +- .travis.yml | 6 +- examples/docs/zh-cn/date-picker.md | 8 +- examples/docs/zh-cn/datetime-picker.md | 4 +- package.json | 1 + .../date-picker/src/basic/time-spinner.vue | 9 +- packages/date-picker/src/panel/date.vue | 1 + packages/date-picker/src/panel/time-range.vue | 4 - packages/date-picker/src/panel/time.vue | 4 - packages/date-picker/src/picker.vue | 3 - .../date-picker/src/picker/date-picker.js | 6 +- packages/theme-default/package.json | 3 +- test/unit/specs/date-picker.spec.js | 222 ++++++++++++++++++ test/unit/specs/time-picker.spec.js | 4 +- 14 files changed, 243 insertions(+), 35 deletions(-) create mode 100644 test/unit/specs/date-picker.spec.js diff --git a/.babelrc b/.babelrc index 11c0b05d19..4a39588495 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,4 @@ { "presets": [["es2015", { "loose": true }]], - "plugins": ["transform-vue-jsx"], - "comments": false + "plugins": ["transform-vue-jsx"] } diff --git a/.travis.yml b/.travis.yml index 6276b8b9c9..6f6c16323b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,6 @@ before_install: - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi" - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi" - "phantomjs --version" -script: - - "make dist" - - "npm t" + +after_success: + - cat ./test/unit/coverage/lcov.info | ./node_modules/.bin/coveralls diff --git a/examples/docs/zh-cn/date-picker.md b/examples/docs/zh-cn/date-picker.md index 90d13e4f02..045e998970 100644 --- a/examples/docs/zh-cn/date-picker.md +++ b/examples/docs/zh-cn/date-picker.md @@ -4,12 +4,12 @@ return { pickerOptions0: { disabledDate(time) { - return time < Date.now(); + return time.getTime() < Date.now() - 8.64e7; } }, pickerOptions1: { disabledDate(time) { - return time < Date.now(); + return time.getTime() < Date.now() - 8.64e7; }, shortcuts: [{ text: '今天', @@ -133,7 +133,7 @@ return { pickerOptions0: { disabledDate(time) { - return time < Date.now(); + return time.getTime() < Date.now() - 8.64e7; } }, pickerOptions1: { @@ -276,7 +276,7 @@ |---------- |-------------- |---------- |-------------------------------- |-------- | | readonly | 只读 | boolean | — | false | | placeholder | 占位内容 | string | — | — | -| type | 显示类型 | string | year/month/date/datetime/week | date | +| type | 显示类型 | string | year/month/date/week/
datetime/datetimerange/daterange | date | | format | 时间日期格式化 | string | 年 `yyyy`,月 `MM`,日 `dd`,
小时 `HH`,分 `mm`,秒 `ss` | yyyy-MM-dd | | align | 对齐方式 | string | left, center, right | left | |picker-options | 当前时间日期选择器特有的选项
参考下表 | object | — | {} | diff --git a/examples/docs/zh-cn/datetime-picker.md b/examples/docs/zh-cn/datetime-picker.md index 9d30480a88..151b2860ca 100644 --- a/examples/docs/zh-cn/datetime-picker.md +++ b/examples/docs/zh-cn/datetime-picker.md @@ -232,10 +232,10 @@ |---------- |-------------- |---------- |-------------------------------- |-------- | | readonly | 只读 | boolean | — | false | | placeholder | 占位内容 | string | — | — | -| type | 显示类型 | string | year/month/date/datetime/week | date | +| type | 显示类型 | string | year/month/date/week/
datetime/datetimerange/daterange | date | | format | 时间日期格式化 | string | 年 `yyyy`,月 `MM`,日 `dd`,
小时 `HH`,分 `mm`,秒 `ss` | yyyy-MM-dd | | align | 对齐方式 | string | left, center, right | left | -|picker-options | 当前时间日期选择器特有的选项
参考下表 | object | — | {} | +| picker-options | 当前时间日期选择器特有的选项
参考下表 | object | — | {} | ### Picker Options | 参数 | 说明 | 类型 | 可选值 | 默认值 | diff --git a/package.json b/package.json index 8895b25254..7a5c496245 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "cooking": "^1.1.0", "cooking-lint": "^0.1.3", "cooking-vue2": "^0.1.4", + "coveralls": "^2.11.14", "cp-cli": "^1.0.2", "css-loader": "^0.24.0", "extract-text-webpack-plugin": "^1.0.1", diff --git a/packages/date-picker/src/basic/time-spinner.vue b/packages/date-picker/src/basic/time-spinner.vue index 75a6bbb1ed..ad75ef4b29 100644 --- a/packages/date-picker/src/basic/time-spinner.vue +++ b/packages/date-picker/src/basic/time-spinner.vue @@ -46,7 +46,7 @@ -