-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'af34614d68f4de6c9f05166bad69a9922885817d'
- Loading branch information
Showing
2 changed files
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
var should = require('should'); | ||
var should = require('should/as-function'), | ||
Pipedrive = require('./../..'), | ||
blueprint = require('./../../lib/blueprint'); | ||
|
||
describe('client module', function() { | ||
describe('client module', function () { | ||
|
||
it('should expose some of the main object types', function() { | ||
var Pipedrive = require('./../..'), | ||
pipedrive = new Pipedrive.Client('apitoken'), | ||
blueprint = require('./../../lib/blueprint'); | ||
beforeEach(function () { | ||
client = new Pipedrive.Client('apitoken'); | ||
strictClient = new Pipedrive.Client('apitoken', {strictMode: true}); | ||
}); | ||
|
||
it('should expose main API objects', function () { | ||
should(client.Activities).be.an.Object(); | ||
should(client.Deals).be.an.Object(); | ||
|
||
// iterate through all top level objects which should be exposed, e.g. pipedrive.Deals, ... | ||
blueprint.apiObjects.forEach(function(obj) { | ||
should(pipedrive[obj.substr(0,1).toUpperCase() + obj.substr(1)]).be.an.Object(); | ||
// iterate through all | ||
blueprint.apiObjects.forEach(function (obj) { | ||
should(client[obj.substr(0, 1).toUpperCase() + obj.substr(1)]).be.an.Object(); | ||
}); | ||
}); | ||
|
||
it('should expose .on() listener in strict mode', function() { | ||
var Pipedrive = require('./../..'), | ||
pipedrive = new Pipedrive.Client('apitoken', { strictMode: true }); | ||
describe('client.on()', function () { | ||
it('should be defined in strict mode', function () { | ||
should(strictClient.on).be.a.Function(); | ||
}); | ||
|
||
should(pipedrive.on).be.a.Function(); | ||
it('should not be defined in regular mode', function () { | ||
should(client.on).be.a.Undefined(); | ||
}); | ||
}); | ||
|
||
it('client.getAll() should throw error if non-existant resource is requested', function (done) { | ||
client.getAll('bananas', function (error) { | ||
should(error.message).equal('bananas is not supported object type for getAll()'); | ||
return done(); | ||
}); | ||
}); | ||
}); |