diff --git a/pages/component/radio/radio.test.js b/pages/component/radio/radio.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a3c3b8fdaab78a07e55f14ff4771991d7e0998f
--- /dev/null
+++ b/pages/component/radio/radio.test.js
@@ -0,0 +1,68 @@
+function getData(key = '') {
+ return new Promise(async (resolve, reject) => {
+ const data = await page.data()
+ resolve(key ? data[key] : data)
+ })
+}
+
+let page
+beforeAll(async () => {
+ page = await program.reLaunch('/pages/component/radio/radio')
+ await page.waitFor(1000)
+})
+
+describe('Radio.uvue', () => {
+ it('change', async () => {
+ const radio = await page.$('.r')
+ const radio1 = await page.$('.r1')
+ const radio2 = await page.$('.r2')
+ expect(await getData('value')).toEqual("")
+ await radio1.tap()
+ expect(await getData('value')).toEqual("r1")
+ await radio.tap()
+ expect(await getData('value')).toEqual("r")
+ await radio2.tap()
+ expect(await getData('value')).toEqual("r")
+ })
+ it('length', async () => {
+ const radioGroupElements = await page.$$('.radio-group')
+ expect(radioGroupElements.length).toBe(3)
+ const radioElements = await page.$$('.radio')
+ expect(radioElements.length).toBe(11)
+ })
+ it('text', async () => {
+ const radio = await page.$('.r')
+ expect(await radio.text()).toEqual('选中')
+ await page.setData({
+ text: 'checked'
+ })
+ expect(await radio.text()).toEqual('checked')
+ })
+ it('checked', async () => {
+ const radio = await page.$('.r')
+ expect(await radio.property('checked')).toBe(true)
+ await page.setData({
+ checked: false
+ })
+ await page.waitFor(500)
+ expect(await radio.property('checked')).toBe(false)
+ })
+ it('color', async () => {
+ const radio = await page.$('.r')
+ expect(await radio.property('color')).toBe('#007aff')
+ await page.setData({
+ color: '#63acfc'
+ })
+ await page.waitFor(500)
+ expect(await radio.property('color')).toBe('#63acfc')
+ })
+ it('disabled', async () => {
+ const radio = await page.$('.r2')
+ expect(await radio.property('disabled')).toBe(true)
+ await page.setData({
+ disabled: false
+ })
+ await page.waitFor(500)
+ expect(await radio.property('disabled')).toBe(false)
+ })
+})
\ No newline at end of file
diff --git a/pages/component/radio/radio.uvue b/pages/component/radio/radio.uvue
index eddac277dde10b307869f06bcb22186b4b63666c..69764f85e1e2cc650479a3758a2a016a29229a68 100644
--- a/pages/component/radio/radio.uvue
+++ b/pages/component/radio/radio.uvue
@@ -7,10 +7,12 @@
默认样式
-
- 选中
- 未选中
-
+
+ {{text}}
+
+ 未选中
+ 禁用
+
@@ -18,11 +20,12 @@
不同颜色和尺寸的radio
-
- 选中
+
+ 选中
- 未选中
-
+ 未选中
+
@@ -32,8 +35,8 @@
-
-
+
{{item.name}}
@@ -76,7 +79,13 @@
name: '法国'
},
] as ItemType[],
- current: 0
+ current: 0,
+
+ value: '',
+ text: '选中',
+ disabled: true,
+ checked: true,
+ color: '#007aff'
}
},
methods: {
@@ -87,6 +96,9 @@
break;
}
}
+ },
+ testChange(e : RadioGroupChangeEvent) {
+ this.value = e.detail.value
}
}
}