@@ -4,7 +4,7 @@ import { FileTypeValidator } from '../../../pipes';
4
4
5
5
describe ( 'FileTypeValidator' , ( ) => {
6
6
describe ( 'isValid' , ( ) => {
7
- it ( 'should return true when the file buffer matches the specified type' , async ( ) => {
7
+ it ( 'should return true when the file buffer matches the specified type' , ( ) => {
8
8
const fileTypeValidator = new FileTypeValidator ( {
9
9
fileType : 'image/jpeg' ,
10
10
} ) ;
@@ -17,10 +17,10 @@ describe('FileTypeValidator', () => {
17
17
buffer : jpegBuffer ,
18
18
} as IFile ;
19
19
20
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
20
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
21
21
} ) ;
22
22
23
- it ( 'should return true when the file buffer matches the specified file extension' , async ( ) => {
23
+ it ( 'should return true when the file buffer matches the specified file extension' , ( ) => {
24
24
const fileTypeValidator = new FileTypeValidator ( {
25
25
fileType : 'jpeg' ,
26
26
} ) ;
@@ -32,10 +32,10 @@ describe('FileTypeValidator', () => {
32
32
mimetype : 'image/jpeg' ,
33
33
buffer : jpegBuffer ,
34
34
} as IFile ;
35
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
35
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
36
36
} ) ;
37
37
38
- it ( 'should return true when the file buffer matches the specified regexp' , async ( ) => {
38
+ it ( 'should return true when the file buffer matches the specified regexp' , ( ) => {
39
39
const fileTypeValidator = new FileTypeValidator ( {
40
40
fileType : / ^ i m a g e \/ / ,
41
41
} ) ;
@@ -48,10 +48,10 @@ describe('FileTypeValidator', () => {
48
48
buffer : jpegBuffer ,
49
49
} as IFile ;
50
50
51
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
51
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
52
52
} ) ;
53
53
54
- it ( 'should return false when the file buffer does not match the specified type' , async ( ) => {
54
+ it ( 'should return false when the file buffer does not match the specified type' , ( ) => {
55
55
const fileTypeValidator = new FileTypeValidator ( {
56
56
fileType : 'image/jpeg' ,
57
57
} ) ;
@@ -64,10 +64,10 @@ describe('FileTypeValidator', () => {
64
64
buffer : pngBuffer ,
65
65
} as IFile ;
66
66
67
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
67
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
68
68
} ) ;
69
69
70
- it ( 'should return false when the file buffer does not match the specified file extension' , async ( ) => {
70
+ it ( 'should return false when the file buffer does not match the specified file extension' , ( ) => {
71
71
const fileTypeValidator = new FileTypeValidator ( {
72
72
fileType : 'jpeg' ,
73
73
} ) ;
@@ -80,10 +80,10 @@ describe('FileTypeValidator', () => {
80
80
buffer : pngBuffer ,
81
81
} as IFile ;
82
82
83
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
83
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
84
84
} ) ;
85
85
86
- it ( 'should return false when no buffer is provided' , async ( ) => {
86
+ it ( 'should return false when no buffer is provided' , ( ) => {
87
87
const fileTypeValidator = new FileTypeValidator ( {
88
88
fileType : 'image/jpeg' ,
89
89
} ) ;
@@ -92,18 +92,18 @@ describe('FileTypeValidator', () => {
92
92
mimetype : 'image/jpeg' ,
93
93
} as IFile ;
94
94
95
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
95
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
96
96
} ) ;
97
97
98
- it ( 'should return false when no file is provided' , async ( ) => {
98
+ it ( 'should return false when no file is provided' , ( ) => {
99
99
const fileTypeValidator = new FileTypeValidator ( {
100
100
fileType : 'image/jpeg' ,
101
101
} ) ;
102
102
103
- expect ( await fileTypeValidator . isValid ( ) ) . to . equal ( false ) ;
103
+ expect ( fileTypeValidator . isValid ( ) ) . to . equal ( false ) ;
104
104
} ) ;
105
105
106
- it ( 'should return false when no buffer is provided' , async ( ) => {
106
+ it ( 'should return false when no buffer is provided' , ( ) => {
107
107
const fileTypeValidator = new FileTypeValidator ( {
108
108
fileType : 'image/jpeg' ,
109
109
} ) ;
@@ -112,10 +112,10 @@ describe('FileTypeValidator', () => {
112
112
mimetype : 'image/jpeg' ,
113
113
} as IFile ;
114
114
115
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
115
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
116
116
} ) ;
117
117
118
- it ( 'should return true when the file buffer matches the specified regexp' , async ( ) => {
118
+ it ( 'should return true when the file buffer matches the specified regexp' , ( ) => {
119
119
const fileTypeValidator = new FileTypeValidator ( {
120
120
fileType : / ^ i m a g e \/ / ,
121
121
} ) ;
@@ -128,10 +128,10 @@ describe('FileTypeValidator', () => {
128
128
buffer : jpegBuffer ,
129
129
} as IFile ;
130
130
131
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
131
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
132
132
} ) ;
133
133
134
- it ( 'should return true when no validation options are provided' , async ( ) => {
134
+ it ( 'should return true when no validation options are provided' , ( ) => {
135
135
const fileTypeValidator = new FileTypeValidator ( { } as any ) ;
136
136
const jpegBuffer = Buffer . from ( [
137
137
0xff , 0xd8 , 0xff , 0xe0 , 0x00 , 0x10 , 0x4a , 0x46 , 0x49 , 0x46 ,
@@ -141,10 +141,10 @@ describe('FileTypeValidator', () => {
141
141
buffer : jpegBuffer ,
142
142
} as IFile ;
143
143
144
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
144
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
145
145
} ) ;
146
146
147
- it ( 'should skip magic numbers validation when the skipMagicNumbersValidation is true' , async ( ) => {
147
+ it ( 'should skip magic numbers validation when the skipMagicNumbersValidation is true' , ( ) => {
148
148
const fileTypeValidator = new FileTypeValidator ( {
149
149
fileType : 'image/jpeg' ,
150
150
skipMagicNumbersValidation : true ,
@@ -154,10 +154,10 @@ describe('FileTypeValidator', () => {
154
154
mimetype : 'image/jpeg' ,
155
155
} as IFile ;
156
156
157
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
157
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
158
158
} ) ;
159
159
160
- it ( 'should return false when the file buffer does not match any known type' , async ( ) => {
160
+ it ( 'should return false when the file buffer does not match any known type' , ( ) => {
161
161
const fileTypeValidator = new FileTypeValidator ( {
162
162
fileType : 'unknown/type' ,
163
163
} ) ;
@@ -170,10 +170,10 @@ describe('FileTypeValidator', () => {
170
170
buffer : unknownBuffer ,
171
171
} as IFile ;
172
172
173
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
173
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
174
174
} ) ;
175
175
176
- it ( 'should return false when the buffer is empty' , async ( ) => {
176
+ it ( 'should return false when the buffer is empty' , ( ) => {
177
177
const fileTypeValidator = new FileTypeValidator ( {
178
178
fileType : 'image/jpeg' ,
179
179
} ) ;
@@ -184,7 +184,7 @@ describe('FileTypeValidator', () => {
184
184
buffer : emptyBuffer ,
185
185
} as IFile ;
186
186
187
- expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
187
+ expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
188
188
} ) ;
189
189
} ) ;
190
190
0 commit comments