mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +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>
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { assert, describe, it } from "vitest";
|
|
|
|
import { splitByGroups } from "../../../src/common/entity/split_by_groups";
|
|
|
|
import { createEntities, createGroup, entityMap } from "./test_util";
|
|
|
|
describe("splitByGroups", () => {
|
|
it("splitByGroups splits correctly", () => {
|
|
const entities = createEntities(7);
|
|
const entityIds = Object.keys(entities);
|
|
|
|
const group1 = createGroup({
|
|
attributes: {
|
|
entity_id: entityIds.splice(0, 2),
|
|
order: 6,
|
|
},
|
|
});
|
|
entities[group1.entity_id] = group1;
|
|
|
|
const group2 = createGroup({
|
|
attributes: {
|
|
entity_id: entityIds.splice(0, 3),
|
|
order: 4,
|
|
},
|
|
});
|
|
entities[group2.entity_id] = group2;
|
|
|
|
const result = splitByGroups(entities);
|
|
result.groups.sort(
|
|
(gr1, gr2) => gr1.attributes.order - gr2.attributes.order
|
|
);
|
|
|
|
const expected = {
|
|
groups: [group2, group1],
|
|
ungrouped: entityMap(entityIds.map((ent) => entities[ent])),
|
|
};
|
|
|
|
assert.deepEqual(expected, result);
|
|
});
|
|
});
|