@@ -2,7 +2,7 @@ import { expect } from 'chai';
2
2
import {
3
3
addLeadingSlash ,
4
4
isConstructor ,
5
- isEmpty ,
5
+ isEmptyArray ,
6
6
isFunction ,
7
7
isNil ,
8
8
isNumber ,
@@ -199,20 +199,43 @@ describe('Shared utils', () => {
199
199
} ) ;
200
200
} ) ;
201
201
202
- describe ( 'isEmpty' , ( ) => {
203
- it ( 'should return true when array is empty or not exists' , ( ) => {
204
- expect ( isEmpty ( [ ] ) ) . to . be . true ;
205
- expect ( isEmpty ( null ) ) . to . be . true ;
206
- expect ( isEmpty ( undefined ) ) . to . be . true ;
202
+ describe ( 'isEmptyArray' , ( ) => {
203
+ it ( 'should return true when array is empty' , ( ) => {
204
+ expect ( isEmptyArray ( [ ] ) ) . to . be . true ;
207
205
} ) ;
206
+
208
207
it ( 'should return false when array is not empty' , ( ) => {
209
- expect ( isEmpty ( [ 1 , 2 ] ) ) . to . be . false ;
208
+ expect ( isEmptyArray ( [ 1 , 2 ] ) ) . to . be . false ;
209
+ expect ( isEmptyArray ( [ 'a' , 'b' , 'c' ] ) ) . to . be . false ;
210
+ expect ( isEmptyArray ( [ { } ] ) ) . to . be . false ;
211
+ } ) ;
212
+
213
+ it ( 'should return false for non-array values' , ( ) => {
214
+ expect ( isEmptyArray ( null ) ) . to . be . false ;
215
+ expect ( isEmptyArray ( undefined ) ) . to . be . false ;
216
+ expect ( isEmptyArray ( { } ) ) . to . be . false ;
217
+ expect ( isEmptyArray ( '' ) ) . to . be . false ;
218
+ expect ( isEmptyArray ( 0 ) ) . to . be . false ;
219
+ expect ( isEmptyArray ( false ) ) . to . be . false ;
220
+ expect ( isEmptyArray ( Symbol ( ) ) ) . to . be . false ;
221
+ expect ( isEmptyArray ( ( ) => { } ) ) . to . be . false ;
222
+ } ) ;
223
+
224
+ it ( 'should return false for array-like objects' , ( ) => {
225
+ expect ( isEmptyArray ( { length : 0 } ) ) . to . be . false ;
226
+ expect ( isEmptyArray ( { length : 1 } ) ) . to . be . false ;
227
+ } ) ;
228
+
229
+ it ( 'should return false for sparse arrays' , ( ) => {
230
+ const sparseArray = new Array ( 3 ) ;
231
+ expect ( isEmptyArray ( sparseArray ) ) . to . be . false ;
210
232
} ) ;
211
- it ( 'should return true for non-array values' , ( ) => {
212
- expect ( isEmpty ( { } ) ) . to . be . true ;
213
- expect ( isEmpty ( '' ) ) . to . be . true ;
214
- expect ( isEmpty ( 0 ) ) . to . be . true ;
215
- expect ( isEmpty ( false ) ) . to . be . true ;
233
+ } ) ;
234
+
235
+ describe ( 'stripEndSlash' , ( ) => {
236
+ it ( 'should strip end slash if present' , ( ) => {
237
+ expect ( stripEndSlash ( '/cats/' ) ) . to . equal ( '/cats' ) ;
238
+ expect ( stripEndSlash ( '/cats' ) ) . to . equal ( '/cats' ) ;
216
239
} ) ;
217
240
} ) ;
218
241
0 commit comments