choose-location.test.js 1.5 KB
Newer Older
1
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
2
const isMP = platformInfo.startsWith('mp')
3
const isIos = platformInfo.startsWith('ios')
4

5 6
describe('dialog page', () => {
  if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
7 8 9 10 11
  	it('skip app-webview', () => {
  		expect(1).toBe(1)
  	})
  	return
  }
12 13
  if (isMP) {
  	it('skip mp', () => {
14 15 16 17
  		expect(1).toBe(1)
  	})
  	return
  }
18

19 20
	let page;
	let originLifeCycleNum;
21 22
  beforeAll(async () => {
    page = await program.reLaunch('/pages/API/choose-location/choose-location')
23 24 25
		await page.waitFor('view');

		originLifeCycleNum = await page.callMethod('getLifeCycleNum')
26 27 28

		await page.callMethod('chooseLocation')
		await page.waitFor(1000)
29 30 31
  });

  it('dialogPage should empty', async () => {
32 33
		const dialogPagesNum = await page.data('dialogPagesNum')
		expect(dialogPagesNum).toBe(0)
34 35 36 37 38 39
	})

	it('should trigger parent hide', async () => {
		const lifecycleNum = await page.callMethod('getLifeCycleNum')
		expect(lifecycleNum).toBe(originLifeCycleNum - 1)
	})
40 41 42 43 44 45 46 47 48 49
	if (isIos) {
		it('call chooseLocation in uts plugin', async () => {
			page = await program.reLaunch('/pages/API/choose-location/choose-location')
			await page.waitFor('view');
			await page.callMethod('chooseLocationByPlugin')
			await page.waitFor(1000)
			const lifecycleNum = await page.callMethod('getLifeCycleNum')
			expect(lifecycleNum).toBe(originLifeCycleNum - 1)
		})
	}
50 51 52 53

	afterAll(async () => {
		await page.callMethod('setLifeCycleNum', originLifeCycleNum)
  });
54
})