alagarr
Version:
Alagarr is a request-response helper library that removes the boilerplate from your Node.js serverless functions and helps make your code portable.
39 lines (38 loc) • 1.32 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const etag_1 = __importStar(require("./etag"));
const testTextBody = 'foobar';
const testTextBodyETag = '"6-iEPX+SQWIR3p67lj/0zigSWTKHg"';
describe('Response ETag header', () => {
test('is set correctly given a string', () => {
const { headers } = etag_1.default({
body: testTextBody,
headers: {},
statusCode: 200,
});
expect(headers.etag).toBe(testTextBodyETag);
});
test('is set correctly given a Buffer', () => {
const { headers } = etag_1.default({
body: Buffer.from(testTextBody),
headers: {},
statusCode: 200,
});
expect(headers.etag).toBe(testTextBodyETag);
});
test('should handle an empty entity', () => {
const { headers } = etag_1.default({
body: '',
headers: {},
statusCode: 200,
});
expect(headers.etag).toBe(etag_1.EMPTY_ENTITY_TAG);
});
});