describe("recalculatePosition", () => { it("should set new position and recreate node", () => { const baseGraph = new BaseLineGraph(options); sandbox.spy(testContainer, "remove"); sandbox.spy(testContainer, "append"); sandbox.stub(baseGraph, "_getPosition").returns({ top: "20%" }); baseGraph.recalculatePosition(); expect(baseGraph.node).to.have.property("position").that.deep.equals({ top: "20%" }); expect(testContainer.remove).to.have.been.calledOnce; expect(testContainer.append).to.have.been.calledOnce; }); it("should do nothing if position is unchanged", () => { options.layoutConfig.getPosition = function () { return { top: "10%" }; }; const baseGraph = new BaseLineGraph(options); const originalPosition = baseGraph.node.position; sandbox.spy(testContainer, "remove"); sandbox.stub(baseGraph, "_getPosition").returns({ top: "10%" }); baseGraph.recalculatePosition(); expect(baseGraph.node).to.have.property("position", originalPosition); expect(testContainer.remove).to.have.not.been.called; }); });
const baseView = new BaseView(options); baseView.node = blessed.element(); expect(options.layoutConfig.getPosition).to.have.not.been.called;
}) expect(db.healthCheck).to.have.been.called expect(redis.healthCheck).to.have.been.called }) .end() expect(db.healthCheck).to.have.been.called }) .end() expect(redis.healthCheck).to.have.been.called }) .end() expect(db.healthCheck).not.to.have.been.called expect(redis.healthCheck).not.to.have.been.called }) })
it('starts agent', function () { var agentCreateStub = this.sandbox.stub(Agent, 'create').returns(fakeAgent) var instrumentationCreateStub = this.sandbox.stub(Instrumentation, 'create').returns({}) // eslint-disable-next-line new trace.Trace(fakeConfig) expect(agentCreateStub).to.be.calledWith({ config: fakeConfig }) expect(instrumentationCreateStub).to.be.called expect(fakeAgent.start).to.be.called })
it('should call the original', function () { var query = this.sandbox.spy(function () { return new Readable() }) wrapQuery(query, [], agent, { continuationMethod: 'eventEmitter' }) expect(query).to.have.been.called })
it('should pass controller buffer, border colour and mode', async () => { expect(controller.redraw).to.not.have.been.called; inkyphat.setBorder(RED); inkyphat.setMode('noFlash'); await inkyphat.redraw(); expect(controller.redraw).to.have.callCount(1); expect(controller.redraw.getCall(0).args[0].length).to.equal(WIDTH); expect(controller.redraw.getCall(0).args[0][0].length).to.equal(HEIGHT); expect(controller.redraw.getCall(0).args[1]).to.equal(RED); expect(controller.redraw.getCall(0).args[2]).to.equal('noFlash'); });
it('test listener with no matches', function() { $compile('{{{test3}}}')(scope).then(function(t) { expect(t).to.eq(''); expect($LogProvider.warn).not.to.have.been.called; }); });
it("Runs validation when validation data is given", () => { sinon.spy(net, "validate") return net.train(testDataWithOutput, {epochs: 10, validation: {data: testDataWithOutput, interval: 2}}).then(() => { expect(net.validate).to.be.called net.validate.restore() }) })
it("Calls a given callback with an object containing keys: 'elapsed', 'iterations', 'error' and 'input', for each iteration", () => { sinon.stub(console, "warn") return net.test(testData, {callback: console.warn}).then(() => { expect(console.warn).to.have.been.called expect(console.warn.callCount).to.equal(4) expect(console.warn).to.have.been.calledWith(sinon.match.has("iterations")) expect(console.warn).to.have.been.calledWith(sinon.match.has("error")) expect(console.warn).to.have.been.calledWith(sinon.match.has("input")) expect(console.warn).to.have.been.calledWith(sinon.match.has("elapsed")) console.warn.restore() }) })
it('skips whitelisted hosts', function () { var r = request(original, agent) r({ host: 'risingstack.com' }) expect(agent.tracer.collector.clientSend).not.to.be.called expect(original).to.be.calledWith({ host: 'risingstack.com', method: 'GET', path: '/' }) })
it('should not pass spiDevice to controller if not specified', async () => { await inkyphat.init(); expect(controllerFactory).to.have.been.called; expect(controllerFactory.getCall(0).args[0]).to.not.have.property('spiDevice'); });
it('should allow the mode to be overridden for this call only', async () => { expect(controller.redraw).to.not.have.been.called; inkyphat.setBorder(RED); inkyphat.setMode('noFlash'); await inkyphat.redraw('pimoroni'); expect(controller.redraw).to.have.callCount(1); expect(controller.redraw.getCall(0).args[2]).to.equal('pimoroni'); await inkyphat.redraw(); expect(controller.redraw).to.have.callCount(2); expect(controller.redraw.getCall(1).args[2]).to.equal('noFlash'); });
it('should call the original', function () { var query = this.sandbox.spy(function () { return Promise.resolve() }) wrapQuery(query, [], agent, { continuationMethod: 'promise' }) expect(query).to.have.been.called })
}) expect(db.healthCheck).to.have.been.called expect(redis.healthCheck).to.have.been.called }) .end() expect(db.healthCheck).to.have.been.called }) .end() expect(redis.healthCheck).to.have.been.called }) .end() expect(db.healthCheck).not.to.have.been.called expect(redis.healthCheck).not.to.have.been.called }) })