mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-20 10:18:24 -05:00
* Initial * Faster user page * Remove redundant function * Favorite badge sorting * Upgrade deps * Simplify entry.server * Bun tests initial * Update package.json npm -> bun * Update README * Type safe translations again * Don't load streams info for finalized tournaments * Translations as an object * More unit test work * Convert match.server.test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * Test & all done * Working cf * Bun GA try * No cache * spacing * spacing 2 * Add SQL logging * Remove NR * Hmm * Hmm 2 * Interesting * SKALOP_SYSTEM_MESSAGE_URL * . * . * ? * . * ? * Server.ts adjust * Downgrade Tldraw * E2E test fix * Fix lint
25 lines
779 B
TypeScript
25 lines
779 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { cutToNDecimalPlaces } from "./number";
|
|
|
|
describe("cutToNDecimalPlaces()", () => {
|
|
test("cutOff truncates decimal places correctly", () => {
|
|
const result = cutToNDecimalPlaces(3.9999, 2);
|
|
expect(result).toBe(3.99);
|
|
});
|
|
|
|
test("cutOff can change amount of decimals returned", () => {
|
|
const result = cutToNDecimalPlaces(3.12, 1);
|
|
expect(result).toBe(3.1);
|
|
});
|
|
|
|
test("cutOff preserves decimal values with the desired number of decimal places correctly", () => {
|
|
const result = cutToNDecimalPlaces(100, 2);
|
|
expect(result).toBe(100);
|
|
});
|
|
|
|
test("cutOff cuts off decimal places and removes trailing zeros correctly", () => {
|
|
const result = cutToNDecimalPlaces(3.0001, 2);
|
|
expect(result).toBe(3);
|
|
});
|
|
});
|