@@ -4,7 +4,7 @@ import { FileTypeValidator } from '../../../pipes';
44
55describe ( 'FileTypeValidator' , ( ) => {
66 describe ( 'isValid' , ( ) => {
7- it ( 'should return true when the file buffer matches the specified type' , ( ) => {
7+ it ( 'should return true when the file buffer matches the specified type' , async ( ) => {
88 const fileTypeValidator = new FileTypeValidator ( {
99 fileType : 'image/jpeg' ,
1010 } ) ;
@@ -17,10 +17,10 @@ describe('FileTypeValidator', () => {
1717 buffer : jpegBuffer ,
1818 } as IFile ;
1919
20- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
20+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
2121 } ) ;
2222
23- it ( 'should return true when the file buffer matches the specified file extension' , ( ) => {
23+ it ( 'should return true when the file buffer matches the specified file extension' , async ( ) => {
2424 const fileTypeValidator = new FileTypeValidator ( {
2525 fileType : 'jpeg' ,
2626 } ) ;
@@ -32,10 +32,10 @@ describe('FileTypeValidator', () => {
3232 mimetype : 'image/jpeg' ,
3333 buffer : jpegBuffer ,
3434 } as IFile ;
35- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
35+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
3636 } ) ;
3737
38- it ( 'should return true when the file buffer matches the specified regexp' , ( ) => {
38+ it ( 'should return true when the file buffer matches the specified regexp' , async ( ) => {
3939 const fileTypeValidator = new FileTypeValidator ( {
4040 fileType : / ^ i m a g e \/ / ,
4141 } ) ;
@@ -48,10 +48,10 @@ describe('FileTypeValidator', () => {
4848 buffer : jpegBuffer ,
4949 } as IFile ;
5050
51- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
51+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
5252 } ) ;
5353
54- it ( 'should return false when the file buffer does not match the specified type' , ( ) => {
54+ it ( 'should return false when the file buffer does not match the specified type' , async ( ) => {
5555 const fileTypeValidator = new FileTypeValidator ( {
5656 fileType : 'image/jpeg' ,
5757 } ) ;
@@ -64,10 +64,10 @@ describe('FileTypeValidator', () => {
6464 buffer : pngBuffer ,
6565 } as IFile ;
6666
67- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
67+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
6868 } ) ;
6969
70- it ( 'should return false when the file buffer does not match the specified file extension' , ( ) => {
70+ it ( 'should return false when the file buffer does not match the specified file extension' , async ( ) => {
7171 const fileTypeValidator = new FileTypeValidator ( {
7272 fileType : 'jpeg' ,
7373 } ) ;
@@ -80,10 +80,10 @@ describe('FileTypeValidator', () => {
8080 buffer : pngBuffer ,
8181 } as IFile ;
8282
83- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
83+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
8484 } ) ;
8585
86- it ( 'should return false when no buffer is provided' , ( ) => {
86+ it ( 'should return false when no buffer is provided' , async ( ) => {
8787 const fileTypeValidator = new FileTypeValidator ( {
8888 fileType : 'image/jpeg' ,
8989 } ) ;
@@ -92,18 +92,18 @@ describe('FileTypeValidator', () => {
9292 mimetype : 'image/jpeg' ,
9393 } as IFile ;
9494
95- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
95+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
9696 } ) ;
9797
98- it ( 'should return false when no file is provided' , ( ) => {
98+ it ( 'should return false when no file is provided' , async ( ) => {
9999 const fileTypeValidator = new FileTypeValidator ( {
100100 fileType : 'image/jpeg' ,
101101 } ) ;
102102
103- expect ( fileTypeValidator . isValid ( ) ) . to . equal ( false ) ;
103+ expect ( await fileTypeValidator . isValid ( ) ) . to . equal ( false ) ;
104104 } ) ;
105105
106- it ( 'should return false when no buffer is provided' , ( ) => {
106+ it ( 'should return false when no buffer is provided' , async ( ) => {
107107 const fileTypeValidator = new FileTypeValidator ( {
108108 fileType : 'image/jpeg' ,
109109 } ) ;
@@ -112,10 +112,10 @@ describe('FileTypeValidator', () => {
112112 mimetype : 'image/jpeg' ,
113113 } as IFile ;
114114
115- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
115+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
116116 } ) ;
117117
118- it ( 'should return true when the file buffer matches the specified regexp' , ( ) => {
118+ it ( 'should return true when the file buffer matches the specified regexp' , async ( ) => {
119119 const fileTypeValidator = new FileTypeValidator ( {
120120 fileType : / ^ i m a g e \/ / ,
121121 } ) ;
@@ -128,10 +128,10 @@ describe('FileTypeValidator', () => {
128128 buffer : jpegBuffer ,
129129 } as IFile ;
130130
131- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
131+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
132132 } ) ;
133133
134- it ( 'should return true when no validation options are provided' , ( ) => {
134+ it ( 'should return true when no validation options are provided' , async ( ) => {
135135 const fileTypeValidator = new FileTypeValidator ( { } as any ) ;
136136 const jpegBuffer = Buffer . from ( [
137137 0xff , 0xd8 , 0xff , 0xe0 , 0x00 , 0x10 , 0x4a , 0x46 , 0x49 , 0x46 ,
@@ -141,10 +141,10 @@ describe('FileTypeValidator', () => {
141141 buffer : jpegBuffer ,
142142 } as IFile ;
143143
144- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
144+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
145145 } ) ;
146146
147- it ( 'should skip magic numbers validation when the skipMagicNumbersValidation is true' , ( ) => {
147+ it ( 'should skip magic numbers validation when the skipMagicNumbersValidation is true' , async ( ) => {
148148 const fileTypeValidator = new FileTypeValidator ( {
149149 fileType : 'image/jpeg' ,
150150 skipMagicNumbersValidation : true ,
@@ -154,10 +154,10 @@ describe('FileTypeValidator', () => {
154154 mimetype : 'image/jpeg' ,
155155 } as IFile ;
156156
157- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
157+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( true ) ;
158158 } ) ;
159159
160- it ( 'should return false when the file buffer does not match any known type' , ( ) => {
160+ it ( 'should return false when the file buffer does not match any known type' , async ( ) => {
161161 const fileTypeValidator = new FileTypeValidator ( {
162162 fileType : 'unknown/type' ,
163163 } ) ;
@@ -170,10 +170,10 @@ describe('FileTypeValidator', () => {
170170 buffer : unknownBuffer ,
171171 } as IFile ;
172172
173- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
173+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
174174 } ) ;
175175
176- it ( 'should return false when the buffer is empty' , ( ) => {
176+ it ( 'should return false when the buffer is empty' , async ( ) => {
177177 const fileTypeValidator = new FileTypeValidator ( {
178178 fileType : 'image/jpeg' ,
179179 } ) ;
@@ -184,12 +184,12 @@ describe('FileTypeValidator', () => {
184184 buffer : emptyBuffer ,
185185 } as IFile ;
186186
187- expect ( fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
187+ expect ( await fileTypeValidator . isValid ( requestFile ) ) . to . equal ( false ) ;
188188 } ) ;
189189 } ) ;
190190
191191 describe ( 'buildErrorMessage' , ( ) => {
192- it ( 'should return a string with the format "Validation failed (expected type is #fileType)"' , ( ) => {
192+ it ( 'should return a string with the format "Validation failed (expected type is #fileType)"' , async ( ) => {
193193 const fileType = 'image/jpeg' ;
194194 const fileTypeValidator = new FileTypeValidator ( {
195195 fileType,
@@ -200,7 +200,7 @@ describe('FileTypeValidator', () => {
200200 ) ;
201201 } ) ;
202202
203- it ( 'should include the file type in the error message when a file is provided' , ( ) => {
203+ it ( 'should include the file type in the error message when a file is provided' , async ( ) => {
204204 const currentFileType = 'image/png' ;
205205 const fileType = 'image/jpeg' ;
206206 const fileTypeValidator = new FileTypeValidator ( {
@@ -214,7 +214,7 @@ describe('FileTypeValidator', () => {
214214 ) ;
215215 } ) ;
216216
217- it ( 'should handle regexp file type in error message' , ( ) => {
217+ it ( 'should handle regexp file type in error message' , async ( ) => {
218218 const fileTypeValidator = new FileTypeValidator ( {
219219 fileType : / ^ i m a g e \/ / ,
220220 } ) ;
@@ -225,7 +225,7 @@ describe('FileTypeValidator', () => {
225225 ) ;
226226 } ) ;
227227
228- it ( 'should handle file extension in error message' , ( ) => {
228+ it ( 'should handle file extension in error message' , async ( ) => {
229229 const fileTypeValidator = new FileTypeValidator ( {
230230 fileType : 'jpeg' ,
231231 } ) ;
0 commit comments