figspec

Unofficial static Figma frame/file viewer available as HTML CustomElement

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
import { describe, expect, it } from "vitest";

import { getLinearGradientAngle, radToDeg } from "./gradient";

describe("radToDeg", () => {
  it("πrad = 180deg", () => {
    expect(radToDeg(Math.PI)).toBeCloseTo(180);
  });

  it("π/2rad = 90deg", () => {
    expect(radToDeg(Math.PI / 2)).toBeCloseTo(90);
  });
});

describe("getLinearGradientAngle", () => {
  it("(0.5,0) to (0.5,1) = 270deg", () => {
    expect(getLinearGradientAngle({ x: 0.5, y: 0 }, { x: 0.5, y: 1 })).toBe(
      270,
    );
  });
});