box-view-api
Version:
Box View API, node.js client library
63 lines (55 loc) • 2.58 kB
JavaScript
// Tests for the Box View session API
var API = require('index').SessionAPI;
describe('Box View API: NodeJS API: session', function() {
describe('constructor', function() {
it('should throw an error with no API Token', function() {
framework.throwsError(function() {
new API();
});
});
it('should throw an error if too many params are passed', function() {
framework.throwsError(function() {
new API(framework.boxView.dummyApiKey, 1);
});
});
for (var k in framework.values.invalidParamList) {
it('should throw an error with a '+framework.values.invalidParamList[k].name+' param', function () {
framework.throwsError(function() {
new API(framework.values.invalidParamList[k].value);
});
});
}
it('should NOT throw an error with a non-empty API Token string', function(){
new API(framework.boxView.dummyApiKey);
});
});
describe('instance', function() {
var instance;
function getInstance() {
return instance;
}
before(function () {
instance = new API(framework.boxView.dummyApiKey);
});
it('should have a create function', function() {
framework.assert(typeof instance.create === 'function');
});
describe('.create()', function() {
var dummyCb = function () {};
framework.instanceMethodTests(getInstance, 'create', [
{name: 'a non-blank string document id, and a function callback', args: ['docId', dummyCb]},
{name: 'a non-blank string document id, an options hash, and a function callback', args: ['docId', {}, dummyCb]}
], [
{name: 'no parameters', args: []},
{name: 'a callback only', args: [dummyCb]},
{name: 'a non-blank string document id, no options, no callback', args: ['docId']},
{name: 'a non-blank string document id, an options hash, no callback', args: ['docId', {}]},
{name: 'a non-blank string document id, an options hash, a callback, and a extra parameter', args: ['docId', {}, dummyCb, 'random']},
{name: 'a blank string document id, an options hash, and a function callback', args: ['', {}, dummyCb]},
{name: 'a non-string document id, an options hash, and a function callback', args: [{}, {}, dummyCb]},
{name: 'a non-blank string document id, non-object options, and a function callback', args: ['docId', 'random', dummyCb]},
{name: 'a non-blank string document id, an options hash, and a non function callback', args: ['docId', {}, 'random']}
]);
});
});
});