提交 d6d2fbc2 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test(swiper): 修复测试逻辑错误

上级 fb0f9c1a
jest.setTimeout(30000); jest.setTimeout(30000);
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
resolve(key ? data[key] : data)
})
}
describe('test swiper', () => { describe('test swiper', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isIos = platformInfo.startsWith('ios') const isIos = platformInfo.startsWith('ios')
...@@ -44,11 +35,11 @@ describe('test swiper', () => { ...@@ -44,11 +35,11 @@ describe('test swiper', () => {
autoplaySelect: true, autoplaySelect: true,
}) })
await page.waitFor(2400) await page.waitFor(2400)
expect(await getData('currentValChange')).toEqual(1) expect(await page.data('currentValChange')).toEqual(1)
await page.waitFor(2000) await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(2) expect(await page.data('currentValChange')).toEqual(2)
await page.waitFor(2000) await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(0) expect(await page.data('currentValChange')).toEqual(0)
await page.setData({ await page.setData({
autoplaySelect: false autoplaySelect: false
...@@ -61,12 +52,12 @@ describe('test swiper', () => { ...@@ -61,12 +52,12 @@ describe('test swiper', () => {
currentVal: 2, currentVal: 2,
}) })
await page.waitFor(600) await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(2) expect(await page.data('currentValChange')).toEqual(2)
await page.setData({ await page.setData({
currentVal: 0, currentVal: 0,
}) })
await page.waitFor(600) await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(0) expect(await page.data('currentValChange')).toEqual(0)
}); });
it('check currentId', async () => { it('check currentId', async () => {
...@@ -74,13 +65,13 @@ describe('test swiper', () => { ...@@ -74,13 +65,13 @@ describe('test swiper', () => {
currentItemIdVal: 'C', currentItemIdVal: 'C',
}) })
await page.waitFor(600) await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(2) expect(await page.data('currentValChange')).toEqual(2)
await page.setData({ await page.setData({
currentItemIdVal: 'A', currentItemIdVal: 'A',
}) })
await page.waitFor(600) await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(0) expect(await page.data('currentValChange')).toEqual(0)
}); });
it('Trigger Event', async () => { it('Trigger Event', async () => {
...@@ -91,8 +82,8 @@ describe('test swiper', () => { ...@@ -91,8 +82,8 @@ describe('test swiper', () => {
autoplaySelect:true autoplaySelect:true
}) })
await page.waitFor(2000) await page.waitFor(2000)
console.log('currentValChange',await getData('currentValChange')) console.log('currentValChange',await page.data('currentValChange'))
if(await getData('currentValChange') == 1){ if(await page.data('currentValChange') == 1){
await page.setData({ await page.setData({
autoplaySelect:false autoplaySelect:false
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册