search.test1.js 1.0 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start

describe('pages/list/search/search.vue', () => {
	let page
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
7
		page = await program.navigateTo('/pages/list/search/search')
study夏羽's avatar
study夏羽 已提交
8 9
		await page.waitFor(500)
	})
study夏羽's avatar
study夏羽 已提交
10
	it('搜索发现-显示-隐藏', async () => {
study夏羽's avatar
study夏羽 已提交
11
		// expect.assertions(2);
study夏羽's avatar
study夏羽 已提交
12 13 14 15 16 17 18 19 20 21 22
		await page.callMethod('searchHotRefresh')
		await page.waitFor(300)
		const getShow = await page.data('netHotListIsHide')
		expect(getShow).toBeFalsy()
		if(!getShow){
			await page.setData({netHotListIsHide: true})
			expect(await page.data('netHotListIsHide')).toBeTruthy()
		}
	})

	it('搜索内容', async () => {
study夏羽's avatar
study夏羽 已提交
23
		// expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
24 25 26
		const setSearchTest = await page.setData({
			searchText: '小程序',
		})
study夏羽's avatar
study夏羽 已提交
27
		console.log(await page.data('searchText'));
study夏羽's avatar
study夏羽 已提交
28 29
		await page.callMethod('search', '小程序')
		await page.waitFor(300)
study夏羽's avatar
study夏羽 已提交
30
		console.log(await program.currentPage(),"-----------------------");
study夏羽's avatar
study夏羽 已提交
31 32 33
		expect((await program.currentPage()).path).toBe('pages/list/list')
	})
});