list.test.js 1.4 KB
Newer Older
A
Anne_LXM 已提交
1 2 3
// 	jest.setTimeout(20000)
describe('pages/user-info/list.vue', () => {
	let page,currentPage;
Anne_LXM's avatar
Anne_LXM 已提交
4 5 6 7 8 9 10
  console.log('uniTestPlatformInfo',process.env.uniTestPlatformInfo)
  if(process.env.uniTestPlatformInfo == 'ios_simulator 13.7'){
    it('ios', async () => {
    	expect(1).toBe(1)
      return
    })
  }
A
Anne_LXM 已提交
11 12 13 14
	beforeAll(async () => {
		// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
		page = await program.navigateTo('/pages/user-info/list')
		await page.waitFor('view')
A
Anne_LXM 已提交
15
		console.log('process----',process.env.UNI_PLATFORM)
A
Anne_LXM 已提交
16
	})
A
Anne_LXM 已提交
17 18
	async function waitTime(){
		if(process.env.UNI_PLATFORM == 'mp-weixin'){
Anne_LXM's avatar
Anne_LXM 已提交
19
			await page.waitFor(2000)
A
Anne_LXM 已提交
20
		}else{
Anne_LXM's avatar
Anne_LXM 已提交
21
			await page.waitFor(1000)
A
Anne_LXM 已提交
22 23
		}
	}
A
Anne_LXM 已提交
24 25
	it('点击fab跳转到添加页',async()=>{
		await page.callMethod('fabClick')
A
Anne_LXM 已提交
26
		await waitTime()
A
Anne_LXM 已提交
27
		currentPage = await program.currentPage()
Anne_LXM's avatar
Anne_LXM 已提交
28
    console.log('currentPage',currentPage)
A
Anne_LXM 已提交
29 30 31 32
		expect(currentPage.path).toBe('pages/user-info/add')
		await program.navigateBack()
	})
	it('点击第一条',async()=>{
A
Anne_LXM 已提交
33
		await page.waitFor(2000)
A
Anne_LXM 已提交
34
		const items = await page.$$('.uni-list-item')
A
Anne_LXM 已提交
35 36 37 38
		if(items.length>0){
			await items[0].tap()
			await waitTime()
			currentPage = await program.currentPage()
Anne_LXM's avatar
Anne_LXM 已提交
39
      console.log('currentPage',currentPage)
A
Anne_LXM 已提交
40 41
			expect(currentPage.path).toBe('pages/user-info/detail')
			// await program.navigateBack()
Anne_LXM's avatar
Anne_LXM 已提交
42
			console.log('currentPage',await program.currentPage())
A
Anne_LXM 已提交
43 44 45
		}else{
			console.log('no items');
		}
A
Anne_LXM 已提交
46
	})
A
Anne_LXM 已提交
47
})