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('create', () => { afterEach(() => { AWS.restore('DynamoDB.DocumentClient') }) it('should generate component id', async () => { const store = new MetricsStore() store.update = sinon.spy() await store.create(new Metric({type: 'Mock'})) assert(store.update.calledOnce) assert(store.update.firstCall.args[0].metricID.length === 12) }) })
describe("node_onShow", () => { it("saves focus and pops up the dialog", () => { const gotoTimeView = new GotoTimeView(options); const spyTextBoxFocus = sandbox.spy(gotoTimeView.textBox, "focus"); gotoTimeView.node.emit("show"); expect(gotoTimeView.screen.saveFocus).to.have.been.calledOnce; expect(gotoTimeView.node.setFront).to.have.been.calledOnce; expect(gotoTimeView.form.reset).to.have.been.calledOnce; expect(spyTextBoxFocus).to.have.been.calledOnce; }); });
describe('updateEventUpdate', () => { const eventType = messageType.incidentPatched it('should update the existing event', async () => { await handler.updateEventUpdate(eventUpd, eventType) assert(eventUpd.validate.calledOnce) assert(eventUpdatesStore.update.calledOnce) }) it('should notify the update', async () => { await handler.updateEventUpdate(eventUpd, eventType) assert(snsStub.calledOnce) }) })
describe("hide", () => { it("hides the popup and restores focus", () => { const gotoTimeView = new GotoTimeView(options); gotoTimeView.hide(); expect(gotoTimeView.node.hide).to.have.been.calledOnce; expect(gotoTimeView.screen.restoreFocus).to.have.been.calledOnce; expect(gotoTimeView.screen.render).to.have.been.calledOnce; }); });
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('corsMiddleware', () => { it('should send response directly', async () => { const req = new MockExpressRequest({ method: 'OPTIONS', }); corsMiddleware(req, res, () => { throw new Error('next should not be calld'); }); assert.called(res.header); assert.calledOnce(res.send); }); });
describe('GET /service/philips-hue/bridge', () => { it('should get bridges', async () => { const philipsHueController = PhilipsHueControllers(philipsHueLightService); await philipsHueController['get /api/v1/service/philips-hue/bridge'].controller({}, res); assert.calledOnce(philipsHueLightService.getBridges); }); });
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('create', () => { afterEach(() => { AWS.restore('DynamoDB.DocumentClient') }) it('should generate component id', async () => { const store = new ComponentsStore() store.update = sinon.spy() await store.create(new Component({})) assert(store.update.calledOnce) assert(store.update.firstCall.args[0].componentID.length === 12) }) })
describe('GET /api/v1/service/xiaomi/sensor', () => { it('should get sensors', async () => { const xiaomiController = XiaomiController({ getSensors }); const req = {}; await xiaomiController['get /api/v1/service/xiaomi/sensor'].controller(req, res); assert.calledOnce(getSensors); }); });
describe('GET /api/v1/service/usb/port', () => { it('should configure bridge', async () => { const usbController = UsbController({ list }); const req = {}; await usbController['get /api/v1/service/usb/port'].controller(req, res); assert.calledOnce(list); }); });
describe('create', () => { afterEach(() => { AWS.restore('DynamoDB.DocumentClient') }) it('should generate component id', async () => { const store = new MetricsStore() store.update = sinon.spy() await store.create(new Metric({type: 'Mock'})) assert(store.update.calledOnce) assert(store.update.firstCall.args[0].metricID.length === 12) }) })
describe('GET /api/v1/service/usb/port', () => { it('should configure bridge', async () => { const usbController = UsbController({ list }); const req = {}; await usbController['get /api/v1/service/usb/port'].controller(req, res); assert.calledOnce(list); }); });
describe('GET /api/v1/service/xiaomi/sensor', () => { it('should get sensors', async () => { const xiaomiController = XiaomiController({ getSensors }); const req = {}; await xiaomiController['get /api/v1/service/xiaomi/sensor'].controller(req, res); assert.calledOnce(getSensors); }); });