slider.test.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const PAGE_PATH = '/pages/component/slider/slider'
  2. describe('slider', () => {
  3. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  4. const isAndroid = platformInfo.startsWith('android')
  5. const isIOS = platformInfo.startsWith('ios')
  6. const isMP = platformInfo.startsWith('mp')
  7. const isWeb = platformInfo.startsWith('web')
  8. let page
  9. beforeAll(async () => {
  10. page = await program.reLaunch(PAGE_PATH)
  11. await page.waitFor(500)
  12. })
  13. // it('change', async () => {})
  14. it('value', async () => {
  15. const slider = await page.$('#slider-custom-color-and-size')
  16. const sliderValue = 80
  17. await page.setData({
  18. sliderValue: sliderValue,
  19. })
  20. await page.waitFor(100)
  21. // TODO
  22. const newValue = await slider.property('value')
  23. expect(newValue.toString()).toBe(sliderValue + '')
  24. })
  25. if(!isMP) {
  26. it('color', async () => {
  27. const slider = await page.$('#slider-custom-color-and-size')
  28. expect(await slider.attribute('backgroundColor')).toBe('#000000')
  29. expect(await slider.attribute('activeColor')).toBe('#FFCC33')
  30. expect(await slider.attribute('blockColor')).toBe('#8A6DE9')
  31. expect(await slider.attribute('activeBackgroundColor')).toBe('#FFCC33')
  32. expect(await slider.attribute('foreColor')).toBe('#8A6DE9')
  33. const backgroundColor = '#008000'
  34. const activeColor = '#00FF00'
  35. const blockColor = '#0000A0'
  36. await page.setData({
  37. sliderBackgroundColor: backgroundColor,
  38. sliderActiveColor: activeColor,
  39. sliderBlockColor: blockColor,
  40. })
  41. await page.waitFor(100)
  42. expect(await slider.attribute('backgroundColor')).toBe(backgroundColor)
  43. expect(await slider.attribute('activeColor')).toBe(activeColor)
  44. expect(await slider.attribute('activeBackgroundColor')).toBe(activeColor)
  45. expect(await slider.attribute('blockColor')).toBe(blockColor)
  46. expect(await slider.attribute('foreColor')).toBe(blockColor)
  47. })
  48. }
  49. if(isMP) {
  50. it('block-size', async () => {
  51. const slider = await page.$('#slider-custom-color-and-size')
  52. expect(await slider.property('blockSize')).toBe(20)
  53. const blockSize = 18
  54. await page.setData({
  55. sliderBlockSize: blockSize,
  56. })
  57. await page.waitFor(100)
  58. expect(await slider.property('blockSize')).toBe(blockSize)
  59. })
  60. } else {
  61. it('block-size', async () => {
  62. const slider = await page.$('#slider-custom-color-and-size')
  63. expect(await slider.attribute('blockSize')).toBe(20 + '')
  64. const blockSize = 18
  65. await page.setData({
  66. sliderBlockSize: blockSize,
  67. })
  68. await page.waitFor(100)
  69. expect(await slider.attribute('blockSize')).toBe(blockSize + '')
  70. })
  71. }
  72. })