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