particle-api-js 10.3.0 → 10.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +23 -21
- package/CHANGELOG.md +8 -0
- package/EventStream-e2e-browser.html +7 -7
- package/EventStream-e2e-node.js +14 -14
- package/dist/particle.min.js +1 -1
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +3448 -875
- package/karma.conf.js +59 -59
- package/package.json +1 -1
- package/src/Agent.js +387 -363
- package/src/Client.js +162 -162
- package/src/Defaults.js +5 -5
- package/src/EventStream.js +254 -253
- package/src/Library.js +21 -21
- package/src/Particle.js +2685 -2649
- package/test/.eslintrc +5 -5
- package/test/Agent.integration.js +14 -14
- package/test/Agent.spec.js +495 -495
- package/test/Client.spec.js +203 -203
- package/test/Defaults.spec.js +20 -20
- package/test/EventStream.spec.js +231 -231
- package/test/FakeAgent.js +18 -18
- package/test/Library.spec.js +29 -29
- package/test/Particle.integration.js +29 -29
- package/test/Particle.spec.js +3127 -3127
- package/test/fixtures/index.js +7 -7
- package/test/support/FixtureHttpServer.js +16 -16
- package/test/test-setup.js +3 -3
- package/tsconfig.json +3 -1
- package/webpack.config.js +39 -39
|
@@ -2,36 +2,36 @@ const { expect, sinon } = require('./test-setup');
|
|
|
2
2
|
const Particle = require('../src/Particle');
|
|
3
3
|
|
|
4
4
|
describe('Particle', () => {
|
|
5
|
-
|
|
5
|
+
let api;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
api = new Particle({ baseUrl: '' });
|
|
9
|
+
});
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
describe('downloadFile', () => {
|
|
12
|
+
it('download the file', () => {
|
|
13
|
+
const uri = 'https://binaries.particle.io/libraries/neopixel/neopixel-0.0.10.tar.gz';
|
|
14
|
+
const fileSize = 25505;
|
|
15
|
+
return api.downloadFile({ uri })
|
|
16
|
+
.then(contents => {
|
|
17
|
+
expect(contents.length || contents.byteLength).to.equal(fileSize);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
describe('context', () => {
|
|
23
|
+
it('adds headers for the context', () => {
|
|
24
|
+
api.setContext('tool', { name:'cli', version:'1.2.3' });
|
|
25
|
+
api.setContext('project', { name:'blinky', version:'0.0.1' });
|
|
26
|
+
api.agent._promiseResponse = sinon.stub().resolves();
|
|
27
|
+
return api.flashTinker('deviceID', 'auth').then(() => {
|
|
28
|
+
expect(api.agent._promiseResponse).to.have.been.calledOnce;
|
|
29
|
+
const req = api.agent._promiseResponse.firstCall.args[0];
|
|
30
|
+
const options = req[1];
|
|
31
|
+
expect(req).to.be.ok;
|
|
32
|
+
expect(options.headers).to.have.property('X-Particle-Tool').eql('cli@1.2.3');
|
|
33
|
+
expect(options.headers).to.have.property('X-Particle-Project').eql('blinky; version=0.0.1');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
37
|
});
|