sticky-header.test.js 1.3 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1
describe('component-native-sticky-header', () => {
雪洛's avatar
雪洛 已提交
2
  let page
3 4 5 6 7 8 9 10
  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
雪洛 已提交
11
  beforeAll(async () => {
12 13 14 15 16 17 18 19 20 21 22 23
    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
雪洛 已提交
24 25 26
    page = await program.reLaunch('/pages/component/sticky-header/sticky-header')
    await page.waitFor('sticky-header')
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
27

雪洛's avatar
雪洛 已提交
28 29 30
  //检测吸顶效果
  it('check_sticky_header', async () => {
    await page.callMethod('confirm_scroll_top_input', 600)
31
    const image = await program.screenshot(screenshotParams);
32
    expect(image).toSaveImageSnapshot();
雪洛's avatar
雪洛 已提交
33
  })
34
})