提交 ee8a872c 编写于 作者: Y yurj26

feat(button): test

上级 122546b5
...@@ -35,9 +35,8 @@ describe('Button.uvue', () => { ...@@ -35,9 +35,8 @@ describe('Button.uvue', () => {
expect(await textBtn.text()).toEqual('button') expect(await textBtn.text()).toEqual('button')
}) })
it('type', async () => { it('type', async () => {
// TODO 目前获取组件属性只能通过组件的name,并且拿到的是最后一个 const btn = await page.$('.test-button')
const btn = await page.$('Button') expect(await btn.property('type')).toBe('primary')
expect(await btn.property('type')).toBe('warn')
await page.setData({ await page.setData({
type: 'default' type: 'default'
}) })
...@@ -50,19 +49,16 @@ describe('Button.uvue', () => { ...@@ -50,19 +49,16 @@ describe('Button.uvue', () => {
expect(await btn.property('type')).toBe('warn') expect(await btn.property('type')).toBe('warn')
}) })
it('size', async () => { it('size', async () => {
const btn = await page.$('Button') const btn = await page.$('.test-button')
expect(await btn.property('size')).toBe('mini')
await page.setData({
size: 'default'
})
await page.waitFor(500)
expect(await btn.property('size')).toBe('default') expect(await btn.property('size')).toBe('default')
await page.setData({ await page.setData({
size: 'mini' size: 'mini'
}) })
await page.waitFor(500)
expect(await btn.property('size')).toBe('mini')
}) })
it('plain', async () => { it('plain', async () => {
const btn = await page.$('Button') const btn = await page.$('.test-button')
expect(await btn.property('plain')).toBe(false) expect(await btn.property('plain')).toBe(false)
await page.setData({ await page.setData({
plain: true plain: true
...@@ -71,7 +67,7 @@ describe('Button.uvue', () => { ...@@ -71,7 +67,7 @@ describe('Button.uvue', () => {
expect(await btn.property('plain')).toBe(true) expect(await btn.property('plain')).toBe(true)
}) })
it('disabled', async () => { it('disabled', async () => {
const btn = await page.$('Button') const btn = await page.$('.test-button')
expect(await btn.property('disabled')).toBe(false) expect(await btn.property('disabled')).toBe(false)
await page.setData({ await page.setData({
disabled: true disabled: true
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<view> <view>
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<button type="primary" class="button test-button">页面主操作 Normal</button> <button :type="type" :size="size" :plain="plain" :disabled="disabled" class="button test-button">页面主操作
Normal</button>
<!-- <button type="primary" :loading="loading" class="button">页面主操作 Loading</button> --> <!-- <button type="primary" :loading="loading" class="button">页面主操作 Loading</button> -->
<button type="primary" :disabled="true" class="button">页面主操作 Disabled</button> <button type="primary" :disabled="true" class="button">页面主操作 Disabled</button>
...@@ -24,8 +25,7 @@ ...@@ -24,8 +25,7 @@
<view class="uni-flex uni-row"> <view class="uni-flex uni-row">
<button class="button mini-btn" type="primary" size="mini">按钮</button> <button class="button mini-btn" type="primary" size="mini">按钮</button>
<button class="button mini-btn" type="default" size="mini">按钮</button> <button class="button mini-btn" type="default" size="mini">按钮</button>
<button class="button mini-btn" :type="type" :size="size" :plain="plain" <button class="button mini-btn" type="warn" size="mini">按钮</button>
:disabled="disabled">按钮</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
loading: false, loading: false,
_timer: 0, _timer: 0,
text: '按钮', text: '按钮',
type: 'warn', type: 'primary',
size: 'mini', size: 'default',
plain: false, plain: false,
disabled: false, disabled: false,
count: 0 count: 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册