-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.js
More file actions
38 lines (29 loc) · 829 Bytes
/
strings.js
File metadata and controls
38 lines (29 loc) · 829 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
36
37
38
var Strings = require('../../src/js/utils/strings')
describe('utils strings', function () {
it('string format', function () {
var _ = Strings.format
var str = '{0}-{1}!={2}'
_(str, '3', '4', 2).should.equal('3-4!=2')
})
it('string substitute', function () {
Strings.substitute('{a}!={b}', { a:1, b:2 }).should.equal('1!=2')
})
it('toArray', function () {
var _ = Strings.toArray
var raw = '1,2,3'
_(raw, ',').should.deep.equal(['1', '2', '3'])
raw = '1,2,3'
_(raw).should.deep.equal(['1,2,3'])
raw = [1, 2, 3]
_(raw, ',').should.deep.equal(['1', '2', '3'])
raw = [1, 2, 3]
_(raw).should.deep.equal([1, 2, 3])
})
it('nextUid', function () {
var uid
for(var i=0; i<100; i++) {
uid = Strings.nextUid()
}
uid.should.eql('A02S')
})
})