mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-30 21:52:10 +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:
40
test/common/entity/split_by_groups.test.ts
Normal file
40
test/common/entity/split_by_groups.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user