mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-16 15:16:38 +00:00

* 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>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { assert, describe, it } from "vitest";
|
|
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"
|
|
);
|
|
});
|
|
});
|