test( 'should export expected reducer keys', () => { expect( reducer( undefined, {} ) ).to.have.keys( [ 'hasChanges', 'fileInfo', 'transform', 'cropBounds', 'crop', 'aspectRatio', 'imageIsLoading', 'originalAspectRatio', ] ); } );
describe('API /', () => { it('it should return Welcome message', (done) => { chai.request(app) .get('/') .end((err, res) => { res.should.have.status(200); res.should.to.be.html; res.text.should.be.equal("Hello Docker World\n"); done(); }); }); });
it('should concat handlers for same paths with different dynamic segment names', async function() { addHandlers('/ping/:id'); expect(server.lookup('GET', '/ping/:id').handlers).to.have.lengthOf(3); addHandlers('/ping/:uuid'); expect(server.lookup('GET', '/ping/:id').handlers).to.have.lengthOf(6); expect(server.lookup('GET', '/ping/:uuid').handlers).to.have.lengthOf(6); });
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'); }); });
it('.emit()', async function() { expect(emitter.emit('a')).to.be.a('promise'); const array = []; emitter.on('a', () => array.push(1)); emitter.on('a', async () => { await timeout(10); array.push(2); }); emitter.on('a', () => array.push(3)); expect(await emitter.emit('a')).to.be.true; expect(array).to.have.ordered.members([1, 2, 3]); });
describe("isVisible", () => { it("returns the visibility of the popup", () => { const gotoTimeView = new GotoTimeView(options); gotoTimeView.toggle(); expect(gotoTimeView.node.toggle).to.have.been.calledOnce; expect(gotoTimeView.isVisible()).to.equal(false); }); });
it('registers a known event via .once()', function() { const handler = new Handler(); const { _eventEmitter: eventEmitter } = handler; expect(eventEmitter.hasListeners('request')).to.be.false; handler.once('request', () => {}); expect(eventEmitter.hasListeners('request')).to.be.true; handler.once('request', () => {}); expect(eventEmitter.listeners('request')).to.have.lengthOf(2); eventEmitter.emitSync('request'); expect(eventEmitter.hasListeners('request')).to.be.false; });
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('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('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('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/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/gateway/status', () => { it('should get gateway status', async () => { await authenticatedRequest .get('/api/v1/gateway/status') .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('connected'); expect(res.body).to.have.property('configured'); }); }); });
it('registers a known event via .once()', function() { const handler = new Handler(); const { _eventEmitter: eventEmitter } = handler; expect(eventEmitter.hasListeners('request')).to.be.false; handler.once('request', () => {}); expect(eventEmitter.hasListeners('request')).to.be.true; handler.once('request', () => {}); expect(eventEmitter.listeners('request')).to.have.lengthOf(2); eventEmitter.emitSync('request'); expect(eventEmitter.hasListeners('request')).to.be.false; });