1
1
import type { NestedArray } from '../../src/utils-hoist/array' ;
2
+ // eslint-disable-next-line deprecation/deprecation
2
3
import { flatten } from '../../src/utils-hoist/array' ;
3
4
4
5
describe ( 'flatten' , ( ) => {
5
6
it ( 'should return the same array when input is a flat array' , ( ) => {
6
7
const input = [ 1 , 2 , 3 , 4 ] ;
7
8
const expected = [ 1 , 2 , 3 , 4 ] ;
9
+ // eslint-disable-next-line deprecation/deprecation
8
10
expect ( flatten ( input ) ) . toEqual ( expected ) ;
9
11
} ) ;
10
12
11
13
it ( 'should flatten a nested array of numbers' , ( ) => {
12
14
const input = [ [ 1 , 2 , [ 3 ] ] , 4 ] ;
13
15
const expected = [ 1 , 2 , 3 , 4 ] ;
16
+ // eslint-disable-next-line deprecation/deprecation
14
17
expect ( flatten ( input ) ) . toEqual ( expected ) ;
15
18
} ) ;
16
19
@@ -20,6 +23,7 @@ describe('flatten', () => {
20
23
[ 'How' , 'Are' , 'You' ] ,
21
24
] ;
22
25
const expected = [ 'Hello' , 'World' , 'How' , 'Are' , 'You' ] ;
26
+ // eslint-disable-next-line deprecation/deprecation
23
27
expect ( flatten ( input ) ) . toEqual ( expected ) ;
24
28
} ) ;
25
29
@@ -29,30 +33,35 @@ describe('flatten', () => {
29
33
[ { a : 3 } , { b : 4 } ] ,
30
34
] ;
31
35
const expected = [ { a : 1 } , { b : 2 } , { a : 3 } , { b : 4 } ] ;
36
+ // eslint-disable-next-line deprecation/deprecation
32
37
expect ( flatten ( input ) ) . toEqual ( expected ) ;
33
38
} ) ;
34
39
35
40
it ( 'should flatten a mixed type array' , ( ) => {
36
41
const input : NestedArray < string | { b : number } > = [ [ 'a' , { b : 2 } , 'c' ] , 'd' ] ;
37
42
const expected = [ 'a' , { b : 2 } , 'c' , 'd' ] ;
43
+ // eslint-disable-next-line deprecation/deprecation
38
44
expect ( flatten ( input ) ) . toEqual ( expected ) ;
39
45
} ) ;
40
46
41
47
it ( 'should flatten a deeply nested array' , ( ) => {
42
48
const input = [ 1 , [ 2 , [ 3 , [ 4 , [ 5 ] ] ] ] ] ;
43
49
const expected = [ 1 , 2 , 3 , 4 , 5 ] ;
50
+ // eslint-disable-next-line deprecation/deprecation
44
51
expect ( flatten ( input ) ) . toEqual ( expected ) ;
45
52
} ) ;
46
53
47
54
it ( 'should return an empty array when input is empty' , ( ) => {
48
55
const input : any [ ] = [ ] ;
49
56
const expected : any [ ] = [ ] ;
57
+ // eslint-disable-next-line deprecation/deprecation
50
58
expect ( flatten ( input ) ) . toEqual ( expected ) ;
51
59
} ) ;
52
60
53
61
it ( 'should return the same array when input is a flat array' , ( ) => {
54
62
const input = [ 1 , 'a' , { b : 2 } , 'c' , 3 ] ;
55
63
const expected = [ 1 , 'a' , { b : 2 } , 'c' , 3 ] ;
64
+ // eslint-disable-next-line deprecation/deprecation
56
65
expect ( flatten ( input ) ) . toEqual ( expected ) ;
57
66
} ) ;
58
67
} ) ;
0 commit comments