       expect(keyfinder(true, 'predicate')).to.have.length 0
 
 
-  describe 'keyfinder(object/array, [callback = "function"])', ->
+  describe 'keyfinder(object/array, callback)', ->
+
+    fn = (obj) ->
+      list = []
+      keyfinder obj, (key, val, parent) ->
+        obj =
+          key: key
+          val: val
+          parent: parent
+        list.push obj
+      list
 
     it 'should be able to pass function instead of string as second argument', ->
       expect(-> keyfinder {a: 'aa'}, ->).to.not.throw /error/


keyfinder = require '../lib/index'

describe 'keyfinder module\n', ->

  describe 'keyfinder(object/array, [predicate = "string"])', ->

    it 'find key in single level object', ->
      obj =

        { key: 'b', val: 'bb', parent: 'object' },
        { key: 'c', val: 'cc', parent: 'object' },
      ]

    it 'third argument shoud match the type of the elements parent', ->
      obj =
        object: {
          number: 123
        }
        array: [
          'string'
        ]

      results = keyfinder obj, (key, val, parent) ->
        if key is 'number'
          expect(parent).to.eql 'object'
        if val is 'string'
          expect(parent).to.eql 'array'
