sticky-header.test.js 1.5 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')

shutao-dc's avatar
shutao-dc 已提交
4
describe('component-native-sticky-header', () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
5 6 7 8 9 10 11
  if (isMP) {
  	it('skip mp', () => {
  		expect(1).toBe(1)
  	})
  	return
  }

雪洛's avatar
雪洛 已提交
12
  let page
13 14 15 16 17 18 19 20
  async function getWindowInfo() {
    const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info')
    await windowInfoPage.waitFor(600);
    return await windowInfoPage.callMethod('jest_getWindowInfo')
  }
  const screenshotParams = { fullPage: true }
  let windowInfo
  
雪洛's avatar
雪洛 已提交
21
  beforeAll(async () => {
22 23 24 25 26 27 28 29 30 31 32 33
    if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
      screenshotParams.fullPage = false
      windowInfo = await getWindowInfo()
      let offsetY = '0'
      if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('android')) {
        offsetY = `${windowInfo.statusBarHeight + 44}`
      }
      if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
        offsetY = `${windowInfo.safeAreaInsets.top + 44}`
      }
      screenshotParams.offsetY = offsetY
    }
雪洛's avatar
雪洛 已提交
34 35 36
    page = await program.reLaunch('/pages/component/sticky-header/sticky-header')
    await page.waitFor('sticky-header')
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
37

雪洛's avatar
雪洛 已提交
38 39 40
  //检测吸顶效果
  it('check_sticky_header', async () => {
    await page.callMethod('confirm_scroll_top_input', 600)
41
    const image = await program.screenshot(screenshotParams);
42
    expect(image).toSaveImageSnapshot();
雪洛's avatar
雪洛 已提交
43
  })
44
})