Skip to content

Commit

Permalink
Fix again
Browse files Browse the repository at this point in the history
  • Loading branch information
callemand committed Oct 2, 2023
1 parent 1006468 commit 01f5961
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions server/lib/scene/scene.update.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ async function update(selector, scene) {
},
});

await Promise.each(scene.tags, (tag) => {
db.TagScene.create({
scene_id: existingScene.id,
name: tag.name,
if (scene.tags) {
await Promise.each(scene.tags, (tag) => {
db.TagScene.create({

Check warning on line 45 in server/lib/scene/scene.update.js

View check run for this annotation

Codecov / codecov/patch

server/lib/scene/scene.update.js#L44-L45

Added lines #L44 - L45 were not covered by tests
scene_id: existingScene.id,
name: tag.name,
});
});
});
}

const plainScene = existingScene.get({ plain: true });
// Remove scene in brain if already present
Expand Down
4 changes: 2 additions & 2 deletions server/test/lib/scene/scene.init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('scene.init', () => {

it('should init scene all scheduled task', async () => {
await sceneManager.init();
assert.callCount(scheduler.scheduleJob, 3);
assert.callCount(scheduler.scheduleJob, 4);
assert.calledWithMatch(
scheduler.scheduleJob,
{ tz: 'Europe/Paris', hour: 0, minute: 0, second: 0 },
Expand All @@ -55,7 +55,7 @@ describe('scene.init', () => {
assert.calledWithMatch(scheduler.scheduleJob, '* * * * *', sinon.match.func);

// Check that scheduled method send an event
scheduler.scheduleJob.getCall(2).callback();
scheduler.scheduleJob.getCall(3).callback();
assert.calledOnceWithExactly(event.emit, 'calendar.check-if-event-is-coming');
});
});

0 comments on commit 01f5961

Please sign in to comment.