WXS.test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isMP = platformInfo.startsWith('mp')
  3. describe('test WXS', () => {
  4. let page,movable;
  5. if (!isMP) {
  6. it('not support', () => {
  7. expect(1).toBe(1)
  8. })
  9. return
  10. }
  11. beforeAll(async () => {
  12. page = await program.reLaunch('/pages/template/WXS/WXS')
  13. await page.waitFor(3000);
  14. movable = await page.$('.movable');
  15. });
  16. it('setColor', async () => {
  17. const setColor = await page.$('.setColor')
  18. await setColor.tap()
  19. expect(await setColor.style('color')).toEqual('rgb(255, 0, 0)');
  20. });
  21. it('check title', async () => {
  22. const titleText = await movable.text();
  23. expect(titleText).toEqual('Hello');
  24. });
  25. it('touchstart-touchmove', async () => {
  26. const offsetBefore = await movable.offset()
  27. await movable.touchstart({
  28. touches: [{
  29. identifier: 0,
  30. pageX: 92,
  31. pageY: 93,
  32. clientX: 92,
  33. clientY: 93
  34. }],
  35. changedTouches: [{
  36. identifier: 0,
  37. pageX: 92,
  38. pageY: 93,
  39. clientX: 92,
  40. clientY: 93
  41. }]
  42. })
  43. await page.waitFor(100)
  44. await movable.touchmove({
  45. touches: [{
  46. identifier: 0,
  47. pageX: 207,
  48. pageY: 385,
  49. clientX: 207,
  50. clientY: 385
  51. }],
  52. changedTouches: [{
  53. identifier: 0,
  54. pageX: 207,
  55. pageY: 385,
  56. clientX: 207,
  57. clientY: 385
  58. }]
  59. })
  60. await page.waitFor(100)
  61. const offsetAfter = await movable.offset()
  62. expect(offsetAfter.left).toBeGreaterThan(offsetBefore.left);
  63. expect(offsetAfter.top).toBeGreaterThan(offsetBefore.top);
  64. });
  65. });