diff --git a/pages/component/button/button.test.js b/pages/component/button/button.test.js index 7a8bfdf2ffe4e9989010f18e628ffb002c508b4f..e6eaaaf0a6bfe5758c0d5f7104aa4523823c826b 100644 --- a/pages/component/button/button.test.js +++ b/pages/component/button/button.test.js @@ -1,78 +1,77 @@ function getData(key = '') { - return new Promise(async (resolve, reject) => { - const data = await page.data() - resolve(key ? data[key] : data) - }) + 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/button/button') - await page.waitFor(1000) + page = await program.reLaunch('/pages/component/button/button') + await page.waitFor(1000) }) describe('Button.uvue', () => { - it('click', async () => { - const defaultBtn = await page.$('.default-button') - const disabledBtn = await page.$('.disabled-button') - expect(await getData('count')).toEqual(0) - await defaultBtn.tap() - expect(await getData('count')).toEqual(1) - await disabledBtn.tap() - expect(await getData('count')).toEqual(1) + it('click', async () => { + const defaultBtn = await page.$('.default-button') + const disabledBtn = await page.$('.disabled-button') + expect(await getData('count')).toEqual(0) + await defaultBtn.tap() + expect(await getData('count')).toEqual(1) + await disabledBtn.tap() + expect(await getData('count')).toEqual(1) + }) + it('length', async () => { + const elements = await page.$$('.button') + expect(elements.length).toBe(13) + }) + it('text', async () => { + const textBtn = await page.$('.text-button') + expect(await textBtn.text()).toEqual('按钮') + await page.setData({ + text: 'button', }) - it('length', async () => { - const elements = await page.$$('.button') - expect(elements.length).toBe(13) + expect(await textBtn.text()).toEqual('button') + }) + it('type', async () => { + const btn = await page.$('.test-button') + expect(await btn.property('type')).toBe('primary') + await page.setData({ + type: 'default', }) - // it('text', async () => { - // const textBtn = await page.$('.text-button') - // expect(await textBtn.text()).toEqual('按钮') - // await page.setData({ - // text: 'button' - // }) - // // TODO 待修复 - // expect(await textBtn.text()).toEqual('button') - // }) - it('type', async () => { - const btn = await page.$('.test-button') - expect(await btn.property('type')).toBe('primary') - await page.setData({ - type: 'default' - }) - await page.waitFor(500) - expect(await btn.property('type')).toBe('default') - await page.setData({ - type: 'warn' - }) - await page.waitFor(500) - expect(await btn.property('type')).toBe('warn') + await page.waitFor(500) + expect(await btn.property('type')).toBe('default') + await page.setData({ + type: 'warn', }) - it('size', async () => { - const btn = await page.$('.test-button') - expect(await btn.property('size')).toBe('default') - await page.setData({ - size: 'mini' - }) - await page.waitFor(500) - expect(await btn.property('size')).toBe('mini') + await page.waitFor(500) + expect(await btn.property('type')).toBe('warn') + }) + it('size', async () => { + const btn = await page.$('.test-button') + expect(await btn.property('size')).toBe('default') + await page.setData({ + size: 'mini', }) - it('plain', async () => { - const btn = await page.$('.test-button') - expect(await btn.property('plain')).toBe(false) - await page.setData({ - plain: true - }) - await page.waitFor(500) - expect(await btn.property('plain')).toBe(true) + await page.waitFor(500) + expect(await btn.property('size')).toBe('mini') + }) + it('plain', async () => { + const btn = await page.$('.test-button') + expect(await btn.property('plain')).toBe(false) + await page.setData({ + plain: true, }) - it('disabled', async () => { - const btn = await page.$('.test-button') - expect(await btn.property('disabled')).toBe(false) - await page.setData({ - disabled: true - }) - await page.waitFor(500) - expect(await btn.property('disabled')).toBe(true) + await page.waitFor(500) + expect(await btn.property('plain')).toBe(true) + }) + it('disabled', async () => { + const btn = await page.$('.test-button') + expect(await btn.property('disabled')).toBe(false) + await page.setData({ + disabled: true, }) -}) \ No newline at end of file + await page.waitFor(500) + expect(await btn.property('disabled')).toBe(true) + }) +}) diff --git a/pages/component/checkbox/checkbox.test.js b/pages/component/checkbox/checkbox.test.js index d9bf6be578a797e5fe6e23490fff3472f530b4af..24d0e86b09092336b47e6fbb70cca12963ee5cf3 100644 --- a/pages/component/checkbox/checkbox.test.js +++ b/pages/component/checkbox/checkbox.test.js @@ -1,70 +1,70 @@ function getData(key = '') { - return new Promise(async (resolve, reject) => { - const data = await page.data() - resolve(key ? data[key] : data) - }) + 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/checkbox/checkbox') - await page.waitFor(1000) + page = await program.reLaunch('/pages/component/checkbox/checkbox') + await page.waitFor(1000) }) describe('Checkbox.uvue', () => { - // it('change', async () => { - // const cb = await page.$('.cb') - // const cb1 = await page.$('.cb1') - // const cb2 = await page.$('.cb2') - // expect(await getData('value')).toEqual([]) - // await cb1.tap() - // expect(await getData('value')).toEqual(["cb", "cb1"]) - // await cb.tap() - // expect(await getData('value')).toEqual(["cb1"]) - // await cb2.tap() - // expect(await getData('value')).toEqual(["cb1"]) - // await cb1.tap() - // expect(await getData('value')).toEqual([]) - // }) - it('length', async () => { - const checkboxGroupElements = await page.$$('.checkbox-group') - expect(checkboxGroupElements.length).toBe(3) - const checkboxElements = await page.$$('.checkbox') - expect(checkboxElements.length).toBe(11) + it('change', async () => { + const cb = await page.$('.cb') + const cb1 = await page.$('.cb1') + const cb2 = await page.$('.cb2') + expect(await getData('value')).toEqual([]) + await cb1.tap() + expect(await getData('value')).toEqual(['cb', 'cb1']) + await cb.tap() + expect(await getData('value')).toEqual(['cb1']) + await cb2.tap() + expect(await getData('value')).toEqual(['cb1']) + await cb1.tap() + expect(await getData('value')).toEqual([]) + }) + it('length', async () => { + const checkboxGroupElements = await page.$$('.checkbox-group') + expect(checkboxGroupElements.length).toBe(3) + const checkboxElements = await page.$$('.checkbox') + expect(checkboxElements.length).toBe(11) + }) + it('text', async () => { + const cb = await page.$('.cb1') + expect(await cb.text()).toEqual('未选中') + await page.setData({ + text: 'not selected', + }) + expect(await cb.text()).toEqual('not selected') + }) + it('checked', async () => { + const cb = await page.$('.cb') + expect(await cb.property('checked')).toBe(true) + await page.setData({ + checked: false, + }) + await page.waitFor(500) + expect(await cb.property('checked')).toBe(false) + }) + it('color', async () => { + const cb = await page.$('.cb') + expect(await cb.property('color')).toBe('#007aff') + await page.setData({ + color: '#63acfc', }) - // it('text', async () => { - // const cb = await page.$('.cb1') - // expect(await cb.text()).toEqual('未选中') - // await page.setData({ - // text: 'not selected' - // }) - // expect(await cb.text()).toEqual('not selected') - // }) - // it('checked', async () => { - // const cb = await page.$('.cb') - // expect(await cb.property('checked')).toBe(true) - // await page.setData({ - // checked: false - // }) - // await page.waitFor(500) - // expect(await cb.property('checked')).toBe(false) - // }) - // it('color', async () => { - // const cb = await page.$('.cb') - // expect(await cb.property('color')).toBe('#007aff') - // await page.setData({ - // color: '#63acfc' - // }) - // await page.waitFor(500) - // expect(await cb.property('color')).toBe('#63acfc') - // }) - // it('disabled', async () => { - // const cb = await page.$('.cb2') - // expect(await cb.property('disabled')).toBe(true) - // await page.setData({ - // disabled: false - // }) - // await page.waitFor(500) - // expect(await cb.property('disabled')).toBe(false) - // }) -}) \ No newline at end of file + await page.waitFor(500) + expect(await cb.property('color')).toBe('#63acfc') + }) + it('disabled', async () => { + const cb = await page.$('.cb2') + expect(await cb.property('disabled')).toBe(true) + await page.setData({ + disabled: false, + }) + await page.waitFor(500) + expect(await cb.property('disabled')).toBe(false) + }) +}) diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js index 3384036ccf40bc4385411b4f36d643a551494e7c..da7cb110b08cc9bd0dfbac50f4e48ba1255f403d 100644 --- a/pages/component/picker-view/picker-view.test.js +++ b/pages/component/picker-view/picker-view.test.js @@ -1,58 +1,58 @@ function getData(key = '') { - return new Promise(async (resolve, reject) => { - const data = await page.data() - resolve(key ? data[key] : data) - }) + 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/picker-view/picker-view') - await page.waitFor(1000) + page = await program.reLaunch('/pages/component/picker-view/picker-view') + await page.waitFor(1000) }) describe('PickerView.uvue', () => { - // it('value', async () => { - // const el = await page.$('.picker-view') - // await page.callMethod('setValue') - // await page.waitFor(1000) - // expect(await el.property('value')).toEqual([0, 0, 0]) - // expect(await getData('result')).toEqual([0, 0, 0]) + it('value', async () => { + const el = await page.$('.picker-view') + await page.callMethod('setValue') + await page.waitFor(1000) + expect(await el.property('value')).toEqual([0, 0, 0]) + expect(await getData('result')).toEqual([0, 0, 0]) - // await page.callMethod('setValue1') - // await page.waitFor(1000) - // expect(await el.property('value')).toEqual([10, 10, 10]) - // expect(await getData('result')).toEqual([10, 10, 10]) - // }) + await page.callMethod('setValue1') + await page.waitFor(1000) + expect(await el.property('value')).toEqual([10, 10, 10]) + expect(await getData('result')).toEqual([10, 10, 10]) + }) - it('length', async () => { - const els = await page.$$('.picker-view') - expect(els.length).toBe(1) - const els1 = await page.$$('.picker-view-column') - expect(els1.length).toBe(3) + it('length', async () => { + const els = await page.$$('.picker-view') + expect(els.length).toBe(1) + const els1 = await page.$$('.picker-view-column') + expect(els1.length).toBe(3) + }) + it('indicator-style', async () => { + const el = await page.$('.picker-view') + await page.setData({ + indicatorStyle: 'height: 100px;', }) - // it('indicator-style', async () => { - // const el = await page.$('.picker-view') - // await page.setData({ - // indicatorStyle: 'height: 100px;' - // }) - // await page.waitFor(500) - // expect(await el.property('indicatorStyle')).toBe('height: 100px;') - // }) - // it('mask-top-style', async () => { - // const el = await page.$('.picker-view') - // await page.setData({ - // maskTopStyle: 'background: #ffffff;' - // }) - // await page.waitFor(500) - // expect(await el.property('mask-top-style')).toBe('background: #ffffff;') - // }) - // it('mask-bottom-style', async () => { - // const el = await page.$('.picker-view') - // await page.setData({ - // maskBottomStyle: 'background: #ffffff;' - // }) - // await page.waitFor(500) - // expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;') - // }) -}) \ No newline at end of file + await page.waitFor(500) + expect(await el.property('indicatorStyle')).toBe('height: 100px;') + }) + it('mask-top-style', async () => { + const el = await page.$('.picker-view') + await page.setData({ + maskTopStyle: 'background: #ffffff;', + }) + await page.waitFor(500) + expect(await el.property('mask-top-style')).toBe('background: #ffffff;') + }) + it('mask-bottom-style', async () => { + const el = await page.$('.picker-view') + await page.setData({ + maskBottomStyle: 'background: #ffffff;', + }) + await page.waitFor(500) + expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;') + }) +}) diff --git a/pages/component/radio/radio.test.js b/pages/component/radio/radio.test.js index 98702b83b57710e8b98dba3deccf97bcd3d3bc8e..2fd2c1e5f34aa1f82046efac00f3cb55a5049184 100644 --- a/pages/component/radio/radio.test.js +++ b/pages/component/radio/radio.test.js @@ -1,68 +1,68 @@ function getData(key = '') { - return new Promise(async (resolve, reject) => { - const data = await page.data() - resolve(key ? data[key] : data) - }) + 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) + 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('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.$('.r1') + expect(await radio.text()).toEqual('未选中') + await page.setData({ + text: 'not selected', + }) + expect(await radio.text()).toEqual('not selected') + }) + 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', }) - // it('text', async () => { - // const radio = await page.$('.r1') - // expect(await radio.text()).toEqual('未选中') - // await page.setData({ - // text: 'not selected' - // }) - // expect(await radio.text()).toEqual('not selected') - // }) - // 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 + 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) + }) +})