upload-file.test.js 1.7 KB
Newer Older
1 2 3
const PAGE_PATH = '/pages/API/upload-file/upload-file'

describe('ExtApi-UploadFile', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7 8 9
  if(process.env.uniTestPlatformInfo.startsWith('web')){
    // TODO: web 端暂不支持测试
    it('web', async () => {
      expect(1).toBe(1)
    })
  }
10

雪洛's avatar
雪洛 已提交
11
  let page;
12 13 14
  let res;
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
雪洛's avatar
雪洛 已提交
15 16 17 18 19 20 21 22 23 24
    await page.waitFor(600);
    await page.callMethod('jest_uploadFile');
    await page.waitFor(1000);
    res = await page.data('jest_result');
  });

  beforeEach(async () => {
    await page.setData({
      jest_result: false
    })
25 26 27
  });

  it('Check ', async () => {
雪洛's avatar
雪洛 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    expect(res).toBe(true);
  });

  it('Check Set Cookie', async () => {
    if (process.env.uniTestPlatformInfo.startsWith('android')) {
      let version = process.env.uniTestPlatformInfo
      version = version.split(" ")[1]
      if(version > 9){
        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 (process.env.uniTestPlatformInfo.startsWith('android')) {
      let version = process.env.uniTestPlatformInfo
      version = version.split(" ")[1]
      if(version > 9){
        res = await page.callMethod('jest_delete_cookie')
        await page.waitFor(1000);
        res = await page.data('jest_result');
        expect(res).toBe(true)
      }
    }
  });
  it('Check files upload', async () => {
    res = await page.callMethod('jest_files_upload')
    await page.waitFor(1000);
    res = await page.data('jest_result');
    expect(res).toBe(true)
60
  });
雪洛's avatar
雪洛 已提交
61
});