mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 05:17:20 +00:00

* Add rspack * Remove TransformAsyncModulesPlugin from rspack * Migrate all webpack usage to rspack * Migrate tests to vitest * Fix test suites * Remove chai dependency * Fix compute_state_display tests * Fix resolveTimeZone * Reduces test pipeline * Revert test ci * optimize chunk filtering * Migrate landing-page to rspack * Update rspack dependencies * Add rsdoctor * Fix prod build bundle size * Use rsdoctor for demo stats * Remove unused webpack configs * Update build-scripts/rspack.cjs Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com> * Fix eslint * Update rspack * Remove unused code --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
26 lines
911 B
TypeScript
26 lines
911 B
TypeScript
import { assert, describe, it } from "vitest";
|
|
import {
|
|
getValueInPercentage,
|
|
normalize,
|
|
roundWithOneDecimal,
|
|
} from "../../src/util/calculate";
|
|
|
|
describe("Calculate tests", () => {
|
|
it("Test getValueInPercentage", () => {
|
|
assert.strictEqual(getValueInPercentage(10, 0, 100), 10);
|
|
assert.strictEqual(getValueInPercentage(120, 0, 100), 120);
|
|
assert.strictEqual(getValueInPercentage(-10, 0, 100), -10);
|
|
assert.strictEqual(getValueInPercentage(10.33333, 0, 100), 10.33333);
|
|
});
|
|
it("Test normalize", () => {
|
|
assert.strictEqual(normalize(10, 0, 100), 10);
|
|
assert.strictEqual(normalize(1, 10, 100), 10);
|
|
assert.strictEqual(normalize(100, 0, 10), 10);
|
|
});
|
|
it("Test roundWithOneDecimal", () => {
|
|
assert.strictEqual(roundWithOneDecimal(10), 10);
|
|
assert.strictEqual(roundWithOneDecimal(10.3), 10.3);
|
|
assert.strictEqual(roundWithOneDecimal(10.3333), 10.3);
|
|
});
|
|
});
|