2013-11-14 03:59:49 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-05-11 03:30:32 +00:00
|
|
|
const assert = require('assert');
|
2015-10-12 04:59:30 +00:00
|
|
|
const response = require('../helpers/context').response;
|
2013-11-14 03:59:49 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
describe('res.lastModified', () => {
|
|
|
|
it('should set the header as a UTCString', () => {
|
2015-10-05 18:23:47 +00:00
|
|
|
const res = response();
|
|
|
|
const date = new Date();
|
2013-11-14 03:59:49 +00:00
|
|
|
res.lastModified = date;
|
2017-05-11 03:30:32 +00:00
|
|
|
assert.equal(res.header['last-modified'], date.toUTCString());
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
2013-11-14 03:59:49 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
it('should work with date strings', () => {
|
2015-10-05 18:23:47 +00:00
|
|
|
const res = response();
|
|
|
|
const date = new Date();
|
2013-11-14 03:59:49 +00:00
|
|
|
res.lastModified = date.toString();
|
2017-05-11 03:30:32 +00:00
|
|
|
assert.equal(res.header['last-modified'], date.toUTCString());
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
2013-11-14 03:59:49 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
it('should get the header as a Date', () => {
|
2013-11-14 03:59:49 +00:00
|
|
|
// Note: Date() removes milliseconds, but it's practically important.
|
2015-10-05 18:23:47 +00:00
|
|
|
const res = response();
|
|
|
|
const date = new Date();
|
2013-11-14 03:59:49 +00:00
|
|
|
res.lastModified = date;
|
2017-05-11 03:30:32 +00:00
|
|
|
assert.equal((res.lastModified.getTime() / 1000), Math.floor(date.getTime() / 1000));
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
2014-10-01 12:42:29 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
describe('when lastModified not set', () => {
|
|
|
|
it('should get undefined', () => {
|
2015-10-05 18:23:47 +00:00
|
|
|
const res = response();
|
2017-05-11 03:30:32 +00:00
|
|
|
assert.equal(res.lastModified, undefined);
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|