hellojs-xiaotian
Version:
A clientside Javascript library for standardizing requests to OAuth2 web services (and OAuth1 - with a shim)
66 lines (34 loc) • 1.3 kB
JavaScript
define([], function() {
var args = hello.utils.args;
describe('utils.args', function() {
it('should accept an object and arguments as first and second parameters and return an object', function() {
var value = args({}, []);
expect(value).to.be.an(Object);
});
it('should map arguments to an object', function() {
var value = args({str: 's', obj: 'o', func: 'f'}, ['String', {}, function() {}]);
expect(value).to.be.an('object');
expect(value.str).to.be.a('string');
expect(value.obj).to.be.an('object');
expect(value.func).to.be.a('function');
});
it('should interpret the order of arguments, so some can be ommited', function() {
var value = args({str: 's', obj: 'o', func: 'f'}, [function() {}]);
expect(value)
.to.be.an('object')
.and.to.not.have.property('str')
.and.to.not.have.property('obj');
expect(value.func).to.be.a('function');
});
it('should decipher whether the first argument is all the arguments represented as an object', function() {
var value = args({str: 's', obj: 'o', func: 'f'}, [{
func: function() {}
}]);
expect(value)
.to.be.an('object')
.and.to.not.have.property('str')
.and.to.not.have.property('obj');
expect(value.func).to.be.a('function');
});
});
});