   config: { team: { id: '48' } }
   version: '1.0'
 
-testJSON = ->
+testJSON = (id = ITEM_ID)->
   msg:"impression"
   id:2
   client:

  domain:
    id: DOMAIN_ID
  item:
    id: ITEM_ID
    title:"muuh"
    url:"google.de"
    created: 42

        expect(responseObject.team.id).toEqual(OUR_TEAM_ID)

    it 'saves the category of an item appropriately', ->
      helper.send string(testJSON()), ->
        expect(itemStorage[DOMAIN_ID][ITEM_ID].category).toEqual CATEGORY_ID

  describe 'feedback messages', ->

    beforeEach ->
      # we need an item in our db
      helper.sendAndExpect string(testJSON()), (responseObject) -> #nothing

    it 'increases the recommends attribute of the item appropriately', ->
      helper.send string(feedbackJSON()), ->
        expect(itemStorage[DOMAIN_ID][ITEM_ID].recommends[TARGET_ID].count).toEqual 1

    it 'sets the id of the item appropriately', ->
      helper.send string(feedbackJSON()), ->
        expect(itemStorage[DOMAIN_ID][ITEM_ID].recommends[TARGET_ID].id).toEqual TARGET_ID

    it 'responds with the recommended item if the source item is requested', ->
      helper.sendAndExpect string(testJSON()), (response) ->
        expect(_.select(response.items, (item) -> item.id == TARGET_ID).length).toEqual 1

  describe 'put on quite some load', ->

    for i in [1..20]
      helper.send string(testJSON(i)), -> #nothing

    it 'responds with the amount of items specified in the limit parameter', ->
      helper.sendAndExpect string(testJSON()), (response) ->
        expect(response.items.length).toEqual LIMIT

    it 'responds with a well formed array of item ids', ->
      helper.sendAndExpect string(testJSON()), (response) ->
        _.each response.items, (item) ->
          # looks simple but checks for the existance of the id attribute and
          # for the numericality of the ids
          expect(item.id).toBeGreaterThan 0

runs -> helper.stopServer()
