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:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user