settings.test.js 1.3 KB
Newer Older
Anne_LXM's avatar
Anne_LXM 已提交
1 2 3 4
// uniapp自动化测试教程: https://uniapp-test.dcloud.net.cn/docs/testcase/start
jest.setTimeout(30000);
const PAGE_PATH = '/pages/ucenter/settings/settings'
describe('settings', () => {
Anne_LXM's avatar
Anne_LXM 已提交
5 6 7 8 9 10 11
	let page, hasLogin;
	if (process.env.uniTestPlatformInfo == 'ios_simulator 13.7') {
		it('ucenter-ios13.7', async () => {
			expect(1).toBe(1)
		})
		return
	}
Anne_LXM's avatar
Anne_LXM 已提交
12
	beforeAll(async () => {
Anne_LXM's avatar
Anne_LXM 已提交
13 14 15 16 17 18 19
		page = await program.navigateTo(PAGE_PATH)
		await page.waitFor('view')
		hasLogin = await page.callMethod('hasLoginTest')
		console.log("登录状态", hasLogin)
		if (!hasLogin) {
			console.log("未登录测试失败")
			return
Anne_LXM's avatar
Anne_LXM 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
		}
	})
	it('settings', async () => {
		if (process.env.UNI_PLATFORM.startsWith("app")) {
			await page.callMethod('clearTmp')
			const pushRes = await page.data('pushIsOn')
			if (pushRes == "wait") {
				await page.callMethod('pushServer.off')
			}
		} else {
			const el = await page.$('.content')
			await page.waitFor('view')
			expect.assertions(1);
			expect((await el.$$('.mt10')).length).toBe(2)
		}
	})
	it('退出登录', async () => {
		const bottomEl = await page.$('.bottom-back-text')
		console.log('bottom-back-text', bottomEl, await bottomEl.text())
		expect(await bottomEl.text()).toBe('退出登录')
		await page.callMethod('changeLoginState')
		await page.waitFor(1000)
	})
});