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
    await page.waitFor(600);
    await page.callMethod('jest_downloadFile');
11
    await page.waitFor(2000);
雪洛's avatar
雪洛 已提交
12 13 14 15 16 17 18
    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
    expect(res).toBe(true);
  });

  let shouldTestCookie = false
26
  if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
雪洛's avatar
雪洛 已提交
27
    let version = process.env.uniTestPlatformInfo
28
    version = parseInt(version.split(" ")[1])
雪洛's avatar
雪洛 已提交
29
    shouldTestCookie = version > 9
30
  } else if (process.env.uniTestPlatformInfo.startsWith('web')) {
雪洛's avatar
雪洛 已提交
31 32 33
    // TODO 测试网址调整后放开此测试
    shouldTestCookie = false
  }
34 35 36
  if (!shouldTestCookie) {
    return
  }
雪洛's avatar
雪洛 已提交
37 38 39

  it('Check Set Cookie', async () => {
    res = await page.callMethod('jest_set_cookie')
40
    await page.waitFor(2000);
雪洛's avatar
雪洛 已提交
41 42 43 44 45
    res = await page.data('jest_result');
    expect(res).toBe(true)
  });
  it('Check Delete Cookie', async () => {
    res = await page.callMethod('jest_delete_cookie')
46
    await page.waitFor(2000);
雪洛's avatar
雪洛 已提交
47 48
    res = await page.data('jest_result');
    expect(res).toBe(true)
49
  });
50
});