Skip to content

Commit

Permalink
Fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
callemand committed Sep 27, 2023
1 parent 6012c3d commit 9a1626f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
27 changes: 26 additions & 1 deletion server/seeders/20190227043234-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ module.exports = {
triggers: '[]',
created_at: '2019-02-12 07:49:07.556 +00:00',
updated_at: '2019-02-12 07:49:07.556 +00:00',
tags: '[]',
},
{
id: '88428a7d-ea9d-46a6-b0d2-46bf82d37e53 \n',
id: '88428a7d-ea9d-46a6-b0d2-46bf82d37e53',
name: 'To Duplicate scene',
icon: 'fe fe-bell',
selector: 'to-duplicate-scene',
Expand All @@ -43,6 +44,30 @@ module.exports = {
]),
created_at: '2022-04-15 07:49:07.556 +00:00',
updated_at: '2022-04-15 07:49:07.556 +00:00',
tags: '[]',
},
{
id: '956794d8-a9cb-49bf-a677-57e820288b5a',
name: 'Scene with tags',
icon: 'fe fe-bell',
selector: 'scene-with-tag',
actions: JSON.stringify([
[
{
type: ACTIONS.LIGHT.TURN_ON,
},
],
]),
triggers: JSON.stringify([
{
type: EVENTS.TIME.CHANGED,
scheduler_type: 'every-day',
time: '12:00',
},
]),
created_at: '2022-04-15 07:49:07.556 +00:00',
updated_at: '2022-04-15 07:49:07.556 +00:00',
tags: '["tag 1", "tag 2"]',
},
],
{},
Expand Down
21 changes: 21 additions & 0 deletions server/test/lib/scene/scene.get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ describe('SceneManager.get', () => {
},
]);
});
it('should search scene by tag', async () => {
const sceneManager = new SceneManager({}, event);
const scenes = await sceneManager.get({
search: 'tag',
});
expect(scenes).to.be.instanceOf(Array);
expect(scenes).to.deep.equal([
{
id: '956794d8-a9cb-49bf-a677-57e820288b5a',
name: 'Scene with tags',
icon: 'fe fe-bell',
active: true,
description: null,
selector: 'scene-with-tag',
tags: ['tag 1', 'tag 2'],
last_executed: null,
updated_at: new Date('2022-04-15T07:49:07.556Z'),
},
]);
});

it('should return 0 result in search', async () => {
const sceneManager = new SceneManager({}, event);
const scenes = await sceneManager.get({
Expand Down

0 comments on commit 9a1626f

Please sign in to comment.