 
       # expect(pairs.length).to.eq 2
 
-  describe 'searching', ->
-    it 'filterObjects', ->
+  describe 'filterObjects', ->
+    it 'works', ->
       c1 = { id: 1, name: 'Link', affil: 'good' }
       c2 = { id: 2, name: 'Zelda', affil: 'good' }
       c3 = { id: 3, name: 'Gannon', affil: 'bad' }

      #   when 'match'  #  [ 'match', key, val ]
      #     c[fil[1]] == fil[2]

joinComponents = (comps,filters) ->
  filters2 = _.cloneDeep(filters)
  _.forEach _.rest(filters2), (f) ->
    f.unshift [ 'join', 'eid' ]
  joinObjects comps,filters2

joinObjects = (comps,filters,row=[]) ->
  if filters.length == 0

      found4 = filterObjects comps, filter4
      expectArray found4, [c4]

  describe 'joinObjects', ->
    it 'works', ->
      comps = makeZeldaComps()

      charFilter = [
        ['match', 'type', 'character']
      ]
      boxFilter = [
        ['join', 'eid']
        ['match', 'type', 'bbox']
      ]
      heroFilter = [
        ['join', 'eid']
        ['match', 'type', 'tag']
        ['match', 'value', 'hero']
      ]

      found1 = joinObjects comps, [charFilter, boxFilter]
      # console.log "RESULTS:",found1
      expectArray found1, [
        [comps[1], comps[2]]
        [comps[5], comps[6]]
      ]

      found2 = joinObjects comps, [charFilter,boxFilter,heroFilter]
      # console.log "RESULTS 2:",found2
      expectArray found2, [
        [comps[1], comps[2], comps[0]]
      ]

  describe 'expandFilter', ->
    it 'leaves arrays as they are', ->
      expectArray expandFilter([[]]), [[]]
      f2 = [
        ['match','something','interesting']
        ['a','b']
      ]
      expectArray expandFilter(f2), f2

    it 'turns a plain string into a "type matcher"', ->
      expectArray expandFilter('dude'), [['match','type','dude']]
      expectArray expandFilter('character'), [['match','type','character']]

    it 'turns a key:value into a key-value filter', ->
      expectArray expandFilter('hi:there'), [['match','hi','there']]
      expectArray expandFilter('type:dude'), [['match','type','dude']]

    it 'turns a tag:string into a "tag matcher"', ->
      expectArray expandFilter('tag:dude'), [['match','type','tag'],['match','value','dude']]
      expectArray expandFilter('tag:enemy'), [['match','type','tag'],['match','value','enemy']]
    it 'stops expanding', ->
      tagFilter = [['match','type','tag'],['match','value','enemy']]
      expectArray expandFilter('tag:enemy'), tagFilter
      expectArray expandFilter(expandFilter(expandFilter('tag:enemy'))), tagFilter


makeZeldaComps = ->
  [
    { eid: 'e1', type: 'tag', value: 'hero' }
    { eid: 'e1', type: 'character', name: 'Link' }
    { eid: 'e1', type: 'bbox', shape: [1,2,3,4] }
    { eid: 'e1', type: 'inventory', stuff: 'items' }

    { eid: 'e1', type: 'tag', value: 'enemy' }
    { eid: 'e2', type: 'character', name: 'Tektike' }
    { eid: 'e2', type: 'bbox', shape: [3,4,5,6] }
    { eid: 'e2', type: 'digger', status: 'burrowing' }
  ]

filterObjects = (comps,filter) ->
  _.filter comps, (c) ->
