From 730a269e00185aad9d430cb5ae80a9f1578ea688 Mon Sep 17 00:00:00 2001
From: yurj26 <1816387074@qq.com>
Date: Fri, 30 Jun 2023 18:36:20 +0800
Subject: [PATCH] fix(component): test
---
pages/component/button/button.test.js | 4 ++--
pages/component/checkbox/checkbox.test.js | 12 +++++++-----
pages/component/checkbox/checkbox.uvue | 6 +++---
pages/component/radio/radio.test.js | 8 ++++----
pages/component/radio/radio.uvue | 6 +++---
5 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/pages/component/button/button.test.js b/pages/component/button/button.test.js
index 98ccf957..222df019 100644
--- a/pages/component/button/button.test.js
+++ b/pages/component/button/button.test.js
@@ -22,8 +22,8 @@ describe('Button.uvue', () => {
expect(await getData('count')).toEqual(1)
})
it('length', async () => {
- const btnLen = await page.$$('.button')
- expect(btnLen.length).toBe(13)
+ const elements = await page.$$('.button')
+ expect(elements.length).toBe(13)
})
it('text', async () => {
const textBtn = await page.$('.text-button')
diff --git a/pages/component/checkbox/checkbox.test.js b/pages/component/checkbox/checkbox.test.js
index 39ebb22b..211dc6b8 100644
--- a/pages/component/checkbox/checkbox.test.js
+++ b/pages/component/checkbox/checkbox.test.js
@@ -22,7 +22,9 @@ describe('Checkbox.uvue', () => {
await cb.tap()
expect(await getData('value')).toEqual(["cb1"])
await cb2.tap()
- expect(await getData('value')).toEqual(["cb1"])
+ expect(await getData('value')).toEqual(["cb1"])
+ await cb1.tap()
+ expect(await getData('value')).toEqual([])
})
it('length', async () => {
const checkboxGroupElements = await page.$$('.checkbox-group')
@@ -31,12 +33,12 @@ describe('Checkbox.uvue', () => {
expect(checkboxElements.length).toBe(11)
})
it('text', async () => {
- const cb = await page.$('.cb')
- expect(await cb.text()).toEqual('选中')
+ const cb = await page.$('.cb1')
+ expect(await cb.text()).toEqual('未选中')
await page.setData({
- text: 'checked'
+ text: 'not selected'
})
- expect(await cb.text()).toEqual('checked')
+ expect(await cb.text()).toEqual('not selected')
})
it('checked', async () => {
const cb = await page.$('.cb')
diff --git a/pages/component/checkbox/checkbox.uvue b/pages/component/checkbox/checkbox.uvue
index fab82ad2..46d915c3 100644
--- a/pages/component/checkbox/checkbox.uvue
+++ b/pages/component/checkbox/checkbox.uvue
@@ -10,8 +10,8 @@
{{text}}
- 未选中
+ class="checkbox cb">选中
+ {{text}}
禁用
@@ -93,7 +93,7 @@
}
] as ItemType[],
- text: '选中',
+ text: '未选中',
value: [] as string[],
disabled: true,
checked: true,
diff --git a/pages/component/radio/radio.test.js b/pages/component/radio/radio.test.js
index 5a3c3b8f..c9e3602d 100644
--- a/pages/component/radio/radio.test.js
+++ b/pages/component/radio/radio.test.js
@@ -31,12 +31,12 @@ describe('Radio.uvue', () => {
expect(radioElements.length).toBe(11)
})
it('text', async () => {
- const radio = await page.$('.r')
- expect(await radio.text()).toEqual('选中')
+ const radio = await page.$('.r1')
+ expect(await radio.text()).toEqual('未选中')
await page.setData({
- text: 'checked'
+ text: 'not selected'
})
- expect(await radio.text()).toEqual('checked')
+ expect(await radio.text()).toEqual('not selected')
})
it('checked', async () => {
const radio = await page.$('.r')
diff --git a/pages/component/radio/radio.uvue b/pages/component/radio/radio.uvue
index 69764f85..0e8db2a7 100644
--- a/pages/component/radio/radio.uvue
+++ b/pages/component/radio/radio.uvue
@@ -8,9 +8,9 @@
- {{text}}
+ 选中
- 未选中
+ {{text}}
禁用
@@ -82,7 +82,7 @@
current: 0,
value: '',
- text: '选中',
+ text: '未选中',
disabled: true,
checked: true,
color: '#007aff'
--
GitLab