11var assert = require ( 'assert' )
22var lolex = require ( 'lolex' )
3- var ulidImport = require ( './dist/ulid.umd.js' )
4- var ulid = ulidImport . factory ( )
3+ var ULID = require ( './dist/ulid.umd.js' )
4+ var ulid = ULID . factory ( )
55
66
77describe ( 'ulid' , function ( ) {
88
99 describe ( 'prng' , function ( ) {
1010
11- var prng = ulidImport . detectPrng ( )
11+ var prng = ULID . detectPrng ( )
1212
1313 it ( 'should produce a number' , function ( ) {
1414 assert . strictEqual ( false , isNaN ( prng ( ) ) )
@@ -24,20 +24,20 @@ describe('ulid', function() {
2424 describe ( 'incremenet base32' , function ( ) {
2525
2626 it ( 'increments correctly' , function ( ) {
27- assert . strictEqual ( 'A109D' , ulidImport . incrementBase32 ( 'A109C' ) )
27+ assert . strictEqual ( 'A109D' , ULID . incrementBase32 ( 'A109C' ) )
2828 } )
2929
3030 it ( 'carries correctly' , function ( ) {
31- assert . strictEqual ( 'A1Z00' , ulidImport . incrementBase32 ( 'A1YZZ' ) )
31+ assert . strictEqual ( 'A1Z00' , ULID . incrementBase32 ( 'A1YZZ' ) )
3232 } )
3333
3434 it ( 'double increments correctly' , function ( ) {
35- assert . strictEqual ( 'A1Z01' , ulidImport . incrementBase32 ( ulidImport . incrementBase32 ( 'A1YZZ' ) ) )
35+ assert . strictEqual ( 'A1Z01' , ULID . incrementBase32 ( ULID . incrementBase32 ( 'A1YZZ' ) ) )
3636 } )
3737
3838 it ( 'throws when it cannot increment' , function ( ) {
3939 assert . throws ( function ( ) {
40- ulidImport . incrementBase32 ( 'ZZZ' )
40+ ULID . incrementBase32 ( 'ZZZ' )
4141 } )
4242 } )
4343
@@ -46,10 +46,10 @@ describe('ulid', function() {
4646 describe ( 'randomChar' , function ( ) {
4747
4848 var sample = { }
49- var prng = ulidImport . detectPrng ( )
49+ var prng = ULID . detectPrng ( )
5050
5151 for ( var x = 0 ; x < 320000 ; x ++ ) {
52- char = String ( ulidImport . randomChar ( prng ) ) // for if it were to ever return undefined
52+ char = String ( ULID . randomChar ( prng ) ) // for if it were to ever return undefined
5353 if ( sample [ char ] === undefined ) {
5454 sample [ char ] = 0
5555 }
@@ -69,46 +69,46 @@ describe('ulid', function() {
6969 describe ( 'encodeTime' , function ( ) {
7070
7171 it ( 'should return expected encoded result' , function ( ) {
72- assert . strictEqual ( '01ARYZ6S41' , ulidImport . encodeTime ( 1469918176385 , 10 ) )
72+ assert . strictEqual ( '01ARYZ6S41' , ULID . encodeTime ( 1469918176385 , 10 ) )
7373 } )
7474
7575 it ( 'should change length properly' , function ( ) {
76- assert . strictEqual ( '0001AS99AA60' , ulidImport . encodeTime ( 1470264322240 , 12 ) )
76+ assert . strictEqual ( '0001AS99AA60' , ULID . encodeTime ( 1470264322240 , 12 ) )
7777 } )
7878
7979 it ( 'should truncate time if not enough length' , function ( ) {
80- assert . strictEqual ( 'AS4Y1E11' , ulidImport . encodeTime ( 1470118279201 , 8 ) )
80+ assert . strictEqual ( 'AS4Y1E11' , ULID . encodeTime ( 1470118279201 , 8 ) )
8181 } )
8282
8383 describe ( 'should throw an error' , function ( ) {
8484
8585 it ( 'if time greater than (2 ^ 48) - 1' , function ( ) {
8686 assert . throws ( function ( ) {
87- ulidImport . encodeTime ( Math . pow ( 2 , 48 ) , 8 )
87+ ULID . encodeTime ( Math . pow ( 2 , 48 ) , 8 )
8888 } , Error )
8989 } )
9090
9191 it ( 'if time is not a number' , function ( ) {
9292 assert . throws ( function ( ) {
93- ulidImport . encodeTime ( 'test' )
93+ ULID . encodeTime ( 'test' )
9494 } , Error )
9595 } )
9696
9797 it ( 'if time is infinity' , function ( ) {
9898 assert . throws ( function ( ) {
99- ulidImport . encodeTime ( Infinity )
99+ ULID . encodeTime ( Infinity )
100100 } , Error )
101101 } )
102102
103103 it ( 'if time is negative' , function ( ) {
104104 assert . throws ( function ( ) {
105- ulidImport . encodeTime ( - 1 )
105+ ULID . encodeTime ( - 1 )
106106 } , Error )
107107 } )
108108
109109 it ( 'if time is a float' , function ( ) {
110110 assert . throws ( function ( ) {
111- ulidImport . encodeTime ( 100.1 )
111+ ULID . encodeTime ( 100.1 )
112112 } , Error )
113113 } )
114114
@@ -118,10 +118,10 @@ describe('ulid', function() {
118118
119119 describe ( 'encodeRandom' , function ( ) {
120120
121- var prng = ulidImport . detectPrng ( )
121+ var prng = ULID . detectPrng ( )
122122
123123 it ( 'should return correct length' , function ( ) {
124- assert . strictEqual ( 12 , ulidImport . encodeRandom ( 12 , prng ) . length )
124+ assert . strictEqual ( 12 , ULID . encodeRandom ( 12 , prng ) . length )
125125 } )
126126
127127 } )
@@ -131,24 +131,24 @@ describe('ulid', function() {
131131 it ( 'should return correct timestamp' , function ( ) {
132132 var timestamp = Date . now ( )
133133 var id = ulid ( timestamp )
134- assert . strictEqual ( timestamp , ulidImport . decodeTime ( id ) )
134+ assert . strictEqual ( timestamp , ULID . decodeTime ( id ) )
135135 } )
136136
137137 it ( 'should accept the maximum allowed timestamp' , function ( ) {
138- assert . strictEqual ( 281474976710655 , ulidImport . decodeTime ( '7ZZZZZZZZZZZZZZZZZZZZZZZZZ' ) )
138+ assert . strictEqual ( 281474976710655 , ULID . decodeTime ( '7ZZZZZZZZZZZZZZZZZZZZZZZZZ' ) )
139139 } )
140140
141141 describe ( 'should reject' , function ( ) {
142142
143143 it ( 'malformed strings of incorrect length' , function ( ) {
144144 assert . throws ( function ( ) {
145- ulidImport . decodeTime ( 'FFFF' )
145+ ULID . decodeTime ( 'FFFF' )
146146 } , Error )
147147 } )
148148
149149 it ( 'strings with timestamps that are too high' , function ( ) {
150150 assert . throws ( function ( ) {
151- ulidImport . decodeTime ( '80000000000000000000000000' )
151+ ULID . decodeTime ( '80000000000000000000000000' )
152152 } , Error )
153153 } )
154154
@@ -174,11 +174,11 @@ describe('ulid', function() {
174174 return 0.96
175175 }
176176
177- var stubbedUlid = ulidImport . factory ( stubbedPrng )
177+ var stubbedUlid = ULID . factory ( stubbedPrng )
178178
179179 describe ( 'without seedTime' , function ( ) {
180180
181- var stubbedUlid = ulidImport . monotonicFactory ( stubbedPrng )
181+ var stubbedUlid = ULID . monotonicFactory ( stubbedPrng )
182182 var clock
183183
184184 before ( function ( ) {
@@ -212,7 +212,7 @@ describe('ulid', function() {
212212
213213 describe ( 'with seedTime' , function ( ) {
214214
215- var stubbedUlid = ulidImport . monotonicFactory ( stubbedPrng )
215+ var stubbedUlid = ULID . monotonicFactory ( stubbedPrng )
216216
217217 it ( 'first call' , function ( ) {
218218 assert . strictEqual ( '01ARYZ6S41YYYYYYYYYYYYYYYY' , stubbedUlid ( 1469918176385 ) )
0 commit comments