Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
test: Add failing test for missing session payload properties (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
bengourley committed Jun 22, 2018
1 parent 43cd92a commit c9dd108
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/sessions/delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,42 @@ describe('session delegate', () => {
notifyReleaseStages: [ 'production' ]
}).startSession({})
})

it('should include the correct app and device payload properties', done => {
class TrackerMock extends Emitter {
start () {
this.emit('summary', [
{ startedAt: '2017-12-12T13:54:00.000Z', sessionsStarted: 123 }
])
}
stop () {}
track () {}
}
const createSessionDelegate = proxyquire('../../lib/sessions', {
'./tracker': TrackerMock,
'request': (opts) => {
const body = JSON.parse(opts.body)
body.sessionCounts.length.should.equal(1)
body.sessionCounts[0].sessionsStarted.should.equal(123)
body.device.should.eql({
hostname: 'test-machine.local'
})
body.app.should.eql({
version: '1.2.3',
releaseStage: 'qa',
type: 'server'
})
done()
}
})
createSessionDelegate({
logger: { info: () => {}, warn: () => {} },
endpoints: { sessions: 'blah' },
notifyReleaseStages: null,
releaseStage: 'qa',
appType: 'server',
appVersion: '1.2.3',
hostname: 'test-machine.local'
}).startSession({})
})
})

0 comments on commit c9dd108

Please sign in to comment.