MockClient.js 892 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* eslint-disable
  2. no-unused-vars,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * DS207: Consider shorter variations of null checks
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. let MockClient
  13. const sinon = require('sinon')
  14. let idCounter = 0
  15. module.exports = MockClient = class MockClient {
  16. constructor() {
  17. this.attributes = {}
  18. this.join = sinon.stub()
  19. this.emit = sinon.stub()
  20. this.disconnect = sinon.stub()
  21. this.id = idCounter++
  22. }
  23. set(key, value, callback) {
  24. this.attributes[key] = value
  25. if (callback != null) {
  26. return callback()
  27. }
  28. }
  29. get(key, callback) {
  30. return callback(null, this.attributes[key])
  31. }
  32. disconnect() {}
  33. }