const assert = require('assert')
const fl     = require('../lib/main')
const data   = require('./data')
const fp     = require('lodash/fp')

describe('flatulence', () => {
  
  describe('#flatten()', () => {
    it('should flatten object', () => {
      const flattened = fl.flatten(data)

      console.log(flattened)
      
      assert.equal(flattened['array[0][1]'], 1)
    })

    it('should use prefix arg if provided', () => {
      const prefix = 'this.is.my.custom.prefix'
      const flattened = fl.flatten(
        { 
          id: 'anid', 
          map: { a:1, b:2, c:3} 
        }, 
        prefix
      )

      console.log(flattened)
      
      assert.equal(flattened[prefix + '.id'], 'anid')
      assert.equal(flattened[prefix + '.map.a'], 1)
    })
  })

  describe('#unflatten()', () => {
    it('should reverse flattened object to an unflattened one', () => {
      const flattened = fl.flatten(data)
      const unflattened = fl.unflatten(flattened)

      assert.deepEqual(data, unflattened)

    })

    it('should reverse flattened object to an unflattened one at a prefix', () => {
      const flattened = fl.flatten(data)
      const unflattened = fl.unflatten(flattened, 'cc')

      assert.deepEqual(data.cc, unflattened)

    })

    it('should produce an unflat array when prefix points at array', () => {
      const flattened = fl.flatten(data)
      const unflattened = fl.unflatten(flattened, 'cc.contract.multiContractSetup')

      console.log('unflattened', unflattened)

      assert.ok(Array.isArray(unflattened))

    })
  })
})
@@ -367,32 +367,330 @@
 %5D'%5D, 1)%0A    %7D)%0A%0A
+    it('should keep empty arrays', () =%3E %7B%0A      const flattened = fl.flatten(%7B%0A        %22name%22: %22Mega Group 2%22,%0A        %22loginId%22: %22admin_mega_merchant_2%22,%0A        %22description%22: %22again, some description here%22,%0A        %22merchantUsers%22: %5B%5D%0A      %7D)%0A%0A      // assert(flattened.merchantUsers)%0A    %7D)%0A%0A
     it('should u

prepare test