Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 58 59 60 61 62 63 64 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x | import hashString from './hash-string';
import {expect} from 'chai';
describe('hash-string', function() {
it('creates for the same string ' +
'and seed the same number', async function() {
const string = 'TEST';
const seed = 12;
const actual1 = await hashString(string, seed);
const actual2 = await hashString(string, seed);
expect(actual1).to.be.eql(actual2);
});
it('creates different number for ' +
'same string but different seed', async function() {
const string = 'TEST';
const seed1 = 12;
const seed2 = 23;
const actual1 = await hashString(string, seed1);
const actual2 = await hashString(string, seed2);
expect(actual1).to.not.be.eql(actual2);
});
it('creates different numbers ' +
'for different strings but same seed', async function() {
const string1 = 'TEST';
const string2 = 'OTHER';
const seed = 1;
const actual1 = await hashString(string1, seed);
const actual2 = await hashString(string2, seed);
expect(actual1).to.not.be.eql(actual2);
});
it('creates different numbers for different ' +
'string and seeds', async function() {
const string1 = 'TEST';
const string2 = 'OTHER';
const seed1 = 1;
const seed2 = 14;
const actual1 = await hashString(string1, seed1);
const actual2 = await hashString(string2, seed2);
expect(actual1).to.not.be.eql(actual2);
});
it('produces same numbers as expected', async function() {
const strings = ['TEST', 'OTHER', 'DIFFERENT', 'STRING'];
const seeds = [0, 4, 12, 14];
const expectedValue = [
7662275108988672,
325964699590494,
6602764949475403,
7900079600016987,
];
for (let i = 0; i < strings.length; i++) {
expect(await hashString(strings[i], seeds[i])).to.equal(expectedValue[i]);
}
});
});
|