react-native-navigation的迁移库

Orientations.test.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const Utils = require('./Utils');
  2. const elementByLabel = Utils.elementByLabel;
  3. describe('orientation', () => {
  4. beforeEach(async () => {
  5. await device.relaunchApp();
  6. });
  7. afterEach(async () => {
  8. await device.setOrientation('landscape');
  9. await device.setOrientation('portrait');
  10. });
  11. it('default allows all', async () => {
  12. await elementByLabel('Orientation').tap();
  13. await elementByLabel('default').tap();
  14. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  15. await device.setOrientation('landscape');
  16. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  17. await device.setOrientation('portrait');
  18. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  19. await elementByLabel('Dismiss').tap();
  20. });
  21. it('landscape and portrait array', async () => {
  22. await elementByLabel('Orientation').tap();
  23. await elementByLabel('landscape and portrait').tap();
  24. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  25. await device.setOrientation('landscape');
  26. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  27. await device.setOrientation('portrait');
  28. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  29. await elementByLabel('Dismiss').tap();
  30. });
  31. it('portrait only', async () => {
  32. await elementByLabel('Orientation').tap();
  33. await elementByLabel('portrait only').tap();
  34. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  35. await device.setOrientation('landscape');
  36. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  37. await device.setOrientation('portrait');
  38. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  39. await elementByLabel('Dismiss').tap();
  40. });
  41. it('landscape only', async () => {
  42. await elementByLabel('Orientation').tap();
  43. await elementByLabel('landscape only').tap();
  44. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  45. await device.setOrientation('landscape');
  46. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  47. await device.setOrientation('portrait');
  48. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  49. await elementByLabel('Dismiss').tap();
  50. });
  51. });