it("should return an error when pusage fails", (done) => { sandbox.stub(pusage, "stat").yields(new Error("bad error")); agent._getStats((err, metrics) => { tryCatch(done, () => { expect(err).to.exist; expect(metrics).to.be.undefined; expect(err.message).to.equal("bad error"); }); }); });
describe('SceneManager', () => { it('should destroy a scene', async () => { const sceneManager = new SceneManager({}, event); sceneManager.scenes['test-scene'] = { name: 'Test Scene', triggers: [], }; await sceneManager.destroy('test-scene'); expect(sceneManager.scenes['test-scene']).to.be.undefined; // eslint-disable-line }); it('should return not found', async () => { const sceneManager = new SceneManager({}, event); const promise = sceneManager.destroy('not-found-scene'); return assert.isRejected(promise); }); });
it('predict', () => { const recognizer = createFaceRecognizer() const trainFaces = loadTrainFaces() recognizer.addFaces(trainFaces.sheldon, 'sheldon') recognizer.addFaces(trainFaces.raj, 'raj') const testFaces = loadTestFaces() function getPrediction(predictions, className) { const prediction = predictions.find(p => p.className === className) expect(prediction).to.not.be.undefined return prediction } const p1 = recognizer.predict(testFaces.sheldon) expect(p1).to.be.an('array').lengthOf(2) expect(p1.map(p => p.className)).to.contain('sheldon') expect(p1.map(p => p.className)).to.contain('raj') expect(getPrediction(p1, 'sheldon').distance).to.be.lessThan(getPrediction(p1, 'raj').distance) const p2 = recognizer.predict(testFaces.raj) expect(p2).to.be.an('array').lengthOf(2) expect(p2.map(p => p.className)).to.contain('sheldon') expect(p2.map(p => p.className)).to.contain('raj') expect(getPrediction(p2, 'raj').distance).to.be.lessThan(getPrediction(p2, 'sheldon').distance) })
expect(cache.get('limelight')).to.be.undefined; });
expect(prediction).to.not.be.undefined return prediction
expect(cache.get('yyz')).to.be.undefined; clock.restore(); filesystem.restore();
expect(response).to.be.undefined(); done(); });
describe('logLevelToString', () => { it('should print log levels as string', () => { expect(logLevelToString(LogLevel.OFF)).to.equal('OFF'); expect(logLevelToString(LogLevel.TRACE)).to.equal('TRACE'); expect(logLevelToString(LogLevel.DEBUG)).to.equal('DEBUG'); expect(logLevelToString(LogLevel.INFO)).to.equal('INFO'); expect(logLevelToString(LogLevel.WARN)).to.equal('WARN'); expect(logLevelToString(LogLevel.ERROR)).to.equal('ERROR'); expect(logLevelToString(LogLevel.CRITICAL)).to.equal('CRITICAL'); expect(logLevelToString(100.0)).to.been.undefined; }); });
describe("#request", function() { context("request with session", function() { var mockRequest = mockHelper.load("intent_request_airport_info.json"); it("session.get(key) should not throw if attribute is not present", function() { var returnedAttributeValue = "overridden"; /** * @param {Alexa.request} req * @param {Alexa.response} res * @param {string} type */ testApp.pre = function(req, res, type) { returnedAttributeValue = req.getSession().get("AttributeWhichDoesNotExist"); }; return testApp.request(mockRequest).then(function() { expect(returnedAttributeValue).to.be.undefined; }); }); }); });
describe("#request", function() { context("request with session", function() { var mockRequest = mockHelper.load("intent_request_airport_info_with_attributes.json"); it("session.get(key) should not throw if attribute is not present", function() { var returnedAttributeValue = "overridden"; var returnedAirportCode = "overridden"; var returnedAirportCodeBackwardsCompat = "overridden"; /** * @param {Alexa.request} req * @param {Alexa.response} res * @param {string} type */ testApp.pre = function(req, res, type) { returnedAttributeValue = req.getSession().get("AttributeWhichDoesNotExist"); returnedAirportCode = req.getSession().get("airportCode"); returnedAirportCodeBackwardsCompat = req.session("airportCode"); }; return testApp.request(mockRequest) .then(function() { expect(returnedAttributeValue).to.be.undefined; expect(returnedAirportCode).to.equal("DAL"); expect(returnedAirportCodeBackwardsCompat).to.equal("DAL"); }); }); }); });
this.request.post('/login') .expect(200) .send({username: 'admin', password: 'admin'}) .expect(function(res) { expect(res.headers['set-cookie']).not.to.be.undefined }) .end(cb)
it("Defaults the net.weightsConfig.distribution to xavieruniform", () => { const net = new Network({weightsConfig: {limit: 1}}) expect(net.weightsConfig).to.not.be.undefined expect(net.weightsConfig.distribution).to.equal("xavieruniform") })
it("Creates a random neuron.rreluSlope number if the activation is rrelu", () => { neuron2.init({activation: "rrelu"}) expect(neuron2.rreluSlope).to.not.be.undefined expect(neuron2.rreluSlope).to.be.a.number expect(neuron2.rreluSlope).to.be.at.most(0.0011) })