koa-lite/test/response/etag.js

34 lines
786 B
JavaScript
Raw Permalink Normal View History

'use strict';
2017-05-11 03:30:32 +00:00
const assert = require('assert');
const response = require('../helpers/context').response;
describe('res.etag=', () => {
it('should not modify an etag with quotes', () => {
const res = response();
res.etag = '"asdf"';
2017-05-11 03:30:32 +00:00
assert.equal(res.header.etag, '"asdf"');
2015-10-12 20:36:41 +00:00
});
it('should not modify a weak etag', () => {
const res = response();
res.etag = 'W/"asdf"';
2017-05-11 03:30:32 +00:00
assert.equal(res.header.etag, 'W/"asdf"');
2015-10-12 20:36:41 +00:00
});
it('should add quotes around an etag if necessary', () => {
const res = response();
res.etag = 'asdf';
2017-05-11 03:30:32 +00:00
assert.equal(res.header.etag, '"asdf"');
2015-10-12 20:36:41 +00:00
});
});
2014-07-06 08:43:14 +00:00
describe('res.etag', () => {
it('should return etag', () => {
const res = response();
2014-07-06 08:43:14 +00:00
res.etag = '"asdf"';
2017-05-11 03:30:32 +00:00
assert.equal(res.etag, '"asdf"');
2015-10-12 20:36:41 +00:00
});
});