Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
callemand committed Oct 2, 2023
1 parent 01f5961 commit e9bc087
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
20 changes: 20 additions & 0 deletions server/test/controllers/scene/scene.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,23 @@ describe('POST /api/v1/scene/:scene_selector/duplicate', () => {
});
});
});

describe('GET /api/v1/tag_scene', () => {
it('should get tags', async () => {
await authenticatedRequest
.get('/api/v1/tag_scene')
.send()
.expect('Content-Type', /json/)
.expect(200)
.then((res) => {
expect(res.body).to.deep.equal([
{
name: 'tag 1',
},
{
name: 'tag 2',
},
]);
});
});
});
2 changes: 1 addition & 1 deletion server/test/lib/scene/scene.get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('SceneManager.get', () => {
it('should search scene by tag', async () => {
const sceneManager = new SceneManager({}, event);
const scenes = await sceneManager.get({
search: 'tag',
search: 'tag 1',
});
expect(scenes).to.be.instanceOf(Array);
expect(scenes).to.deep.equal([
Expand Down
16 changes: 16 additions & 0 deletions server/test/lib/scene/scene.getTag.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { expect } = require('chai');
const EventEmitter = require('events');
const SceneManager = require('../../../lib/scene');

const event = new EventEmitter();

describe('SceneManager.getTag', () => {
it('should get tags', async () => {
const sceneManager = new SceneManager({}, event);
const tags = await sceneManager.getTag();
expect(tags).to.be.instanceOf(Array);
tags.forEach((tag) => {
expect(tag).to.have.property('name');
});
});
});
12 changes: 12 additions & 0 deletions server/test/lib/scene/scene.update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ describe('scene.update', () => {
assertSinon.calledOnce(brain.addNamedEntity);
assertSinon.calledOnce(brain.removeNamedEntity);
});
it('should update a scene with tags', async () => {
const scene = await sceneManager.update('test-scene', {
name: 'Name updated',
tags: [{ name: 'tag 1' }],
});
expect(scene).to.have.property('selector', 'test-scene');
expect(scene).to.have.property('name', 'Name updated');
expect(scene).to.have.property('tags');
expect(scene.tags).deep.eq([{ name: 'tag 1' }]);
assertSinon.calledOnce(brain.addNamedEntity);
assertSinon.calledOnce(brain.removeNamedEntity);
});
it('should return not found', async () => {
const promise = sceneManager.update('not-found-scene', {
name: 'Updated scene',
Expand Down

0 comments on commit e9bc087

Please sign in to comment.