1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-25 19:29:41 +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,48 @@
import { assert } from "chai";
import attributeClassNames from "../../../src/common/entity/attribute_class_names";
describe("attributeClassNames", () => {
const attrs = ["mock_attr1", "mock_attr2"];
it("Skips null states", () => {
const stateObj: any = null;
assert.strictEqual(attributeClassNames(stateObj, attrs), "");
});
it("Matches no attrbutes", () => {
const stateObj: any = {
attributes: {
other_attr_1: 1,
other_attr_2: 2,
},
};
assert.strictEqual(attributeClassNames(stateObj, attrs), "");
});
it("Matches one attrbute", () => {
const stateObj: any = {
attributes: {
other_attr_1: 1,
other_attr_2: 2,
mock_attr1: 3,
},
};
assert.strictEqual(attributeClassNames(stateObj, attrs), "has-mock_attr1");
});
it("Matches two attrbutes", () => {
const stateObj: any = {
attributes: {
other_attr_1: 1,
other_attr_2: 2,
mock_attr1: 3,
mock_attr2: null,
},
};
assert.strictEqual(
attributeClassNames(stateObj, attrs),
"has-mock_attr1 has-mock_attr2"
);
});
});