@@ -388,18 +388,6 @@ describe('ParticleAPI', () => {
388388 } ) ;
389389
390390 describe ( '.listDevices' , ( ) => {
391- describe ( 'uses effective auth' , ( ) => {
392- afterEach ( ( ) => {
393- sinon . restore ( ) ;
394- } ) ;
395- it ( 'calls this._getEffectiveAuth' , async ( ) => {
396- sinon . stub ( api , '_getEffectiveAuth' ) ;
397- sinon . stub ( api , 'get' ) ; // don't actually call the real method
398- await api . listDevices ( props ) ;
399- expect ( api . _getEffectiveAuth ) . to . have . property ( 'callCount' , 1 ) ;
400- } ) ;
401- } ) ;
402-
403391 describe ( 'user scope' , ( ) => {
404392 it ( 'generates request' , ( ) => {
405393 return api . listDevices ( props ) . then ( ( results ) => {
@@ -2648,13 +2636,15 @@ describe('ParticleAPI', () => {
26482636 contextResult = { def : 456 } ;
26492637 result = 'fake-result' ;
26502638 api . _buildContext = sinon . stub ( ) . returns ( contextResult ) ;
2639+ api . _getEffectiveAuth = sinon . stub ( ) . returns ( auth ) ;
26512640 } ) ;
26522641
26532642 afterEach ( ( ) => {
26542643 expect ( api . _buildContext ) . to . have . been . calledWith ( context ) ;
2644+ expect ( api . _getEffectiveAuth ) . to . have . been . calledWith ( auth ) ;
26552645 } ) ;
26562646
2657- it ( 'calls _buildContext from get' , ( ) => {
2647+ it ( 'calls _buildContext and _getEffectiveAuth from get' , ( ) => {
26582648 api . agent . get = sinon . stub ( ) . returns ( result ) ;
26592649 const options = { uri, auth, headers, query, context } ;
26602650 const res = api . get ( options ) ;
@@ -2668,7 +2658,7 @@ describe('ParticleAPI', () => {
26682658 } ) ;
26692659 } ) ;
26702660
2671- it ( 'calls _buildContext from head' , ( ) => {
2661+ it ( 'calls _buildContext and _getEffectiveAuth from head' , ( ) => {
26722662 api . agent . head = sinon . stub ( ) . returns ( result ) ;
26732663 const options = { uri, auth, headers, query, context } ;
26742664 const res = api . head ( options ) ;
@@ -2682,7 +2672,7 @@ describe('ParticleAPI', () => {
26822672 } ) ;
26832673 } ) ;
26842674
2685- it ( 'calls _buildContext from post' , ( ) => {
2675+ it ( 'calls _buildContext and _getEffectiveAuth from post' , ( ) => {
26862676 api . agent . post = sinon . stub ( ) . returns ( result ) ;
26872677 const options = { uri, auth, headers, data, context } ;
26882678 const res = api . post ( options ) ;
@@ -2696,7 +2686,7 @@ describe('ParticleAPI', () => {
26962686 } ) ;
26972687 } ) ;
26982688
2699- it ( 'calls _buildContext from put' , ( ) => {
2689+ it ( 'calls _buildContext and _getEffectiveAuth from put' , ( ) => {
27002690 api . agent . put = sinon . stub ( ) . returns ( result ) ;
27012691 const options = { uri, auth, headers, data, context } ;
27022692 const res = api . put ( options ) ;
@@ -2710,7 +2700,7 @@ describe('ParticleAPI', () => {
27102700 } ) ;
27112701 } ) ;
27122702
2713- it ( 'calls _buildContext from delete' , ( ) => {
2703+ it ( 'calls _buildContext and _getEffectiveAuth from delete' , ( ) => {
27142704 api . agent . delete = sinon . stub ( ) . returns ( result ) ;
27152705 const options = { uri, auth, headers, data, context } ;
27162706 const res = api . delete ( options ) ;
@@ -2724,10 +2714,10 @@ describe('ParticleAPI', () => {
27242714 } ) ;
27252715 } ) ;
27262716
2727- it ( 'calls _buildContext from request' , ( ) => {
2717+ it ( 'calls _buildContext and _getEffectiveAuth from request' , ( ) => {
27282718 api . agent . request = sinon . stub ( ) . returns ( result ) ;
2729- api . request ( { context } ) . should . eql ( result ) ;
2730- expect ( api . agent . request ) . to . have . been . calledWith ( { context :contextResult } ) ;
2719+ api . request ( { context, auth } ) . should . eql ( result ) ;
2720+ expect ( api . agent . request ) . to . have . been . calledWith ( { context :contextResult , auth } ) ;
27312721 } ) ;
27322722 } ) ;
27332723 } ) ;
0 commit comments