ucenter.test.js 1.8 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 14
		try{
			page = await program.switchTab('/pages/ucenter/ucenter')
			await page.waitFor('view')
			console.log('page: ',page);
			console.log('pageStack: ',await program.pageStack());
			uniToken = await program.callUniMethod('getStorageSync', 'uni_id_token')
			platform = process.env.UNI_PLATFORM
			console.log("uniToken: ",platform,uniToken);
		}catch(err){
			console.log('err: ',err);
study夏羽's avatar
study夏羽 已提交
15
		}
study夏羽's avatar
study夏羽 已提交
16 17
	})
	it('宫格', async () => {
study夏羽's avatar
study夏羽 已提交
18
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
19
		const getGrid = await page.data('gridList')
study夏羽's avatar
study夏羽 已提交
20
		expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
21 22 23
	})
	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
A
Anne_LXM 已提交
24
		if(platform.startsWith("app") || platform === "h5"){
study夏羽's avatar
study夏羽 已提交
25
			expect(getUcenterList.length).toBe(3)
A
Anne_LXM 已提交
26 27
		}else if(platform === "mp-weixin"){
			expect(getUcenterList.length).toBe(2)
study夏羽's avatar
study夏羽 已提交
28
		}
study夏羽's avatar
study夏羽 已提交
29
	})
study夏羽's avatar
study夏羽 已提交
30
	it('普通签到', async () => {
A
Anne_LXM 已提交
31 32 33
		if(!uniToken)return;
		if(platform.startsWith("app")){
			await page.callMethod('signInByAd')
A
Anne_LXM 已提交
34
			await page.waitFor(500)
A
Anne_LXM 已提交
35 36 37 38
			await page.callMethod('share')
			// await program.screenshot({
			// 	path: "static/screenshot/sign-app.png" 
			// })
A
Anne_LXM 已提交
39 40
		}else{
			await page.callMethod('signIn')
study夏羽's avatar
study夏羽 已提交
41
		}
study夏羽's avatar
study夏羽 已提交
42
	})
study夏羽's avatar
study夏羽 已提交
43
	it('我的积分', async () => {
A
Anne_LXM 已提交
44 45
		if(!uniToken)return;
		const getScoreRes = await page.callMethod('getScore')
A
Anne_LXM 已提交
46
		console.log('getScoreRes: ',getScoreRes);
A
Anne_LXM 已提交
47
		await page.waitFor(500)
A
Anne_LXM 已提交
48
		if (getScoreRes.score) {
A
Anne_LXM 已提交
49
			expect.assertions(2);
A
Anne_LXM 已提交
50 51
			expect(getScoreRes.score).not.toBeUndefined();
			expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
A
Anne_LXM 已提交
52 53
		} else {
			console.log("签到失败");
study夏羽's avatar
study夏羽 已提交
54
		}
study夏羽's avatar
study夏羽 已提交
55
	})
A
Anne_LXM 已提交
56 57 58 59 60 61
	// it('screenshot',async()=>{
	// 	await program.screenshot({
	// 		path: "static/screenshot/ucenter.png" 
	// 	})
	// 	await page.waitFor(500);
	// })
A
Anne_LXM 已提交
62
	
study夏羽's avatar
study夏羽 已提交
63
})
A
Anne_LXM 已提交
64