describe('GET /api/v1/gateway/instance/key', () => { it('should get instance keys', async () => { await authenticatedRequest .get('/api/v1/gateway/instance/key') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('rsa_fingerprint'); expect(res.body).to.have.property('ecdsa_fingerprint'); }); }); });
describe('dashboard.getBySelector', () => { const dashboard = new Dashboard(); it('should return dashboard', async () => { const testDashboard = await dashboard.getBySelector('test-dashboard'); expect(testDashboard).to.have.property('name', 'Test dashboard'); expect(testDashboard).to.have.property('selector', 'test-dashboard'); }); it('should return not found', async () => { const promise = dashboard.getBySelector('not-found-dashboard'); return assert.isRejected(promise, 'Dashboard not found'); }); });
describe('PhilipsHueService', () => { it('should get scenes', async () => { const philipsHueService = PhilipsHueService(gladys, 'a810b8db-6d04-4697-bed3-c4b72c996279'); await philipsHueService.device.init(); const scenes = await philipsHueService.device.getScenes(); scenes.forEach((scene) => { expect(scene).to.have.property('id'); expect(scene).to.have.property('name'); expect(scene).to.have.property('bridge_serial_number'); }); }); });
describe('#Shell', () => { it('should return a Shell instance with correct default options', () => { const shell = new Shell(); shell.should.be.instanceof(Object); shell.should.have.property('log'); }); });
describe('SceneManager', () => { it('should get a scene by selector', async () => { const sceneManager = new SceneManager({}, event); const scene = await sceneManager.getBySelector('test-scene'); expect(scene).to.have.property('selector', 'test-scene'); }); it('should return not found', async () => { const sceneManager = new SceneManager({}, event); const promise = sceneManager.getBySelector('not-found-scene'); return assert.isRejected(promise); }); });
describe('session.createApiKey', () => { it('should create an api key', async () => { const session = new Session('secret'); const res = await session.createApiKey('0cd30aef-9c4e-4a23-88e3-3547971296e5', ['dashboard:read']); expect(res).to.have.property('api_key'); expect(res).to.have.property('session_id'); expect(res.api_key).to.have.lengthOf(32); }); });
describe('DELETE /api/v1/calendar/event/:calendar_event_selector', () => { it('should delete a calendar event', async () => { await authenticatedRequest .delete('/api/v1/calendar/event/test-calendar-event') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('success', true); }); }); });
describe('POST /api/v1/house/:user_selector/user/:user_selector/seen', () => { it('should mark the user has seen in this house', async () => { await authenticatedRequest .post('/api/v1/house/test-house/user/john/seen') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('current_house_id', 'a741dfa6-24de-4b46-afc7-370772f068d5'); }); }); });
describe('POST /api/v1/session/api_key', () => { it('should create api key', async () => { await authenticatedRequest .post('/api/v1/session/api_key') .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.have.property('api_key'); expect(res.body).to.have.property('session_id'); }); }); });
describe('GET /api/v1/service/:service_name', () => { it('should get a service by name', async () => { await authenticatedRequest .get('/api/v1/service/test-service') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'test-service'); }); }); });
describe('GET /api/v1/system/disk', () => { it('should return disk usage', async () => { await authenticatedRequest .get('/api/v1/system/disk') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('filesystem'); expect(res.body).to.have.property('capacity'); }); }); });
describe('DELETE /api/v1/calendar/:calendar_selector', () => { it('should delete a calendar', async () => { await authenticatedRequest .delete('/api/v1/calendar/test-calendar') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('success', true); }); }); });
describe('DELETE /api/v1/device/:device_selector', () => { it('should delete device', async () => { await authenticatedRequest .delete('/api/v1/device/test-device') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('success', true); }); }); });
describe('GET /api/v1/system/info', () => { it('should return system infos', async () => { await authenticatedRequest .get('/api/v1/system/info') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('platform'); expect(res.body).to.have.property('nodejs_version'); }); }); });