mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-19 18:28:42 +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:
49
test/common/entity/get_view_entities.spec.ts
Normal file
49
test/common/entity/get_view_entities.spec.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { assert } from "chai";
|
||||
|
||||
import { getViewEntities } from "../../../src/common/entity/get_view_entities";
|
||||
|
||||
import {
|
||||
createEntities,
|
||||
createGroup,
|
||||
createView,
|
||||
entityMap,
|
||||
} from "./test_util";
|
||||
|
||||
describe("getViewEntities", () => {
|
||||
it("should work", () => {
|
||||
const entities = createEntities(10);
|
||||
const entityIds = Object.keys(entities);
|
||||
|
||||
const group1 = createGroup({
|
||||
attributes: { entity_id: entityIds.splice(0, 2) },
|
||||
});
|
||||
entities[group1.entity_id] = group1;
|
||||
|
||||
const group2 = createGroup({
|
||||
attributes: { entity_id: entityIds.splice(0, 3) },
|
||||
});
|
||||
entities[group2.entity_id] = group2;
|
||||
|
||||
const view = createView({
|
||||
attributes: {
|
||||
entity_id: [group1.entity_id, group2.entity_id].concat(
|
||||
entityIds.splice(0, 2)
|
||||
),
|
||||
},
|
||||
});
|
||||
|
||||
const expectedEntities = entityMap(
|
||||
view.attributes.entity_id.map((ent) => entities[ent])
|
||||
);
|
||||
Object.assign(
|
||||
expectedEntities,
|
||||
entityMap(group1.attributes.entity_id.map((ent) => entities[ent]))
|
||||
);
|
||||
Object.assign(
|
||||
expectedEntities,
|
||||
entityMap(group2.attributes.entity_id.map((ent) => entities[ent]))
|
||||
);
|
||||
|
||||
assert.deepEqual(expectedEntities, getViewEntities(entities, view));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user