2 * function-args-test.js: Tests for `args` method
4 * (C) 2012, Nodejitsu Inc.
9 var assert = require('assert'),
10 path = require('path'),
11 vows = require('vows'),
12 macros = require('./helpers/macros'),
13 utile = require('../');
15 vows.describe('utile/args').addBatch({
17 'the `args` function': {
19 'should be a function': function (_utile) {
20 assert.isFunction(_utile.args);
25 'with no arguments': {
27 'should return an empty object': function (result) {
28 assert.isArray(result);
29 assert.lengthOf(result, 0);
32 'with simple arguments': {
35 return utile.rargs(arguments);
38 'should return an array with three items': function (result) {
39 assert.isArray(result);
40 assert.equal(3, result.length);
41 assert.equal(result[0], 'a');
42 assert.equal(result[1], 'b');
43 assert.equal(result[2], 'c');
46 'with a simple slice': {
49 return utile.rargs(arguments, 1);
52 'should return an array with three items': function (result) {
53 assert.isArray(result);
54 assert.equal(2, result.length);
55 assert.equal(result[0], 'b');
56 assert.equal(result[1], 'c');
61 'with no arguments': {
63 'should return an empty Array': function (result) {
64 assert.isUndefined(result.callback);
65 assert.isArray(result);
66 assert.lengthOf(result, 0);
69 'with simple arguments': {
72 return utile.args(arguments);
73 })('a', 'b', 'c', function () {
77 'should return an array with three items': function (result) {
78 assert.isArray(result);
79 assert.equal(3, result.length);
80 assert.equal(result[0], 'a');
81 assert.equal(result[1], 'b');
82 assert.equal(result[2], 'c');
85 // Ensure that the Array returned
86 // by `utile.args()` enumerates correctly
89 result.forEach(function (item) {
93 assert.equal(length, 3);
95 'should return lookup helpers': function (result) {
96 assert.isArray(result);
97 assert.equal(result.first, 'a');
98 assert.equal(result.last, 'c');
99 assert.isFunction(result.callback);
100 assert.isFunction(result.cb);