@@ -7,6 +7,8 @@ var u = common.u;
77
88var Account = require ( '../lib/resource/Account' ) ;
99var Group = require ( '../lib/resource/Group' ) ;
10+ var Organization = require ( '../lib/resource/Organization' ) ;
11+ var OrganizationAccountStoreMapping = require ( '../lib/resource/OrganizationAccountStoreMapping' ) ;
1012var Tenant = require ( '../lib/resource/Tenant' ) ;
1113var Provider = require ( '../lib/resource/Provider' ) ;
1214var Directory = require ( '../lib/resource/Directory' ) ;
@@ -285,7 +287,7 @@ describe('Resources: ', function () {
285287 dirObj = { provider : { href : providerObj . href } } ;
286288 app = new Directory ( dirObj , dataStore ) ;
287289
288- nock ( u . BASE_URL ) . get ( u . v1 ( providerObj . href ) ) . reply ( 200 , providerObj ) ;
290+ nock ( u . BASE_URL ) . get ( providerObj . href ) . reply ( 200 , providerObj ) ;
289291
290292 var args = [ ] ;
291293 if ( data ) {
@@ -326,7 +328,83 @@ describe('Resources: ', function () {
326328
327329 it ( 'should call cb without options' , function ( ) {
328330 cbSpy . should . have . been . calledOnce ;
329- cbSpy . should . have . been . calledWith ( undefined , undefined ) ;
331+ cbSpy . should . have . been . calledWith ( ) ;
332+ } ) ;
333+ } ) ;
334+ } ) ;
335+
336+ describe ( 'get organizations' , function ( ) {
337+ describe ( 'if organizations href are set' , function ( ) {
338+ var opt = { } ;
339+
340+ var getResourceStub ;
341+ var sandbox = sinon . sandbox . create ( ) ;
342+ var app = { organizationMappings : { href : 'boom!' } } ;
343+ var directory = new Directory ( app , dataStore ) ;
344+ var cbSpy = sandbox . spy ( ) ;
345+
346+ before ( function ( ) {
347+ getResourceStub = sandbox . stub ( dataStore , 'getResource' , function ( href , options , ctor , cb ) {
348+ cb ( ) ;
349+ } ) ;
350+
351+ directory . getOrganizations ( cbSpy ) ;
352+ directory . getOrganizations ( opt , cbSpy ) ;
353+ } ) ;
354+
355+ after ( function ( ) {
356+ sandbox . restore ( ) ;
357+ } ) ;
358+
359+ it ( 'should get organizations' , function ( ) {
360+ cbSpy . should . have . been . calledTwice ;
361+ getResourceStub . should . have . been . calledTwice ;
362+
363+ getResourceStub . should . have . been . calledWith (
364+ app . organizations . href , null , Organization , cbSpy
365+ ) ;
366+
367+ getResourceStub . should . have . been . calledWith (
368+ app . organizations . href , opt , Organization , cbSpy
369+ ) ;
370+ } ) ;
371+ } ) ;
372+ } ) ;
373+
374+ describe ( 'get organization mappings' , function ( ) {
375+ describe ( 'if organizationMappings href are set' , function ( ) {
376+ var opt = { } ;
377+
378+ var getResourceStub ;
379+ var sandbox = sinon . sandbox . create ( ) ;
380+ var app = { organizationMappings : { href : 'boom!' } } ;
381+ var directory = new Directory ( app , dataStore ) ;
382+ var cbSpy = sandbox . spy ( ) ;
383+
384+ before ( function ( ) {
385+ getResourceStub = sandbox . stub ( dataStore , 'getResource' , function ( href , options , ctor , cb ) {
386+ cb ( ) ;
387+ } ) ;
388+
389+ directory . getOrganizationMappings ( cbSpy ) ;
390+ directory . getOrganizationMappings ( opt , cbSpy ) ;
391+ } ) ;
392+
393+ after ( function ( ) {
394+ sandbox . restore ( ) ;
395+ } ) ;
396+
397+ it ( 'should get organization mappings' , function ( ) {
398+ cbSpy . should . have . been . calledTwice ;
399+ getResourceStub . should . have . been . calledTwice ;
400+
401+ getResourceStub . should . have . been . calledWith (
402+ app . organizationMappings . href , null , OrganizationAccountStoreMapping , cbSpy
403+ ) ;
404+
405+ getResourceStub . should . have . been . calledWith (
406+ app . organizationMappings . href , opt , OrganizationAccountStoreMapping , cbSpy
407+ ) ;
330408 } ) ;
331409 } ) ;
332410 } ) ;
0 commit comments