input entities
This commit is contained in:
1 parent
878035e748
commit
996626f9af
27 files changed
+596
-92
No files matched your search
@@ -1,5 +1,5 @@
|
||||
|
||||
import { convertTimeToString, getDescriptionFromAutomationNode } from "./formatting";
|
||||
import { convertTimeToString, getDescriptionFromAutomationNode, prettyName } from "./formatting";
|
||||
|
||||
test('converting time to a string', () => {
|
||||
expect(convertTimeToString({ hours: 1 })).toEqual('01:00:00:00')
|
||||
@@ -146,3 +146,10 @@ test('get State condition description', () => {
|
||||
state: "on"
|
||||
})).toEqual("switch.kitchen_light is 'on'")
|
||||
})
|
||||
|
||||
|
||||
test('pretty naming', () => {
|
||||
expect(prettyName('sensor')).toEqual("Sensor")
|
||||
expect(prettyName('sensor.phone')).toEqual("Sensor Phone")
|
||||
expect(prettyName('device_tracker')).toEqual("Device Tracker")
|
||||
})
|
||||
@@ -121,3 +121,8 @@ export const prettyEntityId = (entityId: string | string[]) => {
|
||||
return "..."
|
||||
}
|
||||
}
|
||||
|
||||
export const prettyName = (n: string) => {
|
||||
const clean = n.replaceAll(/[\.-_]/g, ' ');
|
||||
return clean.split(' ').map(x => x.slice(0, 1).toUpperCase() + x.slice(1)).join(' ')
|
||||
}
|
||||
Reference in new issue
Block a user