Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
typerandom committed Jan 6, 2016
1 parent 399d55a commit 7292db4
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions test/sp.resource.directory_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var u = common.u;

var Account = require('../lib/resource/Account');
var Group = require('../lib/resource/Group');
var Organization = require('../lib/resource/Organization');
var OrganizationAccountStoreMapping = require('../lib/resource/OrganizationAccountStoreMapping');
var Tenant = require('../lib/resource/Tenant');
var Provider = require('../lib/resource/Provider');
var Directory = require('../lib/resource/Directory');
Expand Down Expand Up @@ -285,7 +287,7 @@ describe('Resources: ', function () {
dirObj = {provider: {href: providerObj.href}};
app = new Directory(dirObj, dataStore);

nock(u.BASE_URL).get(u.v1(providerObj.href)).reply(200, providerObj);
nock(u.BASE_URL).get(providerObj.href).reply(200, providerObj);

var args = [];
if (data) {
Expand Down Expand Up @@ -326,7 +328,7 @@ describe('Resources: ', function () {

it('should call cb without options', function () {
cbSpy.should.have.been.calledOnce;
cbSpy.should.have.been.calledWith(undefined, undefined);
cbSpy.should.have.been.calledWith();
});
});
});
Expand Down Expand Up @@ -361,10 +363,48 @@ describe('Resources: ', function () {

// call without optional param
getResourceStub.should.have.been
.calledWith(app.organizations.href, null, Group, cbSpy);
.calledWith(app.organizations.href, null, Organization, cbSpy);
// call with optional param
getResourceStub.should.have.been
.calledWith(app.organizations.href, opt, Group, cbSpy);
.calledWith(app.organizations.href, opt, Organization, cbSpy);
});
});
});

describe('get organization mappings', function () {
describe('if organizationMappings href are set', function () {
var sandbox, directory, getResourceStub, cbSpy, app, opt;

before(function () {
sandbox = sinon.sandbox.create();
app = {organizationMappings: {href: 'boom!'}};
opt = {};
directory = new Directory(app, dataStore);
getResourceStub = sandbox.stub(dataStore, 'getResource', function (href, options, ctor, cb) {
cb();
});
cbSpy = sandbox.spy();

directory.getOrganizationMappings(cbSpy);
directory.getOrganizationMappings(opt, cbSpy);
});

after(function () {
sandbox.restore();
});

it('should get organization mappingss', function () {
/* jshint -W030 */
getResourceStub.should.have.been.calledTwice;
cbSpy.should.have.been.calledTwice;
/* jshint +W030 */

// call without optional param
getResourceStub.should.have.been
.calledWith(app.organizationMappings.href, null, OrganizationAccountStoreMapping, cbSpy);
// call with optional param
getResourceStub.should.have.been
.calledWith(app.organizationMappings.href, opt, OrganizationAccountStoreMapping, cbSpy);
});
});
});
Expand Down

0 comments on commit 7292db4

Please sign in to comment.