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
import { describe, expect, it } from "vitest";

import { roundTo } from "./math";

describe("roundTo", () => {
  it("Should round to int without `at` parameter", () => {
    expect(roundTo(1.23456789)).toBe(1);
    expect(roundTo(9.87654321)).toBe(10);
  });

  it("Should round to specified decimal", () => {
    expect(roundTo(1.23456789, 2)).toBe(1.23);
    expect(roundTo(9.87654321, 2)).toBe(9.88);
  });
});