From 96469f1d3b53861b3f6fb297e6ba834c328e1252 Mon Sep 17 00:00:00 2001
From: yurj26 <1816387074@qq.com>
Date: Fri, 25 Aug 2023 18:31:44 +0800
Subject: [PATCH] feat: update button test
---
pages/component/button/button.test.js | 79 +++++++++++++++
pages/component/button/button.uvue | 139 ++++++++++++++------------
2 files changed, 154 insertions(+), 64 deletions(-)
create mode 100644 pages/component/button/button.test.js
diff --git a/pages/component/button/button.test.js b/pages/component/button/button.test.js
new file mode 100644
index 00000000..76cb4fcf
--- /dev/null
+++ b/pages/component/button/button.test.js
@@ -0,0 +1,79 @@
+const PAGE_PATH = '/pages/component/button/button'
+
+describe('Button.uvue', () => {
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(500)
+ })
+ it('click', async () => {
+ // TODO 待测试框架支持text的dispatchEvent
+ // const btn = await page.$('.btn')
+ // expect((await page.data())['count']).toEqual(0)
+ // await btn.tap()
+ // expect((await page.data())['count']).toEqual(1)
+ // await page.setData({
+ // disabled_boolean: true,
+ // })
+ // await btn.tap()
+ // expect((await page.data())['count']).toEqual(1)
+ // await page.setData({
+ // disabled_boolean: false,
+ // })
+ // await btn.tap()
+ // expect((await page.data())['count']).toEqual(2)
+ })
+ it('length', async () => {
+ const elements = await page.$$('.btn')
+ expect(elements.length).toBe(1)
+ })
+ it('text', async () => {
+ const textBtn = await page.$('.btn')
+ expect(await textBtn.text()).toEqual('uni-app-x')
+ await page.setData({
+ text: 'uni-app-x button',
+ })
+ expect(await textBtn.text()).toEqual('uni-app-x button')
+ })
+ it('type', async () => {
+ const btn = await page.$('.btn')
+ expect(await btn.property('type')).toBe('default')
+ await page.setData({
+ type_enum_current: 1,
+ })
+ await page.waitFor(500)
+ expect(await btn.property('type')).toBe('primary')
+ await page.setData({
+ type_enum_current: 2,
+ })
+ await page.waitFor(500)
+ expect(await btn.property('type')).toBe('warn')
+ })
+ it('size', async () => {
+ const btn = await page.$('.btn')
+ expect(await btn.property('size')).toBe('default')
+ await page.setData({
+ size_enum_current: 1,
+ })
+ await page.waitFor(500)
+ expect(await btn.property('size')).toBe('mini')
+ })
+ it('plain', async () => {
+ const btn = await page.$('.btn')
+ expect(await btn.property('plain')).toBe(false)
+ await page.setData({
+ plain_boolean: true,
+ })
+ await page.waitFor(500)
+ expect(await btn.property('plain')).toBe(true)
+ })
+ it('disabled', async () => {
+ const btn = await page.$('.btn')
+ expect(await btn.property('disabled')).toBe(false)
+ await page.setData({
+ disabled_boolean: true,
+ })
+ await page.waitFor(500)
+ expect(await btn.property('disabled')).toBe(true)
+ })
+})
\ No newline at end of file
diff --git a/pages/component/button/button.uvue b/pages/component/button/button.uvue
index e91398fb..7ceb1623 100644
--- a/pages/component/button/button.uvue
+++ b/pages/component/button/button.uvue
@@ -1,64 +1,75 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
GitLab