interceptor.test.js 1.0 KB
Newer Older
Q
qiang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
const PAGE_PATH = '/pages/API/interceptor/interceptor'

describe('interceptor', () => {
  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })

  it('no Interceptor', async () => {
    const newPage = await program.navigateTo('./page1')
    await newPage.waitFor('text')
    const num = (await newPage.data()).page
    await program.navigateBack()
    expect(num).toBe(1)
  })

  it('addInterceptor', async () => {
    await page.callMethod('addInterceptor')
    const newPage = await program.navigateTo('./page1')
    await newPage.waitFor('text')
    const num = (await newPage.data()).page
    await program.navigateBack()
    expect(num).toBe(2)
  })

  it('removeInterceptor', async () => {
    await page.callMethod('removeInterceptor')
    const newPage = await program.navigateTo('./page1')
    await newPage.waitFor('text')
    const num = (await newPage.data()).page
    await program.navigateBack()
    expect(num).toBe(1)
  })
})