ucenter.test.js 1.9 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
describe('pages/ucenter/ucenter.vue', () => {

	let page
	beforeAll(async () => {
		page = await program.switchTab('/pages/ucenter/ucenter')
		await page.waitFor(300)
	})

	it('宫格', async () => {
		const getGrid = await page.data('gridList')
		// console.log("getGrid: ",getGrid);
		expect(getGrid.length).toBe(4)
	})

	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
		// console.log("getUcenterList: ",getUcenterList);
		expect(getUcenterList.length).toBe(3)
	})
study夏羽's avatar
study夏羽 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
	

	it('普通签到', async () => {

		
		if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM === "mp-weixin") {
			await page.callMethod('signIn')
			await page.waitFor(300)
			const image = await program.screenshot({
				path: "static/screenshot/sign-h5.png" // 默认项目根目录 process.env.UNI_PLATFORM === "h5" || 
			})
			console.log(image, "image--------------------")
		}
		
		
		if (process.env.UNI_PLATFORM === "app-plus") {
			const signInByAdRes = await page.callMethod('signInByAd')
			console.log("signInByAdRes: ",signInByAdRes);
			
			await page.waitFor(300)
			const shareRes = await page.callMethod('share')
			console.log("shareRes: ",shareRes);
			await page.waitFor(300)
			
			const imageApp = await program.screenshot({
				path: "static/screenshot/sign-app.png" // 默认项目根目录 process.env.UNI_PLATFORM === "h5" || 
			})
			console.log(imageApp, "imageApp--------------------")
			
		}
	})
study夏羽's avatar
study夏羽 已提交
51 52 53

	it('我的积分', async () => {
		// expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
54
		await page.waitFor(300)
study夏羽's avatar
study夏羽 已提交
55

study夏羽's avatar
study夏羽 已提交
56 57
		const getScoreRes = await page.callMethod('getScore')
		console.log("getScoreRes: ", getScoreRes);
study夏羽's avatar
study夏羽 已提交
58 59 60 61 62 63 64 65
		if (getScoreRes) {
			console.log("今日已签到");
			expect(getScoreRes.score).not.toBeUndefined();
			expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
		} else {
			console.log("签到失败");
		}

study夏羽's avatar
study夏羽 已提交
66
		// await page.waitFor(500)
study夏羽's avatar
study夏羽 已提交
67 68 69 70
	})


})