koa-lite/test/response/last-modified.js
2013-11-13 19:59:49 -08:00

27 lines
No EOL
817 B
JavaScript

var response = require('../response');
describe('res.lastModified', function(){
it('should set the header as a UTCString', function(){
var res = response();
var date = new Date();
res.lastModified = date;
res.header['last-modified'].should.equal(date.toUTCString());
})
it('should work with date strings', function(){
var res = response();
var date = new Date();
res.lastModified = date.toString();
res.header['last-modified'].should.equal(date.toUTCString());
})
it('should get the header as a Date', function(){
// Note: Date() removes milliseconds, but it's practically important.
var res = response();
var date = new Date();
res.lastModified = date;
(res.lastModified.getTime() / 1000)
.should.equal(Math.floor(date.getTime() / 1000));
})
})