| 1 |
import { Response } from "@lib"; |
| 2 |
|
| 3 |
describe("Unit | Response", function () { |
| 4 |
test("it can be instantiated and return a rack response", () => { |
| 5 |
let response = new Response(404, {}, {}); |
| 6 |
|
| 7 |
expect(response).toBeTruthy(); |
| 8 |
expect(response.toRackResponse()).toBeTruthy(); |
| 9 |
}); |
| 10 |
|
| 11 |
test("it can be instantiated with just a response code", () => { |
| 12 |
let response = new Response(404); |
| 13 |
|
| 14 |
expect(response).toBeTruthy(); |
| 15 |
expect(response.toRackResponse()).toBeTruthy(); |
| 16 |
}); |
| 17 |
|
| 18 |
test("it adds Content-Type by default", () => { |
| 19 |
let response = new Response(200, {}, {}); |
| 20 |
|
| 21 |
expect(response).toBeTruthy(); |
| 22 |
expect(response.headers["Content-Type"]).toEqual("application/json"); |
| 23 |
}); |
| 24 |
|
| 25 |
test("it does not add Content-Type for a 204 response", () => { |
| 26 |
let response = new Response(204); |
| 27 |
|
| 28 |
expect(response).toBeTruthy(); |
| 29 |
expect(response.headers["Content-Type"]).toBeFalsy(); |
| 30 |
}); |
| 31 |
}); |