-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.js
More file actions
57 lines (48 loc) · 1.89 KB
/
test.js
File metadata and controls
57 lines (48 loc) · 1.89 KB
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
53
54
55
56
57
'use strict';
var expect = require('chai').expect;
var ss = require('./');
describe('seededshuffle', function() {
var array = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
it('should shuffle and return a new array same size with a string seed', function(done) {
var shuff = ss.shuffle(array,"Example seed",true);
expect(shuff).to.deep.not.equal(array);
expect(shuff).to.have.length(array.length);
done();
});
it('should shuffle and unshuffle returning same array with string seed', function(done) {
var seed = "Hello world";
var shuff = ss.shuffle(array,seed,true);
var ushuff = ss.unshuffle(shuff,seed,true);
expect(ushuff).to.deep.equal(array);
expect(ushuff).to.have.length(array.length);
done();
});
it('should shuffle and return a new array same size with a number', function(done) {
var shuff = ss.shuffle(array,701,true);
expect(shuff).to.deep.not.equal(array);
expect(shuff).to.have.length(array.length);
done();
});
it('should shuffle and unshuffle returning same array with number seed', function(done) {
var seed = 25;
var shuff = ss.shuffle(array,seed,true);
var ushuff = ss.unshuffle(shuff,seed,true);
expect(ushuff).to.deep.equal(array);
expect(ushuff).to.have.length(array.length);
done();
});
it('should shuffle and return a new array same size with a float', function(done) {
var shuff = ss.shuffle(array,7.1,true);
expect(shuff).to.deep.not.equal(array);
expect(shuff).to.have.length(array.length);
done();
});
it('should shuffle and unshuffle returning same array with float seed', function(done) {
var seed = 2.5;
var shuff = ss.shuffle(array,seed,true);
var ushuff = ss.unshuffle(shuff,seed,true);
expect(ushuff).to.deep.equal(array);
expect(ushuff).to.have.length(array.length);
done();
});
});