11import { describe , expect , it } from 'vitest' ;
2- import { isPlainObject } from '../../src' ;
2+ import { isArray , isClassInstance , isClassPrototype , isPlainObject , isString } from '../../src' ;
33
44class Foo { }
55const fooInstance = new Foo ( ) ;
@@ -16,3 +16,53 @@ describe('isPlainObject', () => {
1616 it ( 'should return false for class prototype' , ( ) => expect ( isPlainObject ( Foo ) ) . toBe ( false ) ) ;
1717 it ( 'should return false for class instance' , ( ) => expect ( isPlainObject ( fooInstance ) ) . toBe ( false ) ) ;
1818} ) ;
19+
20+ describe ( 'isArray' , ( ) => {
21+ it ( 'should return true for empty array' , ( ) => expect ( isArray ( [ ] ) ) . toBe ( true ) ) ;
22+ it ( 'should return true for non-empty array' , ( ) => expect ( isArray ( [ 1 , 2 , 3 ] ) ) . toBe ( true ) ) ;
23+ it ( 'should return false for plain object' , ( ) => expect ( isArray ( { } ) ) . toBe ( false ) ) ;
24+ it ( 'should return false for string' , ( ) => expect ( isArray ( 'hello' ) ) . toBe ( false ) ) ;
25+ it ( 'should return false for number' , ( ) => expect ( isArray ( 42 ) ) . toBe ( false ) ) ;
26+ it ( 'should return false for boolean' , ( ) => expect ( isArray ( true ) ) . toBe ( false ) ) ;
27+ it ( 'should return false for null' , ( ) => expect ( isArray ( null ) ) . toBe ( false ) ) ;
28+ it ( 'should return false for undefined' , ( ) => expect ( isArray ( undefined ) ) . toBe ( false ) ) ;
29+ it ( 'should return false for class prototype' , ( ) => expect ( isArray ( Foo ) ) . toBe ( false ) ) ;
30+ it ( 'should return false for class instance' , ( ) => expect ( isArray ( fooInstance ) ) . toBe ( false ) ) ;
31+ } ) ;
32+
33+ describe ( 'isClassPrototype' , ( ) => {
34+ it ( 'should return true for class prototype' , ( ) => expect ( isClassPrototype ( Foo ) ) . toBe ( true ) ) ;
35+ it ( 'should return false for class instance' , ( ) => expect ( isClassPrototype ( fooInstance ) ) . toBe ( false ) ) ;
36+ it ( 'should return false for plain object' , ( ) => expect ( isClassPrototype ( { } ) ) . toBe ( false ) ) ;
37+ it ( 'should return false for array' , ( ) => expect ( isClassPrototype ( [ ] ) ) . toBe ( false ) ) ;
38+ it ( 'should return false for string' , ( ) => expect ( isClassPrototype ( 'foo' ) ) . toBe ( false ) ) ;
39+ it ( 'should return false for number' , ( ) => expect ( isClassPrototype ( 42 ) ) . toBe ( false ) ) ;
40+ it ( 'should return false for boolean' , ( ) => expect ( isClassPrototype ( true ) ) . toBe ( false ) ) ;
41+ it ( 'should return false for null' , ( ) => expect ( isClassPrototype ( null ) ) . toBe ( false ) ) ;
42+ it ( 'should return false for undefined' , ( ) => expect ( isClassPrototype ( undefined ) ) . toBe ( false ) ) ;
43+ } ) ;
44+
45+ describe ( 'isClassInstance' , ( ) => {
46+ it ( 'should return true for class instance' , ( ) => expect ( isClassInstance ( fooInstance ) ) . toBe ( true ) ) ;
47+ it ( 'should return false for class prototype' , ( ) => expect ( isClassInstance ( Foo ) ) . toBe ( false ) ) ;
48+ it ( 'should return false for plain object' , ( ) => expect ( isClassInstance ( { } ) ) . toBe ( false ) ) ;
49+ it ( 'should return false for array' , ( ) => expect ( isClassInstance ( [ ] ) ) . toBe ( false ) ) ;
50+ it ( 'should return false for string' , ( ) => expect ( isClassInstance ( 'foo' ) ) . toBe ( false ) ) ;
51+ it ( 'should return false for number' , ( ) => expect ( isClassInstance ( 42 ) ) . toBe ( false ) ) ;
52+ it ( 'should return false for boolean' , ( ) => expect ( isClassInstance ( true ) ) . toBe ( false ) ) ;
53+ it ( 'should return false for null' , ( ) => expect ( isClassInstance ( null ) ) . toBe ( false ) ) ;
54+ it ( 'should return false for undefined' , ( ) => expect ( isClassInstance ( undefined ) ) . toBe ( false ) ) ;
55+ } ) ;
56+
57+ describe ( 'isString' , ( ) => {
58+ it ( 'should return true for string' , ( ) => expect ( isString ( 'hello' ) ) . toBe ( true ) ) ;
59+ it ( 'should return true for empty string' , ( ) => expect ( isString ( '' ) ) . toBe ( true ) ) ;
60+ it ( 'should return false for plain object' , ( ) => expect ( isString ( { } ) ) . toBe ( false ) ) ;
61+ it ( 'should return false for array' , ( ) => expect ( isString ( [ ] ) ) . toBe ( false ) ) ;
62+ it ( 'should return false for number' , ( ) => expect ( isString ( 42 ) ) . toBe ( false ) ) ;
63+ it ( 'should return false for boolean' , ( ) => expect ( isString ( true ) ) . toBe ( false ) ) ;
64+ it ( 'should return false for null' , ( ) => expect ( isString ( null ) ) . toBe ( false ) ) ;
65+ it ( 'should return false for undefined' , ( ) => expect ( isString ( undefined ) ) . toBe ( false ) ) ;
66+ it ( 'should return false for class prototype' , ( ) => expect ( isString ( Foo ) ) . toBe ( false ) ) ;
67+ it ( 'should return false for class instance' , ( ) => expect ( isString ( fooInstance ) ) . toBe ( false ) ) ;
68+ } ) ;
0 commit comments