-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
53 lines (36 loc) · 1.25 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var asArray = require('./index.js');
var namespace = require('tessed').namespace;
var test = namespace('as array');
test('returns the array passed in', function (assert) {
var arr = [1,2,3];
assert.deepEqual(asArray(arr), [1,2,3], 'returned array');
});
test('converts single item into array', function (assert) {
var fn = function () {};
assert.deepEqual(asArray(fn), [fn], 'returned array');
});
test('returns empty array with undefined passed in', function (assert) {
assert.deepEqual(asArray(), [], 'empty array');
});
test('converts arguments variable with numbers into array', function (assert) {
return function (end) {
function tester () {
assert.deepEqual(asArray(arguments), [1,2], 'converted to array');
end();
};
tester(1, 2);
};
});
test('converts arguments variable with strings into array', function (assert) {
return function (end) {
function tester () {
assert.deepEqual(asArray(arguments), ['arg1', 'arg2'], 'converted to array');
end();
};
tester('arg1', 'arg2');
};
});
test('pulls the values from an object as the array', function (assert) {
var dataArr = asArray({'0': 'value1', '1': 'value2'}, true);
assert.deepEqual(dataArr, ['value1', 'value2'], 'values as array');
});