提交 a9b41a60 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

test: 补充 checkbox iconColor/foreColor 相关测试

上级 85446a1d
...@@ -67,6 +67,23 @@ describe('Checkbox.uvue', () => { ...@@ -67,6 +67,23 @@ describe('Checkbox.uvue', () => {
}) })
expect(await cb.attribute('color')).toBe('#63acfc') expect(await cb.attribute('color')).toBe('#63acfc')
}) })
it('icon color', async () => {
const cb = await page.$('.cb')
expect(await cb.attribute('iconColor')).toBe('#211cfe')
await page.setData({
iconColor: '#63acfc',
})
expect(await cb.attribute('iconColor')).toBe('#63acfc')
})
it('foreColor', async () => {
const cb = await page.$('.cb')
expect(await cb.attribute('foreColor')).toBe('#ff0000')
await page.setData({
foreColor: '#63acfe',
})
expect(await cb.attribute('foreColor')).toBe('#63acfe')
})
it('disabled', async () => { it('disabled', async () => {
const cb = await page.$('.cb2') const cb = await page.$('.cb2')
expect(await cb.attribute('disabled')).toBe(true + '') expect(await cb.attribute('disabled')).toBe(true + '')
...@@ -78,7 +95,7 @@ describe('Checkbox.uvue', () => { ...@@ -78,7 +95,7 @@ describe('Checkbox.uvue', () => {
it('trigger UniCheckboxGroupChangeEvent', async () => { it('trigger UniCheckboxGroupChangeEvent', async () => {
const element = await page.$('.checkbox-item-0') const element = await page.$('.checkbox-item-0')
await element.tap() await element.tap()
await page.waitFor(500) await page.waitFor(1000)
const eventCallbackNum = await page.callMethod('getEventCallbackNum') const eventCallbackNum = await page.callMethod('getEventCallbackNum')
expect(eventCallbackNum - originEventCallbackNum).toBe(3) expect(eventCallbackNum - originEventCallbackNum).toBe(3)
}) })
......
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
value: [] as string[], value: [] as string[],
disabled: true, disabled: true,
checked: true, checked: true,
color: '#007aff', color: '#007aff',
iconColor:'#211cfe',
foreColor:'#ff0000',
// 组件属性 autotest // 组件属性 autotest
checked_boolean: false, checked_boolean: false,
disabled_boolean: false, disabled_boolean: false,
...@@ -55,7 +57,8 @@ ...@@ -55,7 +57,8 @@
borderColor_input: "#d1d1d1", borderColor_input: "#d1d1d1",
activeBackgroundColor_input: "#ffffff", activeBackgroundColor_input: "#ffffff",
activeBorderColor_input: "#d1d1d1", activeBorderColor_input: "#d1d1d1",
iconColor_input: "#007aff" iconColor_input: "#007aff",
foreColor_input: '#ff0000'
} }
}, },
methods: { methods: {
...@@ -70,7 +73,7 @@ ...@@ -70,7 +73,7 @@
}, },
checkboxChange: function (e : UniCheckboxGroupChangeEvent) { checkboxChange: function (e : UniCheckboxGroupChangeEvent) {
// 自动化测试 // 自动化测试
if ((e.target?.tagName ?? '').includes('CHECKBOX-GROUP')) { if ((e.target?.tagName ?? '') == 'CHECKBOX-GROUP') {
this.setEventCallbackNum(state.eventCallbackNum + 1) this.setEventCallbackNum(state.eventCallbackNum + 1)
} }
if (e.type === 'change') { if (e.type === 'change') {
...@@ -105,19 +108,20 @@ ...@@ -105,19 +108,20 @@
confirm_borderColor_input(value : string) { this.borderColor_input = value }, confirm_borderColor_input(value : string) { this.borderColor_input = value },
confirm_activeBackgroundColor_input(value : string) { this.activeBackgroundColor_input = value }, confirm_activeBackgroundColor_input(value : string) { this.activeBackgroundColor_input = value },
confirm_activeBorderColor_input(value : string) { this.activeBorderColor_input = value }, confirm_activeBorderColor_input(value : string) { this.activeBorderColor_input = value },
confirm_iconColor_input(value : string) { this.iconColor_input = value } confirm_iconColor_input(value : string) { this.iconColor_input = value },
confirm_foreColor_input(value : string) { this.foreColor_input = value }
} }
} }
</script> </script>
<template> <template>
<view class="main"> <view class="main">
<checkbox :disabled="disabled_boolean" :checked="checked_boolean" :color="color_input" <checkbox :disabled="disabled_boolean" :checked="checked_boolean" :color="color_input" :iconColor="iconColor_input"
:backgroundColor="backgroundColor_input" :borderColor="borderColor_input" :foreColor="foreColor_input" :backgroundColor="backgroundColor_input" :borderColor="borderColor_input"
:activeBackgroundColor="activeBackgroundColor_input" :activeBorderColor="activeBorderColor_input" :activeBackgroundColor="activeBackgroundColor_input" :activeBorderColor="activeBorderColor_input"
:iconColor="iconColor_input" @click="checkbox_click" @touchstart="checkbox_touchstart" @click="checkbox_click" @touchstart="checkbox_touchstart" @touchmove="checkbox_touchmove"
@touchmove="checkbox_touchmove" @touchcancel="checkbox_touchcancel" @touchend="checkbox_touchend" @touchcancel="checkbox_touchcancel" @touchend="checkbox_touchend" @tap="checkbox_tap"
@tap="checkbox_tap" @longpress="checkbox_longpress"><text>uni-app-x</text></checkbox> @longpress="checkbox_longpress"><text>uni-app-x</text></checkbox>
</view> </view>
<scroll-view style="flex: 1"> <scroll-view style="flex: 1">
...@@ -134,8 +138,10 @@ ...@@ -134,8 +138,10 @@
@confirm="confirm_activeBackgroundColor_input"></input-data> @confirm="confirm_activeBackgroundColor_input"></input-data>
<input-data defaultValue="#d1d1d1" title="checkbox选中时的边框颜色" type="text" <input-data defaultValue="#d1d1d1" title="checkbox选中时的边框颜色" type="text"
@confirm="confirm_activeBorderColor_input"></input-data> @confirm="confirm_activeBorderColor_input"></input-data>
<input-data defaultValue="#007aff" title="checkbox的图标颜色,优先级大于color属性" type="text" <input-data defaultValue="#007aff" title="iconColor: checkbox的图标颜色,优先级大于color属性" type="text"
@confirm="confirm_iconColor_input"></input-data> @confirm="confirm_iconColor_input"></input-data>
<input-data defaultValue="#ff0000" title="foreColor: checkbox的图标颜色,优先级大于color属性" type="text"
@confirm="confirm_foreColor_input"></input-data>
</view> </view>
<view> <view>
...@@ -146,7 +152,8 @@ ...@@ -146,7 +152,8 @@
</view> </view>
<view> <view>
<checkbox-group class="uni-flex uni-row checkbox-group" @change="testChange" style="flex-wrap: wrap"> <checkbox-group class="uni-flex uni-row checkbox-group" @change="testChange" style="flex-wrap: wrap">
<checkbox value="cb" :checked="checked" :color="color" style="margin-right: 15px" class="checkbox cb">选中 <checkbox value="cb" :checked="checked" :color="color" :iconColor="iconColor"
:foreColor="foreColor" style="margin-right: 15px" class="checkbox cb">选中
</checkbox> </checkbox>
<checkbox value="cb1" style="margin-right: 15px" class="checkbox cb1">{{ text }}</checkbox> <checkbox value="cb1" style="margin-right: 15px" class="checkbox cb1">{{ text }}</checkbox>
<checkbox value="cb2" :disabled="disabled" class="checkbox cb2">禁用</checkbox> <checkbox value="cb2" :disabled="disabled" class="checkbox cb2">禁用</checkbox>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册