return expect( iterate.async(() => {}) ).to.eventually.be.rejectedWith(/Use iterate\(\)/) }) iterate.async(() => Promise.resolve()) ]) ).to.eventually.be.rejectedWith(/Detected concurrently running tests/) })
}, 20) )) ).to.eventually.be.rejectedWith(MemoryLeakError, /^Heap grew on \d subsequent garbage collections[\s\S]*Iterations between GCs: 30[\s\S]*Final GC details:/) })
describe("#request", function() { context("request without session", function() { var mockRequest = mockHelper.load("audio_player_event_request.json"); it("session.get(key) should fail the app", 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"); }; var subject = testApp.request(mockRequest); return expect(subject).to.eventually.be.rejectedWith(testApp.messages.NO_SESSION); }); }); });
}); return expect(subject).to.eventually.be.rejectedWith(testApp.messages.NO_SESSION); }); }); }); return expect(subject).to.eventually.be.rejectedWith(testApp.messages.NO_SESSION); });
return response.response.outputSpeech; }); return expect(subject).to.eventually.be.rejectedWith("Unhandled exception: OOPS!."); }); return response.response.outputSpeech; }); return expect(subject).to.eventually.be.rejectedWith("Unhandled exception: OOPS!."); }); return response.response.outputSpeech; }); return expect(subject).to.eventually.be.rejectedWith("Unhandled exception."); });
return response.response; }); return expect(subject).to.eventually.be.rejectedWith("foobar"); }); return response.response.outputSpeech; }); return expect(subject).to.eventually.be.rejectedWith("INVALID_REQUEST_TYPE"); });
describe("#request", function() { context("request without session", function() { var mockRequest = mockHelper.load("audio_player_event_request.json"); it("session.clear() should fail the app", function() { /** * @param {Alexa.request} req * @param {Alexa.response} res * @param {string} type */ testApp.pre = function(req, res, type) { return req.getSession().clear(); }; var subject = testApp.request(mockRequest); return expect(subject).to.eventually.be.rejectedWith(testApp.messages.NO_SESSION); }); }); });
it("rejects with an exception if the response comes back with an error.", function () { const expectedMockError = new Error("Stamn! She's a tough one!"); let mockSender = new MockSenderWithResponse([], expectedMockError); let client = new Client(mockSender); let lookup = new Lookup(); return expect(client.send(lookup)).to.eventually.be.rejectedWith(expectedMockError); });
static checkFail(optional, ErrorClass, message) { const value = optional instanceof Promise ? optional : optional.get(); return chai.expect(value) .to.eventually.be.rejectedWith(ErrorClass, message); }
it('should throw an error if value is an object', (done) => { const rules = { digits: 'array' }; const params = { digits: { numbers: [1, 2, 3] } }; expect(whitelister(rules, params)).to.eventually.be.rejectedWith(WhitelistError) .then((response) => { expect(response).to.be.an.instanceof(WhitelistError) .that.has.property('errors') .that.is.an('array') .that.has.lengthOf(1); expect(response.errors[0]).to.have.property('field', 'digits'); expect(response.errors[0]).to.have.property('message', 'is not an array'); done(); }); });
describe('basic errors', () => { it('should require rules as an argument', (done) => { expect(whitelister()) .to.eventually.be.rejectedWith(ArgumentError, 'rules is not an object or string') .and.notify(done); }); it('should require rules (an object or string) as first argument', (done) => { expect(whitelister(true)) .to.eventually.be.rejectedWith(ArgumentError, 'rules is not an object or string') .and.notify(done); }); });
it('should return throw error missing username', async () => { await expect(avatarPicker.facebook.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); await expect(avatarPicker.github.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); await expect(avatarPicker.gmail.getAvatar()).to.eventually.be.rejectedWith('Gmail required as input'); await expect(avatarPicker.instagram.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); await expect(avatarPicker.tumblr.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); await expect(avatarPicker.twitter.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); await expect(avatarPicker.vimeo.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); await expect(avatarPicker.youtube.getAvatar()).to.eventually.be.rejectedWith('Username required as input'); });
describe('#addArgument()', () => { const ARGUMENT = 'PSCommand'; it('should add argument to the Shell', () => { const test = ps.addCommand(COMMAND) .then(() => ps.addArgument(ARGUMENT)); expect(test).to.eventually.be.an('array') .that.have.nested.property('[0].command', `${COMMAND} ${ARGUMENT}`); }); it('should fail adding argument to the Shell', () => { expect(ps.addArgument(ARGUMENT)).be.eventually.rejectedWith(PS_ARG_MISS_ERROR); }); });
describe(".getBerryByName(String: name) invalid", function() { it("should fail", function() { return expect(P.getBerryByName("das")).to.be.rejected }); it("should fail with an error that has response property", function() { return expect(P.getBerryByName("das")).to.be.eventually.rejectedWith(Error).and.have.property('response'); }); });
it("rejects with an exception if the response comes back with an error.", function () { const expectedMockError = new Error("Stamn! She's a tough one!"); let mockSender = new MockSenderWithResponse([], expectedMockError); let client = new Client(mockSender); let lookup = new Lookup(); return expect(client.send(lookup)).to.eventually.be.rejectedWith(expectedMockError); });