 { withConvertedUser }               = require '../../../../../workers/social/testhelper'
 { withConvertedUserAndApiToken }    = require '../../../../../workers/social/testhelper/models/apitokenhelper'
 
-apiErrors = require './errors'
+apiErrors                           = require './errors'
+KodingLogger                        = require '../../../../models/kodinglogger'
+
 
 generateLogRequestParams = (opts = {}, subdomain) ->
 

      withConvertedUser { role: 'admin' }, (admin) ->
        TESTUSERS.admin = admin

        done()



      done()


  it 'should send HTTP 200 and the result in data if session is valid', (done) ->

    { client, group } = TESTUSERS.admin

    logRequestParams = generateRequestParamsEncodeBody
      url      : generateUrl { route : "-/api/logs?q=#{TESTLOG}" }
      clientId : client.sessionToken

    identifier = KodingLogger.getIdentifier TESTSCOPE, group.slug

    request.get logRequestParams, (err, res, body) ->

      expect(err).to.not.exist
      expect(res.statusCode).to.be.equal 200
      expect(body).to.contain 'data'
      expect((JSON.parse body).data.logs).to.exist
      expect((JSON.parse body).data.logs).to.have.length 1
      expect((JSON.parse body).data.logs[0].message).to.be.equal "#{identifier} #{TESTLOG}"

      done()


beforeTests()

runTests()
