mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-24 20:55:49 +00:00
Rspack (#22807)
* 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>
This commit is contained in:
52
test/common/entity/timer_time_remaining.test.ts
Normal file
52
test/common/entity/timer_time_remaining.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { assert, describe, it, beforeEach, afterEach } from "vitest";
|
||||
import { useFakeTimers } from "sinon";
|
||||
|
||||
import { timerTimeRemaining } from "../../../src/data/timer";
|
||||
|
||||
describe("timerTimeRemaining", () => {
|
||||
it("works with idle timers", () => {
|
||||
assert.strictEqual(
|
||||
timerTimeRemaining({
|
||||
state: "idle",
|
||||
attributes: {
|
||||
remaining: "0:01:05",
|
||||
},
|
||||
} as any),
|
||||
65
|
||||
);
|
||||
});
|
||||
|
||||
it("works with paused timers", () => {
|
||||
assert.strictEqual(
|
||||
timerTimeRemaining({
|
||||
state: "paused",
|
||||
attributes: {
|
||||
remaining: "0:01:05",
|
||||
},
|
||||
} as any),
|
||||
65
|
||||
);
|
||||
});
|
||||
|
||||
describe("active timers", () => {
|
||||
let clock;
|
||||
beforeEach(() => {
|
||||
clock = useFakeTimers(new Date("2018-01-17T16:15:30Z"));
|
||||
});
|
||||
afterEach(() => {
|
||||
clock.restore();
|
||||
});
|
||||
it("works", () => {
|
||||
assert.strictEqual(
|
||||
timerTimeRemaining({
|
||||
state: "active",
|
||||
attributes: {
|
||||
remaining: "0:01:05",
|
||||
finishes_at: "2018-01-17T16:16:17+00:00",
|
||||
},
|
||||
} as any),
|
||||
47
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user