1
- import {
2
- isFile ,
3
- cloneDeep ,
4
- hasOwnProperty ,
5
- merge ,
6
- isPlainObject ,
7
- } from '../util'
1
+ import { hasFiles , hasOwnProperty , isFile } from '../util'
8
2
9
3
describe ( 'Object Test' , ( ) => {
10
4
// const { window, File } = global
@@ -16,61 +10,23 @@ describe('Object Test', () => {
16
10
const file = new File ( [ 'hello world!' ] , 'myfile' )
17
11
expect ( isFile ( file ) ) . toBeTruthy ( )
18
12
} )
19
- /*
13
+ it ( 'should check has own property' , function ( ) {
14
+ expect ( hasOwnProperty ( { dev : null } , '' ) ) . toBeFalsy ( )
15
+ } )
20
16
it ( 'check if window is undefined' , ( ) => {
17
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
+ // @ts -ignore
21
19
delete global . window
22
20
const file = new File ( [ 'hello world!' ] , 'myfile' )
23
- expect(isFile(file)).toBeFalsy()
21
+ const form = new FormData ( )
22
+ form . append ( 'file' , file )
23
+ expect ( hasFiles ( form ) ) . toBeFalsy ( )
24
24
} )
25
+ /*
25
26
it('check if File is not function', () => {
26
27
const file = new File(['hello world!'], 'myfile')
27
28
delete global.File
28
29
expect(isFile(file)).toBeFalsy()
29
30
})
30
31
*/
31
32
} )
32
- describe ( 'cloneDeep' , ( ) => {
33
- it ( 'Object is null' , ( ) => {
34
- expect ( cloneDeep ( null ) ) . toBe ( null )
35
- } )
36
- it ( 'Object is typeof File' , ( ) => {
37
- const file = new File ( [ 'hello world!' ] , 'myfile' )
38
- expect ( cloneDeep ( file ) ) . toBeInstanceOf ( File )
39
- } )
40
- it ( 'Object is typeof Array' , ( ) => {
41
- const obj = [ { name : 'Chantouch' } ]
42
- expect ( cloneDeep ( obj ) ) . toBeInstanceOf ( Object )
43
- } )
44
- it ( 'Has own property undefined' , ( ) => {
45
- const obj = [ { name : 'Chantouch' } ]
46
- expect ( hasOwnProperty ( obj , undefined ) ) . toBeFalsy ( )
47
- } )
48
- it ( 'Merge object into object' , ( ) => {
49
- const obj1 = { name : 'Chantouch' }
50
- const obj2 = { email : 'chantouchsek.cs83@gmail.com' }
51
- const merged = { email : 'chantouchsek.cs83@gmail.com' , name : 'Chantouch' }
52
- expect ( merge ( obj1 , obj2 ) ) . toEqual ( merged )
53
- } )
54
- it ( 'should return `true` if the object is created by the `Object` constructor.' , ( ) => {
55
- expect ( isPlainObject ( Object . create ( { } ) ) ) . toBeTruthy ( )
56
- expect ( isPlainObject ( Object . create ( Object . prototype ) ) ) . toBeTruthy ( )
57
- expect ( isPlainObject ( { foo : 'bar' } ) ) . toBeTruthy ( )
58
- expect ( isPlainObject ( { } ) ) . toBeTruthy ( )
59
- expect ( isPlainObject ( Object . create ( null ) ) ) . toBeTruthy ( )
60
- } )
61
- it ( 'should return `false` if the object is not created by the `Object` constructor.' , ( ) => {
62
- function Foo ( this : any ) {
63
- this . abc = { }
64
- }
65
- expect ( isPlainObject ( / f o o / ) ) . toBeFalsy ( )
66
- // eslint-disable-next-line @typescript-eslint/no-empty-function
67
- expect ( isPlainObject ( function ( ) { } ) ) . toBeFalsy ( )
68
- expect ( isPlainObject ( 1 ) ) . toBeFalsy ( )
69
- expect ( isPlainObject ( [ 'foo' , 'bar' ] ) ) . toBeFalsy ( )
70
- expect ( isPlainObject ( [ ] ) ) . toBeFalsy ( )
71
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
72
- // @ts -ignore
73
- expect ( isPlainObject ( new Foo ( ) ) ) . toBeFalsy ( )
74
- expect ( isPlainObject ( null ) ) . toBeFalsy ( )
75
- } )
76
- } )
0 commit comments