import path from 'path'

import Pouch from '../../src/pouch'

export default {
  createDatabase (done) {
    this.pouch = new Pouch(this.config)
    return this.pouch.addAllViews(done)
  },

  cleanDatabase (done) {
    this.pouch.db.destroy(() => {
      this.pouch = null
      done()
    })
  },

  createParentFolder (pouch, callback) {
    let doc = {
      _id: 'my-folder',
      path: 'my-folder',
      docType: 'folder',
      creationDate: new Date(),
      lastModification: new Date(),
      tags: []
    }
    pouch.db.put(doc, callback)
  },

  createFolder (pouch, i, callback) {
    let id = path.join('my-folder', `folder-${i}`)
    let doc = {
      _id: id,
      path: id,
      docType: 'folder',
      creationDate: new Date(),
      lastModification: new Date(),
      tags: [],
      remote: {
        _id: `123456789${i}`
      }
    }
    pouch.db.put(doc, callback)
  },

  createFile (pouch, i, callback) {
    let id = path.join('my-folder', `file-${i}`)
    let doc = {
      _id: id,
      path: id,
      docType: 'file',
      checksum: `111111111111111111111111111111111111111${i}`,
      creationDate: new Date(),
      lastModification: new Date(),
      tags: [],
      remote: {
        _id: `1234567890${i}`
      }
    }
    pouch.db.put(doc, callback)
  }
}

@@ -837,24 +837,84 @@
 456789$%7Bi%7D%60%0A
+      %7D,%0A      sides: %7B%0A        local: 1,%0A        remote: 1%0A
       %7D%0A    
@@ -1297,24 +1297,84 @@
 567890$%7Bi%7D%60%0A
+      %7D,%0A      sides: %7B%0A        local: 1,%0A        remote: 1%0A
       %7D%0A    

Make sure file-* and folder-* have sides info