mirror of
https://github.com/home-assistant/frontend.git
synced 2026-05-02 06:33:25 +01:00
Ts all the tests (#1998)
* Convert tests to TypeScript * Add types for tests * Rename files to TS * Fix up test imports * Fix TSC errors * Liiiint * Add types to util method signatures * Some more types
This commit is contained in:
52
test-mocha/common/entity/timer_time_remaining_test.ts
Normal file
52
test-mocha/common/entity/timer_time_remaining_test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { assert } from "chai";
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import timerTimeRemaining from "../../../src/common/entity/timer_time_remaining";
|
||||
|
||||
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 = sinon.useFakeTimers(new Date("2018-01-17T16:15:30Z"));
|
||||
});
|
||||
afterEach(() => {
|
||||
clock.restore();
|
||||
});
|
||||
it("works", () => {
|
||||
assert.strictEqual(
|
||||
timerTimeRemaining({
|
||||
state: "active",
|
||||
attributes: {
|
||||
remaining: "0:01:05",
|
||||
},
|
||||
last_changed: "2018-01-17T16:15:12Z",
|
||||
} as any),
|
||||
47
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user