download-file.test.js 1.4 KB
Newer Older
1 2 3 4
const PAGE_PATH = '/pages/API/download-file/download-file'

describe('ExtApi-DownloadFile', () => {

雪洛's avatar
雪洛 已提交
5
  let page;
6 7 8
  let res;
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
雪洛's avatar
雪洛 已提交
9 10 11 12 13 14 15 16 17 18
    await page.waitFor(600);
    await page.callMethod('jest_downloadFile');
    await page.waitFor(1000);
    res = await page.data('jest_result');
  });

  beforeEach(async () => {
    await page.setData({
      jest_result: false
    })
19 20 21
  });

  it('Check ', async () => {
雪洛's avatar
雪洛 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    expect(res).toBe(true);
  });

  let shouldTestCookie = false
  if (process.env.uniTestPlatformInfo.startsWith('android')) {
    let version = process.env.uniTestPlatformInfo
    version = version.split(" ")[1]
    shouldTestCookie = version > 9
  } else if (process.env.uniTestPlatformInfo.startsWith('web')) {
    // TODO 测试网址调整后放开此测试
    shouldTestCookie = false
  }

  it('Check Set Cookie', async () => {
    if (!shouldTestCookie) {
      return
    }
    res = await page.callMethod('jest_set_cookie')
    await page.waitFor(1000);
    res = await page.data('jest_result');
    expect(res).toBe(true)
  });
  it('Check Delete Cookie', async () => {
    if (!shouldTestCookie) {
      return
    }
    res = await page.callMethod('jest_delete_cookie')
    await page.waitFor(1000);
    res = await page.data('jest_result');
    expect(res).toBe(true)
52 53
  });
});