Skip to content

Commit 0305f4f

Browse files
author
Joe Goggins
committed
Renames _getEffectiveAuth to _getActiveAuthToken for clarity
1 parent e2e3f7f commit 0305f4f

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/Particle.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,8 +2117,8 @@ class Particle {
21172117
* @private
21182118
* @returns {String|undefined} a Particle auth token or undefined
21192119
*/
2120-
_getEffectiveAuth(auth) {
2121-
return auth || this._defaultAuth
2120+
_getActiveAuthToken(auth) {
2121+
return auth || this._defaultAuth;
21222122
}
21232123
/**
21242124
* API URI to access a device
@@ -2134,37 +2134,37 @@ class Particle {
21342134

21352135
get({ uri, auth, headers, query, context }){
21362136
context = this._buildContext(context);
2137-
auth = this._getEffectiveAuth(auth);
2137+
auth = this._getActiveAuthToken(auth);
21382138
return this.agent.get({ uri, auth, headers, query, context });
21392139
}
21402140

21412141
head({ uri, auth, headers, query, context }){
21422142
context = this._buildContext(context);
2143-
auth = this._getEffectiveAuth(auth);
2143+
auth = this._getActiveAuthToken(auth);
21442144
return this.agent.head({ uri, auth, headers, query, context });
21452145
}
21462146

21472147
post({ uri, auth, headers, data, context }){
21482148
context = this._buildContext(context);
2149-
auth = this._getEffectiveAuth(auth);
2149+
auth = this._getActiveAuthToken(auth);
21502150
return this.agent.post({ uri, auth, headers, data, context });
21512151
}
21522152

21532153
put({ uri, auth, headers, data, context }){
21542154
context = this._buildContext(context);
2155-
auth = this._getEffectiveAuth(auth);
2155+
auth = this._getActiveAuthToken(auth);
21562156
return this.agent.put({ uri, auth, headers, data, context });
21572157
}
21582158

21592159
delete({ uri, auth, headers, data, context }){
21602160
context = this._buildContext(context);
2161-
auth = this._getEffectiveAuth(auth);
2161+
auth = this._getActiveAuthToken(auth);
21622162
return this.agent.delete({ uri, auth, headers, data, context });
21632163
}
21642164

21652165
request(args){
21662166
args.context = this._buildContext(args.context);
2167-
args.auth = this._getEffectiveAuth(args.auth);
2167+
args.auth = this._getActiveAuthToken(args.auth);
21682168
return this.agent.request(args);
21692169
}
21702170

test/Particle.spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,15 +2636,15 @@ describe('ParticleAPI', () => {
26362636
contextResult = { def: 456 };
26372637
result = 'fake-result';
26382638
api._buildContext = sinon.stub().returns(contextResult);
2639-
api._getEffectiveAuth = sinon.stub().returns(auth);
2639+
api._getActiveAuthToken = sinon.stub().returns(auth);
26402640
});
26412641

26422642
afterEach(() => {
26432643
expect(api._buildContext).to.have.been.calledWith(context);
2644-
expect(api._getEffectiveAuth).to.have.been.calledWith(auth);
2644+
expect(api._getActiveAuthToken).to.have.been.calledWith(auth);
26452645
});
26462646

2647-
it('calls _buildContext and _getEffectiveAuth from get', () => {
2647+
it('calls _buildContext and _getActiveAuthToken from get', () => {
26482648
api.agent.get = sinon.stub().returns(result);
26492649
const options = { uri, auth, headers, query, context };
26502650
const res = api.get(options);
@@ -2658,7 +2658,7 @@ describe('ParticleAPI', () => {
26582658
});
26592659
});
26602660

2661-
it('calls _buildContext and _getEffectiveAuth from head', () => {
2661+
it('calls _buildContext and _getActiveAuthToken from head', () => {
26622662
api.agent.head = sinon.stub().returns(result);
26632663
const options = { uri, auth, headers, query, context };
26642664
const res = api.head(options);
@@ -2672,7 +2672,7 @@ describe('ParticleAPI', () => {
26722672
});
26732673
});
26742674

2675-
it('calls _buildContext and _getEffectiveAuth from post', () => {
2675+
it('calls _buildContext and _getActiveAuthToken from post', () => {
26762676
api.agent.post = sinon.stub().returns(result);
26772677
const options = { uri, auth, headers, data, context };
26782678
const res = api.post(options);
@@ -2686,7 +2686,7 @@ describe('ParticleAPI', () => {
26862686
});
26872687
});
26882688

2689-
it('calls _buildContext and _getEffectiveAuth from put', () => {
2689+
it('calls _buildContext and _getActiveAuthToken from put', () => {
26902690
api.agent.put = sinon.stub().returns(result);
26912691
const options = { uri, auth, headers, data, context };
26922692
const res = api.put(options);
@@ -2700,7 +2700,7 @@ describe('ParticleAPI', () => {
27002700
});
27012701
});
27022702

2703-
it('calls _buildContext and _getEffectiveAuth from delete', () => {
2703+
it('calls _buildContext and _getActiveAuthToken from delete', () => {
27042704
api.agent.delete = sinon.stub().returns(result);
27052705
const options = { uri, auth, headers, data, context };
27062706
const res = api.delete(options);
@@ -2714,7 +2714,7 @@ describe('ParticleAPI', () => {
27142714
});
27152715
});
27162716

2717-
it('calls _buildContext and _getEffectiveAuth from request', () => {
2717+
it('calls _buildContext and _getActiveAuthToken from request', () => {
27182718
api.agent.request = sinon.stub().returns(result);
27192719
api.request({ context, auth }).should.eql(result);
27202720
expect(api.agent.request).to.have.been.calledWith({ context:contextResult, auth });
@@ -2749,28 +2749,28 @@ describe('ParticleAPI', () => {
27492749
});
27502750
});
27512751

2752-
describe('_getEffectiveAuth(auth)', () => {
2752+
describe('_getActiveAuthToken(auth)', () => {
27532753
afterEach(() => {
27542754
sinon.restore();
27552755
});
27562756

27572757
it('returns provided value when provided value is truthy', () => {
27582758
const expectedReturnValue = 'pass through';
2759-
expect(api._getEffectiveAuth(expectedReturnValue)).to.eql(expectedReturnValue);
2759+
expect(api._getActiveAuthToken(expectedReturnValue)).to.eql(expectedReturnValue);
27602760
});
27612761

27622762
it('returns value of _defaultAuth when provided value is NOT truthy', () => {
27632763
const providedValue = undefined;
27642764
const expectedReturnValue = 'default auth value';
27652765
api.setDefaultAuth(expectedReturnValue);
2766-
expect(api._getEffectiveAuth(providedValue)).to.eql(expectedReturnValue);
2766+
expect(api._getActiveAuthToken(providedValue)).to.eql(expectedReturnValue);
27672767
});
27682768

27692769
it('returns undefined when both provided value and _defaultAuth are NOT truthy', () => {
27702770
const providedValue = undefined;
27712771
const expectedReturnValue = undefined;
27722772
api.setDefaultAuth(undefined);
2773-
expect(api._getEffectiveAuth(providedValue)).to.eql(expectedReturnValue);
2773+
expect(api._getActiveAuthToken(providedValue)).to.eql(expectedReturnValue);
27742774
});
27752775
});
27762776
});

0 commit comments

Comments
 (0)