ucenter.test.js 2.2 KB
Newer Older
A
Anne_LXM 已提交
1
jest.setTimeout(20000);
study夏羽's avatar
study夏羽 已提交
2
describe('pages/ucenter/ucenter.vue', () => {
A
Anne_LXM 已提交
3
	let page,uniToken,platform;
study夏羽's avatar
study夏羽 已提交
4
	beforeAll(async () => {
A
Anne_LXM 已提交
5 6 7 8 9 10 11 12 13
		page = await program.switchTab('/pages/ucenter/ucenter')
		await page.waitFor('view')
		console.log('page: ',page);
		uniToken = await program.callUniMethod('getStorageSync', 'uni_id_token')
		platform = process.env.UNI_PLATFORM
		console.log("uniToken: ",platform,uniToken);
		if(!uniToken){
			console.log("未登录");
			await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd')
study夏羽's avatar
study夏羽 已提交
14
		}
study夏羽's avatar
study夏羽 已提交
15 16
	})
	it('宫格', async () => {
study夏羽's avatar
study夏羽 已提交
17
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
18
		const getGrid = await page.data('gridList')
study夏羽's avatar
study夏羽 已提交
19
		expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
20 21 22
	})
	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
A
Anne_LXM 已提交
23
		if(platform.startsWith("app") || platform === "h5"){
study夏羽's avatar
study夏羽 已提交
24
			expect(getUcenterList.length).toBe(3)
A
Anne_LXM 已提交
25 26
		}else if(platform === "mp-weixin"){
			expect(getUcenterList.length).toBe(2)
study夏羽's avatar
study夏羽 已提交
27
		}
study夏羽's avatar
study夏羽 已提交
28
	})
study夏羽's avatar
study夏羽 已提交
29
	it('普通签到', async () => {
A
Anne_LXM 已提交
30 31
		console.log("普通签到");
		// await page.waitFor('uni-sign-in')
A
Anne_LXM 已提交
32 33 34
		if(!uniToken)return;
		if(platform.startsWith("app")){
			await page.callMethod('signInByAd')
A
Anne_LXM 已提交
35
			await page.waitFor(500)
A
Anne_LXM 已提交
36 37 38 39 40 41 42 43 44 45
			await page.callMethod('share')
			// await program.screenshot({
			// 	path: "static/screenshot/sign-app.png" 
			// })
		}else if(platform === "h5"){
			await page.callMethod('signIn')
			// await page.waitFor(500)
			// await program.screenshot({
			// 	path: "static/screenshot/sign-h5.png" 
			// })
A
Anne_LXM 已提交
46 47
		}else{
			await page.callMethod('signIn')
A
Anne_LXM 已提交
48 49 50 51
			// await page.waitFor(500)
			// await program.screenshot({
			// 	path: "static/screenshot/sign-weixin.png" 
			// })
study夏羽's avatar
study夏羽 已提交
52
		}
study夏羽's avatar
study夏羽 已提交
53
	})
study夏羽's avatar
study夏羽 已提交
54
	it('我的积分', async () => {
A
Anne_LXM 已提交
55 56
		if(!uniToken)return;
		const getScoreRes = await page.callMethod('getScore')
A
Anne_LXM 已提交
57
		console.log('getScoreRes: ',getScoreRes);
A
Anne_LXM 已提交
58
		await page.waitFor(500)
A
Anne_LXM 已提交
59
		if (getScoreRes.score) {
A
Anne_LXM 已提交
60
			expect.assertions(2);
A
Anne_LXM 已提交
61 62
			expect(getScoreRes.score).not.toBeUndefined();
			expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
A
Anne_LXM 已提交
63 64
		} else {
			console.log("签到失败");
study夏羽's avatar
study夏羽 已提交
65
		}
study夏羽's avatar
study夏羽 已提交
66
	})
A
Anne_LXM 已提交
67 68 69 70 71 72
	// it('screenshot',async()=>{
	// 	await program.screenshot({
	// 		path: "static/screenshot/ucenter.png" 
	// 	})
	// 	await page.waitFor(500);
	// })
A
Anne_LXM 已提交
73
	
study夏羽's avatar
study夏羽 已提交
74
})
A
Anne_LXM 已提交
75