 
     queue = [
 
-      ->
+      (next) ->
         # expecting team to be created
         options =
           body              :

Bongo                                   = require 'bongo'
koding                                  = require './../bongo'

{ daisy }                               = Bongo
{ expect }                              = require 'chai'
{ Relationship }                        = require 'jraphical'
{ generateUrl
  generateRandomEmail
  generateRandomString }                = require '../../../testhelper'
{ generateRegisterRequestParams }       = require '../../../testhelper/handler/registerhelper'

{ generateCreateTeamRequestParams
  generateGetTeamMembersRequestParams } = require '../../../testhelper/handler/teamhelper'

request                                 = require 'request'
querystring                             = require 'querystring'

JGroup                                  = null
JInvitation                             = null


# here we have actual tests
runTests = -> describe 'server.handlers.getteammembers', ->

  beforeEach (done) ->

    # including models before each test case, requiring them outside of
    # tests suite is causing undefined errors
    { JGroup
      JInvitation } = koding.models

    done()


  it 'should send HTTP 404 if group does not exist', (done) ->

    getTeamMembersRequestParams = generateGetTeamMembersRequestParams
      groupSlug : 'someInvalidGroup'

    request.post getTeamMembersRequestParams, (err, res, body) ->
      expect(err)             .to.not.exist
      expect(res.statusCode)  .to.be.equal 404
      expect(body)            .to.be.equal 'no group found'
      done()




        # expecting groupOwner's username to exist in the body
        request.get getTeamMembersRequestParams, (err, res, body) ->
          expect(err).to.not.exist
          expect(res.statusCode).to.be.equal 200
          expect(body).not.to.be.empty
          expect(body).to.contain groupOwnerUsername
          next()

    ]

    async.series queue, done



