MockRequest.js 580 B

1234567891011121314151617181920212223242526272829303132
  1. const sinon = require('sinon')
  2. class MockRequest {
  3. constructor() {
  4. this.session = { destroy() {} }
  5. this.ip = '42.42.42.42'
  6. this.headers = {}
  7. this.params = {}
  8. this.query = {}
  9. this.body = {}
  10. this._parsedUrl = {}
  11. this.i18n = {
  12. translate(str) {
  13. return str
  14. },
  15. }
  16. this.route = { path: '' }
  17. this.accepts = () => {}
  18. this.setHeader = () => {}
  19. this.logger = {
  20. addFields: sinon.stub(),
  21. setLevel: sinon.stub(),
  22. }
  23. }
  24. param(param) {
  25. return this.params[param]
  26. }
  27. }
  28. module.exports = MockRequest