/* eslint-env jasmine */
var nock = require('nock')
var VoucherifyClient = require('./client-loader')
var fixtures = require('./fixtures')
var reqWithBody = fixtures.reqWithBody
nock.disableNetConnect()

describe('Distributions API', function () {
  var client = new VoucherifyClient({
    applicationId: 'node-sdk-test-id',
    clientSecretKey: 'node-sdk-test-secret'
  })

  describe('publish voucher', function () {
    it('should publish by camaign name', function (done) {
      var server = nock('https://api.voucherify.io', reqWithBody)
        .post('/v1/vouchers/publish')
        .query({campaign: 'test-campaign'})
        .reply(200, {})

      client.distributions.publish('test-campaign')
      .then(function () {
        server.done()
        done()
      })
    })

    it('should publish by voucher', function (done) {
      var server = nock('https://api.voucherify.io', reqWithBody)
        .post('/v1/vouchers/publish', {
          campaign: 'test-campaign',
          voucher: 'test-voucher'
        })
        .reply(200, {})

      client.distributions.publish({
        campaign: 'test-campaign',
        voucher: 'test-voucher'
      })
      .then(function () {
        server.done()
        done()
      })
    })
  })
})

@@ -573,17 +573,19 @@
 publish'
-)
+, %7B
 %0A       
@@ -589,16 +589,12 @@
     
-.query(%7B
+    
 camp
@@ -614,16 +614,25 @@
 ampaign'
+%0A        
 %7D)%0A     

Fix test nock asseriton