ColorPicker: fix nocorrect rgb value (#5179) (#5183)

pull/2510/merge
kingwl 2017-06-04 17:11:16 +08:00 committed by baiyaaaaa
parent 49c970c3d8
commit 88b5bc6e63
2 changed files with 24 additions and 2 deletions

View File

@ -117,7 +117,7 @@ const rgb2hsv = function(r, g, b) {
h /= 6;
}
return { h: Math.round(h * 360), s: Math.round(s * 100), v: Math.round(v * 100) };
return { h: h * 360, s: s * 100, v: v * 100 };
};
// `hsvToRgb`

View File

@ -80,6 +80,29 @@ describe('ColorPicker', () => {
}, ANIMATION_TIME);
});
it('should show correct rgb value', (done) => {
const vm = createVue({
template: `
<el-color-picker v-model="color"></el-color-picker>
`,
data() {
return {
color: '#20A0FF'
};
}
}, true);
const trigger = vm.$el.querySelector('.el-color-picker__trigger');
trigger.click();
setTimeout(() => {
const value = document.querySelector('.el-color-dropdown__value');
expect(value.innerText.trim().toUpperCase()).to.equal('#20A0FF');
done();
}, ANIMATION_TIME);
});
it('should init the right color when open', (done) => {
const vm = createVue({
template: `
@ -216,4 +239,3 @@ describe('ColorPicker', () => {
}, ANIMATION_TIME);
});
});