import { expect } from 'chai'; import { Response } from '../../src/http'; describe('A Response object', () => { let response: Response; let code = 200; let body = { foo: 'bar' }; it('should be constructed from a status code and a body', () => { response = new Response(code, body); expect(response.code).to.equal(code); expect(response.body).to.equal(body); }); it('should have a default application/json Content-Type header', () => { let headers = response.headers; expect(headers).to.exist; expect(headers['Content-Type']).to.equal('application/json'); }) it('should produce a JSON representation of itself', () => { expect(response.toLambdaResponse).to.exist; let json: any = response.toLambdaResponse(); expect(typeof json.headers).to.equal('object'); expect(typeof json.statusCode).to.equal('number'); expect(typeof json.body).to.equal('string'); }); });