forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (32 loc) · 736 Bytes
/
Copy pathindex.js
File metadata and controls
35 lines (32 loc) · 736 Bytes
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
var test = require('../util/test')(__filename);
var random = require('../../packages/array-random');
test('picks array values at random', function(t) {
t.plan(1);
var arr = [1, 2, 3, 4, 5];
var randomChoice = random(arr);
t.notEqual(arr.indexOf(randomChoice), -1);
t.end();
});
test('picks sole element when array is of unity length', function(t) {
t.plan(1);
var arr = [1];
var randomChoice = random(arr);
t.equal(randomChoice, 1);
t.end();
});
test('non-array arguments throw', function(t) {
t.plan(4);
t.throws(function() {
random({});
});
t.throws(function() {
random(undefined);
});
t.throws(function() {
random(null);
});
t.throws(function() {
random();
});
t.end();
});