clipboard.test.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isAndroid = platformInfo.startsWith('android')
  3. const isIOS = platformInfo.startsWith('ios')
  4. const isWeb = platformInfo.startsWith('web')
  5. let page;
  6. describe('web-clipboard', () => {
  7. if (!(isAndroid || isIOS || isWeb)) {
  8. it('app', async () => {
  9. expect(1).toBe(1)
  10. })
  11. return
  12. }
  13. beforeAll(async () => {
  14. page = await program.reLaunch('/pages/API/clipboard/clipboard')
  15. await page.waitFor('view');
  16. await page.setData({
  17. data: '123456'
  18. })
  19. });
  20. it('setClipboardData', async () => {
  21. await page.callMethod('setClipboard')
  22. await page.waitFor(500);
  23. console.log(await page.data('setClipboardTest'), 'setClipboardTest')
  24. // bug:自动化测试时设置成功也进入了fail
  25. // expect(await page.data('setClipboardTest')).toBeTruthy()
  26. });
  27. it('getClipboardData', async () => {
  28. if (
  29. isIOS &&
  30. platformInfo.indexOf('15.5') != -1
  31. ) {
  32. // 该api在iOS 15.5版本的模拟器上有系统bug
  33. expect(1).toBe(1)
  34. }else{
  35. await page.callMethod('getClipboard')
  36. expect(await page.data('getDataTest')).toBe('123456')
  37. }
  38. });
  39. });