joyent-portal/packages/rnd-id/test/index.js

18 lines
408 B
JavaScript
Raw Normal View History

2017-06-16 23:46:36 +03:00
const test = require('ava');
const uniq = require('lodash.uniq');
2017-08-04 01:56:57 +03:00
const rndId = require('../src');
2017-06-16 23:46:36 +03:00
test('should generate strings', t => {
t.truthy(
[rndId(), rndId(), rndId(), rndId()].every(
s => typeof s === 'string' && s.length
)
);
});
test('should generate unique strings', t => {
const arr = [rndId(), rndId(), rndId(), rndId()];
t.deepEqual(uniq(arr).length, arr.length);
});