feat: add tests && fix bugs

This commit is contained in:
jiangruowei
2017-04-06 15:11:29 +08:00
parent a85c3c2695
commit a32142c723
9 changed files with 216 additions and 46 deletions
+7
View File
@@ -11,12 +11,18 @@
* <zan-button size="large" type="primary">按钮</zan-button>
*/
import ZanLoading from 'packages/loading';
const ALLOWED_SIZE = ['mini', 'small', 'normal', 'large'];
const ALLOWED_TYPE = ['default', 'danger', 'primary'];
export default {
name: 'zan-button',
components: {
'zan-loading': ZanLoading
},
props: {
disabled: Boolean,
loading: Boolean,
@@ -45,6 +51,7 @@ export default {
methods: {
handleClick(e) {
if (this.loading || this.disabled) return;
this.$emit('click', e);
}
},
+2 -2
View File
@@ -53,7 +53,7 @@ export default {
type: {
type: String,
default: 'text',
validate(value) {
validator(value) {
return VALID_TYPES.indexOf(value) > -1;
}
},
@@ -71,7 +71,7 @@ export default {
autosize: {
type: Boolean,
default: false,
validate(value) {
validator(value) {
if (value && this.type !== 'textarea') return false;
}
}
+2 -2
View File
@@ -14,14 +14,14 @@ export default {
type: {
type: String,
default: 'gradient-circle',
validate(value) {
validator(value) {
return VALID_TYPES.indexOf(value) > -1;
}
},
color: {
type: String,
default: 'black',
validate(value) {
validator(value) {
return VALID_COLORS.indexOf(value) > -1;
}
}
+1 -4
View File
@@ -33,7 +33,7 @@ export default {
percentage: {
type: Number,
required: true,
validate(value) {
validator(value) {
return value <= 100 && value >= 0;
}
},
@@ -55,9 +55,6 @@ export default {
},
computed: {
currentPivotText() {
return this.pivotText ? this.pivotText : this.percentage + '%';
},
componentColor() {
return this.inactive ? INACTIVE_COLOR : this.color;
},
-1
View File
@@ -62,7 +62,6 @@ export default {
*/
toggleState: function() {
if (this.disabled || this.loading) return;
console.log('d');
if (this.onChange) {
this.onChange(!this.checked);
} else {
+2 -2
View File
@@ -50,14 +50,14 @@ export default {
type: {
type: String,
default: 'text',
validate(value) {
validator(value) {
return TOAST_TYPES.indexOf(value) > -1;
}
},
message: {
type: String,
default: '',
validate(value) {
validator(value) {
if (this.type === 'success' || this.type === 'fail') {
return value.length <= 16;
}