1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Use explicit default name in entity name picker and lovelace cards (#30189)

This commit is contained in:
Paul Bottein
2026-03-18 09:02:04 +01:00
committed by GitHub
parent c2a2b382e9
commit b1921d1b66
3 changed files with 25 additions and 17 deletions

View File

@@ -22,7 +22,7 @@ describe("computeLovelaceEntityName", () => {
expect(mockFormatEntityName).not.toHaveBeenCalled();
});
it("return state name when nameConfig is empty string", () => {
it("returns empty string when nameConfig is empty string", () => {
const mockFormatEntityName = vi.fn();
const hass = createMockHass(mockFormatEntityName);
const stateObj = mockStateObj({
@@ -32,11 +32,11 @@ describe("computeLovelaceEntityName", () => {
const result = computeLovelaceEntityName(hass, stateObj, "");
expect(result).toBe("Kitchen Light");
expect(result).toBe("");
expect(mockFormatEntityName).not.toHaveBeenCalled();
});
it("return state name when nameConfig is undefined", () => {
it("calls formatEntityName with DEFAULT_ENTITY_NAME when nameConfig is undefined", () => {
const mockFormatEntityName = vi.fn(() => "Formatted Name");
const hass = createMockHass(mockFormatEntityName);
const stateObj = mockStateObj({
@@ -46,8 +46,12 @@ describe("computeLovelaceEntityName", () => {
const result = computeLovelaceEntityName(hass, stateObj, undefined);
expect(result).toBe("Kitchen Light");
expect(mockFormatEntityName).not.toHaveBeenCalled();
expect(result).toBe("Formatted Name");
expect(mockFormatEntityName).toHaveBeenCalledTimes(1);
expect(mockFormatEntityName).toHaveBeenCalledWith(stateObj, [
{ type: "device" },
{ type: "entity" },
]);
});
it("calls formatEntityName with EntityNameItem config", () => {