1.2.5 • Published 8 years ago

meshblu-test-server v1.2.5

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

meshblu-test-server

A helper for spinning up a meshblu-server for your tests

Example

const MeshbluServer = require('meshblu-test-server')
const MeshbluHttp = require('meshblu-http')

describe('your application', function() {
  before("start meshblu", function(done) {
    this.meshbluServer = new MeshbluServer()
    this.meshbluConfig = this.meshbluServer.getConfig()

    this.meshbluServer.start(done)
  })

  after("stop meshblu", function(done) {
    this.meshbluServer.destroy(done)
  })
  
  it('should be a valid meshblu server now', function(done) {
    const meshblu = new MeshbluHttp(this.meshbluConfig)
    meshblu.register({ type: 'test-device' }, (error, device) {
      if (error) return done(error)
      expect(device.uuid).to.exist
      done()
    })
  })
})

Sinon

If you use sinon.useFakeTimers, you need to whitelist the functions that are mocked out. This is because mongojs uses setTimeout a bunch under the hood and stopping time causes it to just never respond. Related docs: http://sinonjs.org/releases/v3.2.1/fake-timers/

const now = Date.now()
sinon.useFakeTimers({ now, toFake: ['Date'] })  // now is optional
moment().utc().format()  // moment should work as expected. AFAIK, moment only uses Date

Travis

In order for the server to work in travis, you'll need to add the following to your .travis.yml

services:
- redis
- mongodb
1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago