Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80517 views
1
/*!
2
* unique-id <https://github.com/jonschlinkert/unique-id>
3
*
4
* Copyright (c) 2014 Jon Schlinkert, contributors.
5
* Licensed under the MIT License
6
*/
7
8
'use strict';
9
10
var assert = require('assert');
11
var uniqueId = require('./');
12
13
describe('uniqueId', function () {
14
it('should generate a unique id', function () {
15
for(var i = 1; i < 25; i++) {
16
assert.equal(uniqueId(), i);
17
}
18
});
19
20
it('should generate a unique id with a prefix:', function () {
21
uniqueId.reset();
22
23
for(var i = 1; i < 25; i++) {
24
assert.equal(uniqueId({prefix: 'apple_'}), 'apple_' + i);
25
}
26
});
27
28
it('should generate a unique id with a suffix:', function () {
29
uniqueId.reset();
30
31
for(var i = 1; i < 25; i++) {
32
assert.equal(uniqueId({suffix: '_orange'}), i + '_orange');
33
}
34
});
35
36
it('should generate a unique id using the given multiplier:', function () {
37
uniqueId.reset();
38
39
for(var i = 1; i < 25; i++) {
40
assert.equal(uniqueId({multiplier: 3}), i * 3);
41
}
42
});
43
});
44