keyboard.test.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const PAGE_PATH = '/pages/API/keyboard/keyboard'
  2. describe('keyboard', () => {
  3. let page;
  4. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  5. const isAndroid = platformInfo.startsWith('android')
  6. const isIOS = platformInfo.startsWith('ios')
  7. const isWeb = platformInfo.startsWith('web')
  8. if (isWeb) {
  9. it('web', async () => {
  10. expect(1).toBe(1)
  11. })
  12. return
  13. } else if(!isAndroid || !isIOS) {
  14. it('app', async () => {
  15. expect(1).toBe(1)
  16. })
  17. return
  18. }
  19. beforeAll(async () => {
  20. page = await program.reLaunch(PAGE_PATH)
  21. await page.waitFor(600);
  22. });
  23. it('Check hideKeyboard', async () => {
  24. // 显示键盘
  25. await page.setData({
  26. isFocus: true,
  27. })
  28. await page.waitFor(1000)
  29. let keyboardStatus = await page.data('keyboardStatus')
  30. expect(keyboardStatus).toBe('显示中')
  31. let keyboardHeight = await page.data('keyboardHeight')
  32. expect(keyboardHeight).toBeGreaterThan(0)
  33. await page.callMethod('hideKeyboard');
  34. await page.waitFor(1000)
  35. // 验证键盘是否隐藏
  36. keyboardStatus = await page.data('keyboardStatus')
  37. expect(keyboardStatus).toBe('已隐藏')
  38. keyboardHeight = await page.data('keyboardHeight')
  39. expect(keyboardHeight).toBe(0)
  40. });
  41. });