it('should get 0 rooms (take = 0)', async () => { const rooms = await room.get({ expand: ['devices'], take: 0, }); expect(rooms).to.be.instanceOf(Array); expect(rooms).to.have.lengthOf(0); });
describe('session.get', () => { it('should get sessions', async () => { const session = new Session('secret'); const sessions = await session.get('0cd30aef-9c4e-4a23-88e3-3547971296e5'); expect(sessions).to.be.instanceOf(Array); sessions.forEach((oneSession) => { expect(oneSession).to.have.property('token_type'); expect(oneSession).to.have.property('scope'); expect(oneSession.scope).to.be.instanceOf(Array); expect(oneSession).not.to.have.property('token_hash'); }); }); });
describe('room.getAll', () => { const brain = { addRoom: fake.returns(null), removeRoom: fake.returns(null), }; const room = new Room(brain); it('should get all rooms', async () => { const rooms = await room.getAll(); expect(rooms).to.be.instanceOf(Array); rooms.forEach((oneRoom) => { expect(oneRoom).to.have.property('name'); }); }); });
describe('#getAll', () => { beforeEach(() => { return factory.createMany('user', 2, [ { name: 'User 1' }, { name: 'User 2' } ]); }); it('returns all users from the database', async () => { const users = await repository.getAll(); expect(users).to.have.lengthOf(2); expect(users[0]).to.be.instanceOf(User); expect(users[0].name).to.equal('User 1'); expect(users[1]).to.be.instanceOf(User); expect(users[1].name).to.equal('User 2'); }); });
describe('zwaveService', () => { const zwaveService = ZwaveService(gladys, 'be86c4db-489f-466c-aeea-1e262c4ee720'); it('should have controllers', () => { expect(zwaveService) .to.have.property('controllers') .and.be.instanceOf(Object); }); it('should start service', async () => { await zwaveService.start(); }); it('should stop service', async () => { await zwaveService.stop(); }); });
describe('Light.buildLightObject', () => { it('should should build light object with binary deviceFeature', async () => { const stateManager = new StateManager(event); const deviceManager = new Device(event, {}, stateManager, {}); const device = { id: '78ffc050-71c4-4dfe-8f3b-4b153e79c457', selector: 'test', features: [ { category: DEVICE_FEATURE_CATEGORIES.LIGHT, type: DEVICE_FEATURE_TYPES.LIGHT.BINARY, }, ], }; const light = deviceManager.lightManager.buildLightObject(device); expect(light) .to.have.property('turnOn') .and.be.instanceOf(Function); expect(light) .to.have.property('turnOff') .and.be.instanceOf(Function); }); });
lennaFaces.forEach(f => expect(f).to.be.instanceOf(fr.ImageRGB)) }) gotFaces.forEach(f => expect(f).to.be.instanceOf(fr.ImageRGB)) })
describe('#getById', () => { context('when user exists', () => { it('returns the user', async () => { const user = await factory.create('user', { name: 'User' }); const foundUser = await repository.getById(user.id); expect(foundUser).to.be.instanceOf(User); expect(foundUser.id).to.equal(user.id); expect(foundUser.name).to.equal('User'); }); }); context('when the user does not exist', () => { it('rejects with an error', async () => { try { await repository.getById(0); } catch(error) { expect(error.message).to.equal('NotFoundError'); expect(error.details).to.equal('User with id 0 can\'t be found.'); } }); }); });
describe('GET /api/v1/room', () => { it('should get rooms with pagination and devices', async () => { await authenticatedRequest .get('/api/v1/room?expand=devices') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.be.instanceOf(Array); res.body.forEach((room) => { expect(room).to.have.property('devices'); }); }); }); });
describe('Camera.get', () => { it('should return list of cameras', async () => { const stateManager = new StateManager(event); const deviceManager = new Device(event, {}, stateManager, {}); const cameras = await deviceManager.camera.get(); expect(cameras).to.be.instanceOf(Array); cameras.forEach((camera) => { expect(camera).to.have.property('name'); expect(camera).to.have.property('selector'); expect(camera).to.have.property('features'); expect(camera).to.have.property('room'); }); }); });
describe('PhilipsHueService', () => { it('should have controllers', () => { const philipsHueService = PhilipsHueService(); expect(philipsHueService) .to.have.property('controllers') .and.be.instanceOf(Object); }); it('should start service', async () => { const philipsHueService = PhilipsHueService(); await philipsHueService.start(); }); it('should stop service', async () => { const philipsHueService = PhilipsHueService(); await philipsHueService.stop(); }); });
describe('GET /api/v1/session', () => { it('should get api key list', async () => { await authenticatedRequest .get('/api/v1/session') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.be.instanceOf(Array); res.body.forEach((oneSession) => { expect(oneSession).to.have.property('token_type'); expect(oneSession).not.to.have.property('token_hash'); }); }); }); it('should return empty array', async () => { await authenticatedRequest .get('/api/v1/session?skip=10000') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.be.instanceOf(Array); expect(res.body).to.have.lengthOf(0); }); }); });
describe('GET /api/v1/service/:service_name/device', () => { it('should return devices in service test-service', async () => { await authenticatedRequest .get('/api/v1/service/test-service/device') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.be.instanceOf(Array); }); }); it('should return 404 not found', async () => { await authenticatedRequest .get('/api/v1/service/unknown-service/device') .expect('Content-Type', /json/) .expect(404); }); });
describe('GET /api/v1/camera', () => { it('should get list of cameras', async () => { await authenticatedRequest .get('/api/v1/camera') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.be.instanceOf(Array); res.body.forEach((camera) => { expect(camera).to.have.property('name'); expect(camera).to.have.property('features'); expect(camera).to.have.property('room'); }); }); }); });
describe('GET /api/v1/device', () => { it('should get device', async () => { await authenticatedRequest .get('/api/v1/device') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.be.instanceOf(Array); res.body.forEach((device) => { expect(device).to.have.property('features'); expect(device).to.have.property('params'); }); }); }); });