/**
 * Acceptance test of redis primitives
 */

/* eslint-env node, mocha */

var expect = require('expect.js');
var messaging = require('../../../db/messaging')({messaging: {}});

describe('Messaging primitives', function () {
  this.timeout(5000);

  after(function () {
    messaging.shutdown();
  });

  describe('Job queue', function () {
    it('redis client is working', function (done) {
      messaging.client.ping(function (err, result) {
        expect(err).to.be(null);
        expect(result).to.be('PONG');
        done();
      });
    });

    it('can publish and subscribe', function (done) {
      messaging.subscribe('test', function (msg) {
        expect(msg.hello).to.be('world');
        done();
      });

      setTimeout(function () {
        messaging.publish('test', {hello: 'world'});
      }, 200);
    });

    it('can create multiple queues and consume messages', function (done) {
      var counter = 0;

      messaging.listen('q1', function (data, jobDone) {
        counter++;
        jobDone();
      });

      messaging.listen('q2', function (data, jobDone) {
        counter++;
        jobDone();
      });

      messaging.submit('q1', {hello: 'world'});
      messaging.submit('q2', {hello: 'world'});

      setTimeout(function () {
        expect(counter).to.be(2);
        done();
      }, 1000);
    });
  });
});

@@ -71,19 +71,21 @@
 cha */%0A%0A
-var
+const
  expect 
@@ -108,19 +108,21 @@
 t.js');%0A
-var
+const
  messagi
@@ -256,27 +256,21 @@
   after(
-function ()
+() =%3E
  %7B%0A    m
@@ -321,27 +321,21 @@
 queue', 
-function ()
+() =%3E
  %7B%0A    i
@@ -362,32 +362,26 @@
 orking',
- function
  (done)
+ =%3E
  %7B%0A     
@@ -403,25 +403,16 @@
 nt.ping(
-function 
 (err, re
@@ -416,16 +416,19 @@
  result)
+ =%3E
  %7B%0A     
@@ -563,32 +563,26 @@
 scribe',
- function
  (done)
+ =%3E
  %7B%0A     
@@ -613,23 +613,17 @@
 st',
- function
  (msg)
+ =%3E
  %7B%0A 
@@ -703,35 +703,29 @@
  setTimeout(
-function ()
+() =%3E
  %7B%0A        m
@@ -853,24 +853,18 @@
 es',
- function
  (done)
+ =%3E
  %7B%0A 
@@ -872,11 +872,11 @@
     
-var
+let
  cou
@@ -914,25 +914,16 @@
 en('q1',
- function
  (data, 
@@ -922,32 +922,35 @@
  (data, jobDone)
+ =%3E
  %7B%0A        count
@@ -1013,25 +1013,16 @@
 en('q2',
- function
  (data, 
@@ -1029,16 +1029,19 @@
 jobDone)
+ =%3E
  %7B%0A     
@@ -1198,27 +1198,21 @@
 Timeout(
-function ()
+() =%3E
  %7B%0A     

migrate to es6-messaging.test