@@ -135,35 +135,79 @@ describe('Test validations from config/validations.js', () => {
135135 */
136136
137137describe ( 'Test utils' , ( ) => {
138- describe ( 'utils.hash.hashLast8 ' , ( ) => {
138+ describe ( 'utils.hash.takeLast ' , ( ) => {
139139 it ( 'should return a string of length 8' , ( ) => {
140140 const input = 'example' ;
141- const result = utils . hash . hashLast8 ( input ) ;
141+ const result = utils . hash . takeLast ( input ) ;
142142 expect ( result ) . to . be . a ( 'string' ) ;
143143 expect ( result ) . to . have . lengthOf ( 8 ) ;
144144 } ) ;
145145
146+ it ( 'should return a string of length 6' , ( ) => {
147+ const input = 'example' ;
148+ const result = utils . hash . takeLast ( input , 6 ) ;
149+ expect ( result ) . to . be . a ( 'string' ) ;
150+ expect ( result ) . to . have . lengthOf ( 6 ) ;
151+ } ) ;
152+
146153 it ( 'should return a different string for different inputs' , ( ) => {
147154 const input1 = 'example1' ;
148155 const input2 = 'example2' ;
149- const result1 = utils . hash . hashLast8 ( input1 ) ;
150- const result2 = utils . hash . hashLast8 ( input2 ) ;
156+ const result1 = utils . hash . takeLast ( input1 ) ;
157+ const result2 = utils . hash . takeLast ( input2 ) ;
151158 expect ( result1 ) . to . not . equal ( result2 ) ;
152159 } ) ;
153160
154161 it ( 'should return the same string for the same input' , ( ) => {
155162 const input = 'example' ;
156- const result1 = utils . hash . hashLast8 ( input ) ;
157- const result2 = utils . hash . hashLast8 ( input ) ;
163+ const result1 = utils . hash . takeLast ( input ) ;
164+ const result2 = utils . hash . takeLast ( input ) ;
158165 expect ( result1 ) . to . equal ( result2 ) ;
159166 } ) ;
160167
161168 it ( 'should return a string containing only valid characters' , ( ) => {
162169 const input = 'example' ;
163- const result = utils . hash . hashLast8 ( input ) ;
170+ const result = utils . hash . takeLast ( input , 20 ) ;
164171 expect ( result ) . to . match ( / ^ [ a - f 0 - 9 ] + $ / ) ;
165172 } ) ;
166173 } ) ;
174+
175+ describe ( 'utils.hash.takeFirst' , ( ) => {
176+ it ( 'should return a string of length 8' , ( ) => {
177+ const input = 'example' ;
178+ const result = utils . hash . takeFirst ( input ) ;
179+ expect ( result ) . to . be . a ( 'string' ) ;
180+ expect ( result ) . to . have . lengthOf ( 8 ) ;
181+ } ) ;
182+
183+ it ( 'should return a string of length 6' , ( ) => {
184+ const input = 'example' ;
185+ const result = utils . hash . takeFirst ( input , 6 ) ;
186+ expect ( result ) . to . be . a ( 'string' ) ;
187+ expect ( result ) . to . have . lengthOf ( 6 ) ;
188+ } ) ;
189+
190+ it ( 'should return a different string for different inputs' , ( ) => {
191+ const input1 = 'example1' ;
192+ const input2 = 'example2' ;
193+ const result1 = utils . hash . takeFirst ( input1 ) ;
194+ const result2 = utils . hash . takeFirst ( input2 ) ;
195+ expect ( result1 ) . to . not . equal ( result2 ) ;
196+ } ) ;
197+
198+ it ( 'should return the same string for the same input' , ( ) => {
199+ const input = 'example' ;
200+ const result1 = utils . hash . takeFirst ( input ) ;
201+ const result2 = utils . hash . takeFirst ( input ) ;
202+ expect ( result1 ) . to . equal ( result2 ) ;
203+ } ) ;
204+
205+ it ( 'should return a string containing only valid characters' , ( ) => {
206+ const input = 'example' ;
207+ const result = utils . hash . takeFirst ( input , 20 ) ;
208+ expect ( result ) . to . match ( / ^ [ a - f 0 - 9 ] + $ / ) ;
209+ } ) ;
210+ } )
167211} ) ;
168212
169213/* ****************************************************************************
0 commit comments