-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added styles template * Added templating for title * Added templating for name
- Loading branch information
1 parent
9fd76f3
commit 1ad9729
Showing
16 changed files
with
206 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
import { HomeAssistant } from 'custom-card-helpers'; | ||
import { createMock } from 'ts-auto-mock'; | ||
import { entityStyles } from '../../src/entity'; | ||
import { EntityStyles } from '../../src/types/room-card-types'; | ||
import { EntityStyles, HomeAssistantEntity, RoomCardAttributeTemplate } from '../../src/types/room-card-types'; | ||
|
||
describe('Testing entity file function computeEntity', () => { | ||
test('Passing entity_id should return entity name', () => { | ||
const stateObj = createMock<HomeAssistantEntity>(); | ||
const hass = createMock<HomeAssistant>(); | ||
|
||
test('Passing styles object should return style string', () => { | ||
const styles: EntityStyles = { | ||
color: 'red', | ||
height: '100' | ||
} | ||
expect(entityStyles(styles)).toBe('color: red;height: 100;'); | ||
expect(entityStyles(styles, stateObj, hass)).toBe('color: red;height: 100;'); | ||
}), | ||
test.each` | ||
state | expected | ||
${'off'} ${'color: red'} | ||
${'on'} ${'color: blue'} | ||
`('Passing RoomCardAttributeTemplate should return style string', ({ state, expected }) => { | ||
stateObj.state = state; | ||
const template: RoomCardAttributeTemplate = { | ||
template: "if (entity.state == 'off') return 'color: red'; else return 'color: blue';" | ||
} | ||
expect(entityStyles(template, stateObj, hass)).toBe(expected); | ||
}) | ||
}) |
Oops, something went wrong.