1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-24 12:49:19 +00:00

Use browser default time and number formatting with polyfills if needed (#9481)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Bram Kragten
2021-09-30 01:34:52 +02:00
committed by GitHub
parent d7f00df391
commit 1bccbd4173
91 changed files with 952 additions and 974 deletions

View File

@@ -0,0 +1,47 @@
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"
);
});
});