koa-lite/test/request/idempotent.js

26 lines
653 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', () => {
describe('when the request method is idempotent', () => {
it('should return true', () => {
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', () => {
it('should return false', () => {
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
});
});
});