Skip to content

Commit 8cfbc89

Browse files
author
Joe Goggins
committed
Adds test to validate EventStream connect passes on http headers
1 parent fd847f9 commit 8cfbc89

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

test/EventStream.spec.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { sinon, expect } from './test-setup';
22
import http from 'http';
33
import { EventEmitter } from 'events';
4-
54
import EventStream from '../src/EventStream';
65

76
describe('EventStream', () => {
@@ -42,7 +41,10 @@ describe('EventStream', () => {
4241
return fakeRequest;
4342
});
4443

45-
const eventStream = new EventStream('http://hostname:8080/path', 'token');
44+
const fakeToolName = 'fake';
45+
const fakeToolVersion = '1.2.3';
46+
const headers = { 'X-Particle-Tool': `${fakeToolName}@${fakeToolVersion}` };
47+
const eventStream = new EventStream('http://hostname:8080/path', 'token', { headers });
4648

4749
return eventStream.connect().then(() => {
4850
expect(http.request).to.have.been.calledWith({
@@ -51,7 +53,8 @@ describe('EventStream', () => {
5153
path: '/path?access_token=token',
5254
method: 'get',
5355
port: 8080,
54-
mode: 'prefer-streaming'
56+
mode: 'prefer-streaming',
57+
headers
5558
});
5659
});
5760
});

test/Particle.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ describe('ParticleAPI', () => {
929929
describe('.getEventStream', () => {
930930
before(() => {
931931
sinon.stub(EventStream.prototype, 'connect').callsFake(function connect(){
932-
return Promise.resolve({ uri: this.uri });
932+
return Promise.resolve({ uri: this.uri, options: this.options });
933933
});
934934
});
935935

0 commit comments

Comments
 (0)