avatarCropper.spec.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {
  2. getDiffNE,
  3. getDiffNW,
  4. getDiffSE,
  5. getDiffSW,
  6. } from 'sentry/components/avatarCropper';
  7. describe('AvatarCropper', function () {
  8. describe('getDiffNW', function () {
  9. it(
  10. 'should return a negative diff when yDiff and xDiff ' +
  11. 'are positive (cropper is getting smaller)',
  12. function () {
  13. expect(getDiffNW(4, 5)).toEqual(-4.5);
  14. }
  15. );
  16. it(
  17. 'should return a positive diff when yDiff and xDiff ' +
  18. 'are negative (cropper is getting bigger)',
  19. function () {
  20. expect(getDiffNW(-4, -5)).toEqual(4.5);
  21. }
  22. );
  23. });
  24. describe('getDiffNE', function () {
  25. it(
  26. 'should return a positive diff when yDiff is negative and ' +
  27. 'xDiff is positive (cropper is getting bigger)',
  28. function () {
  29. expect(getDiffNE(-4, 5)).toEqual(4.5);
  30. }
  31. );
  32. it(
  33. 'should return a negative diff when yDiff is positive and ' +
  34. 'xDiff is negative (cropper is getting smaller)',
  35. function () {
  36. expect(getDiffNE(4, -5)).toEqual(-4.5);
  37. }
  38. );
  39. });
  40. describe('getDiffSE', function () {
  41. it(
  42. 'should return a positive diff when yDiff and ' +
  43. 'xDiff are positive (cropper is getting bigger)',
  44. function () {
  45. expect(getDiffSE(4, 5)).toEqual(4.5);
  46. }
  47. );
  48. it(
  49. 'should return a negative diff when yDiff and ' +
  50. 'xDiff are negative (cropper is getting smaller)',
  51. function () {
  52. expect(getDiffSE(-4, -5)).toEqual(-4.5);
  53. }
  54. );
  55. });
  56. describe('getDiffSW', function () {
  57. it(
  58. 'should return a positive diff when yDiff is positive and ' +
  59. 'xDiff is negative (cropper is getting bigger)',
  60. function () {
  61. expect(getDiffSW(4, -5)).toEqual(4.5);
  62. }
  63. );
  64. it(
  65. 'should return a negative diff when yDiff is negative and' +
  66. 'xDiff is positive (cropper is getting smaller)',
  67. function () {
  68. expect(getDiffSW(-4, 5)).toEqual(-4.5);
  69. }
  70. );
  71. });
  72. });