@@ -2,7 +2,7 @@ import { expect } from 'chai';
22import {
33 addLeadingSlash ,
44 isConstructor ,
5- isEmpty ,
5+ isEmptyArray ,
66 isFunction ,
77 isNil ,
88 isNumber ,
@@ -199,20 +199,43 @@ describe('Shared utils', () => {
199199 } ) ;
200200 } ) ;
201201
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 ;
207205 } ) ;
206+
208207 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 ;
210232 } ) ;
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' ) ;
216239 } ) ;
217240 } ) ;
218241
0 commit comments