setup-mock.ts 876 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // @ts-nocheck
  2. import defineGetter from '@element-plus/test-utils/define-getter'
  3. export default () => {
  4. const clientWidth = defineGetter(
  5. HTMLElement.prototype,
  6. 'clientWidth',
  7. function () {
  8. return Number.parseInt(this.style.width, 10) || 0
  9. },
  10. 0
  11. )
  12. const clientHeight = defineGetter(
  13. HTMLElement.prototype,
  14. 'clientHeight',
  15. function () {
  16. return Number.parseInt(this.style.height, 10) || 0
  17. },
  18. 0
  19. )
  20. const scrollHeight = defineGetter(
  21. HTMLElement.prototype,
  22. 'scrollHeight',
  23. () => {
  24. return Number.MAX_SAFE_INTEGER
  25. },
  26. 0
  27. )
  28. const scrollWidth = defineGetter(
  29. HTMLElement.prototype,
  30. 'scrollWidth',
  31. () => {
  32. return Number.MAX_SAFE_INTEGER
  33. },
  34. 0
  35. )
  36. // clean up function
  37. return () => {
  38. clientWidth()
  39. clientHeight()
  40. scrollHeight()
  41. scrollWidth()
  42. }
  43. }