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 update series without exceeding limit", () => { options.layoutConfig.view.limit = 3; options.series.high = { highwater: true }; const baseGraph = new BaseLineGraph(options); baseGraph.update({ a: 27, high: 27 }); expect(baseGraph).to.have.nested.property("series.a.y").that.deep.equals([0, 0, 27]); expect(baseGraph).to.have.nested.property("series.high.y").that.deep.equals([27, 27, 27]); });
describe("Remove (Sync)", function(){ it("Should have been removed from the index", function(){ flexsearch_sync.remove(0); flexsearch_sync.remove(2); flexsearch_sync.remove(1); expect(flexsearch_sync.length).to.equal(0); expect(flexsearch_sync.search("foo")).to.have.lengthOf(0); expect(flexsearch_sync.search("bar")).to.have.lengthOf(0); expect(flexsearch_sync.search("foobar")).to.have.lengthOf(0); }); });
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('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("acceptButton_onKey_escape", () => { it("presses the cancel button programmatically", () => { // to make the screen act like a real event emitter, set stubEvents to false // and create a new testContainer createTestContainer(false); const gotoTimeView = new GotoTimeView(options); gotoTimeView.acceptButton.focus(); gotoTimeView.screen.program.emit("keypress", "escape", { full: "escape" }); expect(gotoTimeView.cancelButton.press).to.have.been.calledOnce; }); });
describe("toggle", () => { it("toggles the visibility of the popup", () => { const gotoTimeView = new GotoTimeView(options); gotoTimeView.toggle(); expect(gotoTimeView.node.toggle).to.have.been.calledOnce; }); });
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("form_onReset", () => { it("hides any error text being shown", () => { const gotoTimeView = new GotoTimeView(options); gotoTimeView.form.emit("reset"); expect(gotoTimeView.errorText.hide).to.have.been.calledOnce; }); });
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("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); }); });
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'); }); }); });