mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-19 08:20:41 +01:00
Rspack (#22807)
* 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>
This commit is contained in:
54
test/common/entity/feature_class_names.test.ts
Normal file
54
test/common/entity/feature_class_names.test.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { assert, describe, it } from "vitest";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
import { featureClassNames } from "../../../src/common/entity/feature_class_names";
|
||||
|
||||
describe("featureClassNames", () => {
|
||||
const classNames = {
|
||||
1: "has-feature_a",
|
||||
2: "has-feature_b",
|
||||
4: "has-feature_c",
|
||||
8: "has-feature_d",
|
||||
};
|
||||
|
||||
it("Skips null states", () => {
|
||||
const stateObj = null;
|
||||
assert.strictEqual(featureClassNames(stateObj!, classNames), "");
|
||||
});
|
||||
|
||||
it("Matches no features", () => {
|
||||
// eslint-disable-next-line
|
||||
const stateObj = <HassEntity>{
|
||||
attributes: {
|
||||
supported_features: 64,
|
||||
},
|
||||
};
|
||||
assert.strictEqual(featureClassNames(stateObj, classNames), "");
|
||||
});
|
||||
|
||||
it("Matches one feature", () => {
|
||||
// eslint-disable-next-line
|
||||
const stateObj = <HassEntity>{
|
||||
attributes: {
|
||||
supported_features: 72,
|
||||
},
|
||||
};
|
||||
assert.strictEqual(
|
||||
featureClassNames(stateObj, classNames),
|
||||
"has-feature_d"
|
||||
);
|
||||
});
|
||||
|
||||
it("Matches two features", () => {
|
||||
// eslint-disable-next-line
|
||||
const stateObj = <HassEntity>{
|
||||
attributes: {
|
||||
supported_features: 73,
|
||||
},
|
||||
};
|
||||
assert.strictEqual(
|
||||
featureClassNames(stateObj, classNames),
|
||||
"has-feature_a has-feature_d"
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user