mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-19 00:22:14 +03:00
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
|
import { describe, expect, it } from "vitest";
|
||
|
|
||
|
import { formatBrainSizeUsage } from "../UserStatistics";
|
||
|
|
||
|
describe("UserStatistics", () => {
|
||
|
describe("formatBrainSize", () => {
|
||
|
it("should return string", () => {
|
||
|
const result = formatBrainSizeUsage(1, 5);
|
||
|
|
||
|
expect(typeof result).toBe("string");
|
||
|
});
|
||
|
|
||
|
it.each([
|
||
|
{ input: { currentBrainSize: 1, maxBrainSize: 2 }, expected: true },
|
||
|
{ input: { currentBrainSize: 0, maxBrainSize: 0 }, expected: true },
|
||
|
{ input: { currentBrainSize: 1000, maxBrainSize: 5000 }, expected: true },
|
||
|
{
|
||
|
input: { currentBrainSize: 1337, maxBrainSize: 2674 },
|
||
|
expected: true,
|
||
|
},
|
||
|
{ input: { currentBrainSize: 5000, maxBrainSize: 1000 }, expected: true },
|
||
|
])(
|
||
|
"formatBrainSizeUsage($input.currentBrainSize, $input.maxBrainSize) -> $expected",
|
||
|
({ input, expected }) => {
|
||
|
const formatRegex = /^(.+?)\s+\/\s+(.+?)$/gm;
|
||
|
const result = formatBrainSizeUsage(
|
||
|
input.currentBrainSize,
|
||
|
input.maxBrainSize
|
||
|
);
|
||
|
const match = formatRegex.test(result);
|
||
|
|
||
|
expect(typeof result).toBe("string");
|
||
|
expect(match).toBe(expected);
|
||
|
}
|
||
|
);
|
||
|
});
|
||
|
});
|