var wq = require('../lib/wq.js')
  , testutil = require('testutil')
  , batch = require('batchflow')

var WQ_NAME = 'wqtest'
var q = null

describe('wq', function() {
  beforeEach(function(done) {
    wq.create({name: WQ_NAME}, function(err, _q) {
      if (err) return done(err)
      q = _q
      done()
    })
  })

  afterEach(function(done) {
    wq.destroy({name: WQ_NAME}, function(err) {
      if (err) return done(err)
      done()
    })
  })

  describe('queue counts', function() {
    describe('> when three objects are enqueued', function() {
      it('the waiting q should have a count of 3 and others have a count of 0', function(done) {
        var data = [{name: 'JP'}, {name: 'Leslie'}, {name: 'Chris'}]
        batch(data).seq().each(function(i, item, next) {
          q.enq(item, i, next)
        })
        .error(done)
        .end(function() {
          q.count(function(err, counts) {
            if (err) return done(err)
            EQ (counts.waiting, 3)
            EQ (counts.running, 0)
            EQ (counts.done, 0)
            done()
          })
        })
      })
    })
  })
})
@@ -1098,20 +1098,840 @@
    %7D)%0A    %7D)
+%0A%0A    describe('%3E when three objects are enqueued and one is dequeued', function() %7B%0A      it('the waiting q should have a count of 2 and running should have a count of 1 and done should have a count of 0', function(done) %7B%0A        var data = %5B%7Bname: 'JP'%7D, %7Bname: 'Leslie'%7D, %7Bname: 'Chris'%7D%5D%0A        batch(data).seq().each(function(i, item, next) %7B%0A          q.enq(item, i, next)%0A        %7D)%0A        .error(done)%0A        .end(function() %7B%0A          q.deq(function(err, item) %7B%0A            if (err) return done(err)%0A            EQ (item.data.name, 'JP')%0A            q.count(function(err, counts) %7B%0A              if (err) return done(err)%0A              EQ (counts.waiting, 2)%0A              EQ (counts.running, 1)%0A              EQ (counts.done, 0)%0A              done()%0A            %7D)%0A          %7D)%0A        %7D)%0A      %7D)%0A    %7D)
 %0A  %7D)%0A%7D)

update counts after deq