       group         = generateRandomString()
       groupData     = {}
       options       = { context : { group }, createGroup : yes, groupData }
-      expectedError = 'api usage is not enabled for this group'
+      expectedError = 'API usage is not enabled for this group.'
 
       withConvertedUser options, ({ client, account }) ->
 

  generateRandomString
  checkBongoConnectivity } = require '../../../testhelper'

JApiToken = require './apitoken'

# making sure we have db connection before tests

          done()


    describe 'when request is valid', ->

      it 'should be able to create api token with valid request', (done) ->

        group     = generateRandomString()
        groupData = { isApiEnabled : yes }
        options   = { context : { group }, createGroup : yes, groupData }

        withConvertedUser options, ({ client, account }) ->

          data = { group, account }
          JApiToken.create data, (err, token) ->
            expect(err).to.not.exist
            expect(token.code).to.be.a 'string'
            expect(token.createdAt).to.exist
            expect(token.modifiedAt).to.exist
            expect(token.group).to.equal group
            expect(token.originId).to.deep.equal account._id
            done()


      it 'should fail if group exceeds api token count limit', (done) ->

        group     = generateRandomString()
        groupData = { isApiEnabled : yes }
        options   = { context : { group }, createGroup : yes, groupData }

        withConvertedUser options, ({ client, account }) ->

          data  = { group, account }
          queue = []

          for i in [0...JGroup.API_TOKEN_LIMIT]
            queue.push ->
              JApiToken.create data, (err, token) ->
                expect(err).to.not.exist
                expect(token).to.exist
                queue.next()

          queue.push ->
            expectedError = "You can't have more than #{JGroup.API_TOKEN_LIMIT} api tokens"
            JApiToken.create data, (err, token) ->
              expect(err?.message).to.be.equal expectedError
              expect(token).to.not.exist
              queue.next()

          queue.push -> done()

          daisy queue


  describe '#create$()', ->
