1
0
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:
Paulus Schoutsen
2018-11-06 10:09:09 +01:00
committed by GitHub
parent 856ef34964
commit cdb2093ea6
78 changed files with 524 additions and 364 deletions

View 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
);
});
});
});