Skip to content

Commit fc70170

Browse files
author
Joe Goggins
committed
Changes constructor option name from defaultAuth to auth
1 parent 7ba3dec commit fc70170

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/Defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export default {
33
clientSecret: 'particle-api',
44
clientId: 'particle-api',
55
tokenDuration: 7776000, // 90 days
6-
defaultAuth: undefined
6+
auth: undefined
77
};

src/Particle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class Particle {
2323
* @param {Object} options Options for this API call Options to be used for all requests (see [Defaults](../src/Defaults.js))
2424
*/
2525
constructor(options = {}){
26-
if (options.defaultAuth) {
27-
this.setDefaultAuth(options.defaultAuth);
26+
if (options.auth) {
27+
this.setDefaultAuth(options.auth);
2828
}
2929

3030
// todo - this seems a bit dangerous - would be better to put all options/context in a contained object

test/Defaults.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Default Particle constructor options', () => {
2323
});
2424

2525
it('includes defaultAuth', () => {
26-
expect(Defaults).to.have.property('defaultAuth');
27-
expect(Defaults.defaultAuth).to.eql(undefined);
26+
expect(Defaults).to.have.property('auth');
27+
expect(Defaults.auth).to.eql(undefined);
2828
});
2929
});

test/Particle.spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ describe('ParticleAPI', () => {
139139

140140
describe('with defaultAuth', () => {
141141
it('calls .setDefaultAuth(defaultAuth) when provided defaultAuth value is truthy', () => {
142+
const fakeAuthToken = 'foo';
142143
sinon.stub(Particle.prototype, 'setDefaultAuth');
143-
api = new Particle({ defaultAuth: 'foo' });
144+
api = new Particle({ auth: fakeAuthToken });
144145
expect(api.setDefaultAuth).to.have.property('callCount', 1);
146+
expect(api.setDefaultAuth.firstCall.args).to.have.lengthOf(1);
147+
expect(api.setDefaultAuth.firstCall.args[0]).to.eql(fakeAuthToken);
145148
});
146149
});
147150
});

0 commit comments

Comments
 (0)