const assert = require('assert')
const Milkcocoa = require('../lib/node')

var milkcocoa = new Milkcocoa({appId: 'demo', uuid: 'uuid1', apiKey: 'demo'})

describe('milkcocoa', function () {
  it('getAppId', function () {
    assert.equal('demo', milkcocoa.getAppId())
  })

  describe('datastore', function () {
    describe('history', function () {
      this.timeout(3000)

      it('no option', function (done) {
        var ds = milkcocoa.dataStore('demo', {datatype: 'json'})

        ds.history({}, function (err, messages) {
          assert.equal(null, err)
          assert.equal(true, messages.length > 0)
          done()
        })
      })

      it('ts', function (done) {
        var ds = milkcocoa.dataStore('demo', {datatype: 'json'})

        ds.history({ts: 1493027628099, limit: 2}, function (err, messages) {
          console.log(err, messages)
          assert.equal(null, err)
          assert.equal(true, messages.length === 2)
          done()
        })
      })

      it('cache', function (done) {
        var ds = milkcocoa.dataStore('demo', {datatype: 'json'})

        ds.history({ts: 1493027628099, limit: 2, useCache: true}, function (err, messages) {
          ds.history({ts: 1493027628099, limit: 2, useCache: true}, function (err, messages) {
            console.log(err, messages)
            assert.equal(null, err)
            assert.equal(true, messages.length === 2)
            assert.equal(true, messages[0].hasOwnProperty('value'))
            done()
          })
        })
      })
    })

    describe('send', function () {
      this.timeout(3000)

      it('success to send data', function (done) {
        var ds = milkcocoa.dataStore('topic', {datatype: 'json'})

        ds.on('send', function (data) {
          assert.deepEqual({value: {message: 'Hello'}}, data)
          done()
        })
        ds.send({message: 'Hello'})
      })
    })
  })
})

@@ -1157,32 +1157,33 @@
 %7D, function (err
+1
 , messages) %7B%0A  
@@ -1168,32 +1168,33 @@
  (err1, messages
+1
 ) %7B%0A          ds
@@ -1254,32 +1254,33 @@
 %7D, function (err
+2
 , messages) %7B%0A  
@@ -1265,32 +1265,33 @@
  (err2, messages
+2
 ) %7B%0A            
@@ -1297,32 +1297,33 @@
  console.log(err
+2
 , messages)%0A    
@@ -1308,32 +1308,33 @@
 g(err2, messages
+2
 )%0A            as
@@ -1345,32 +1345,33 @@
 .equal(null, err
+2
 )%0A            as
@@ -1387,32 +1387,33 @@
 l(true, messages
+2
 .length === 2)%0A 
@@ -1450,16 +1450,17 @@
 messages
+2
 %5B0%5D.hasO

Fix lint error at test/index.js