koa-lite/test/request/idempotent.js

26 lines
673 B
JavaScript
Raw Normal View History

2014-07-06 08:43:14 +00:00
'use strict';
const request = require('../helpers/context').request;
2014-07-06 08:43:14 +00:00
describe('ctx.idempotent', function(){
2015-10-12 20:36:41 +00:00
describe('when the request method is idempotent', function(){
it('should return true', function(){
2014-07-06 08:43:14 +00:00
['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'].forEach(check);
2015-10-12 20:36:41 +00:00
function check(method){
const req = request();
2014-07-06 08:43:14 +00:00
req.method = method;
req.idempotent.should.equal(true);
}
2015-10-12 20:36:41 +00:00
});
});
2014-07-06 08:43:14 +00:00
describe('when the request method is not idempotent', function(){
2015-10-12 20:36:41 +00:00
it('should return false', function(){
const req = request();
2014-07-06 08:43:14 +00:00
req.method = 'POST';
req.idempotent.should.equal(false);
2015-10-12 20:36:41 +00:00
});
});
});