Skip to content

Commit 63d28bf

Browse files
committed
refactor(common): removed async keyword
1 parent 0b07780 commit 63d28bf

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

packages/common/pipes/file/file-type.validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class FileTypeValidator extends FileValidator<
2222
return `Validation failed (expected type is ${this.validationOptions.fileType})`;
2323
}
2424

25-
async isValid(file?: IFile): Promise<boolean> {
25+
isValid(file?: IFile): boolean {
2626
if (!this.validationOptions) {
2727
return true;
2828
}

packages/common/test/pipes/file/file-type.validator.spec.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FileTypeValidator } from '../../../pipes';
44

55
describe('FileTypeValidator', () => {
66
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', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(true);
20+
expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
2121
});
2222

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', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(true);
35+
expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
3636
});
3737

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', () => {
3939
const fileTypeValidator = new FileTypeValidator({
4040
fileType: /^image\//,
4141
});
@@ -48,10 +48,10 @@ describe('FileTypeValidator', () => {
4848
buffer: jpegBuffer,
4949
} as IFile;
5050

51-
expect(await fileTypeValidator.isValid(requestFile)).to.equal(true);
51+
expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
5252
});
5353

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', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(false);
67+
expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
6868
});
6969

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', () => {
7171
const fileTypeValidator = new FileTypeValidator({
7272
fileType: 'jpeg',
7373
});
@@ -80,10 +80,10 @@ describe('FileTypeValidator', () => {
8080
buffer: pngBuffer,
8181
} as IFile;
8282

83-
expect(await fileTypeValidator.isValid(requestFile)).to.equal(false);
83+
expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
8484
});
8585

86-
it('should return false when no buffer is provided', async () => {
86+
it('should return false when no buffer is provided', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(false);
95+
expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
9696
});
9797

98-
it('should return false when no file is provided', async () => {
98+
it('should return false when no file is provided', () => {
9999
const fileTypeValidator = new FileTypeValidator({
100100
fileType: 'image/jpeg',
101101
});
102102

103-
expect(await fileTypeValidator.isValid()).to.equal(false);
103+
expect(fileTypeValidator.isValid()).to.equal(false);
104104
});
105105

106-
it('should return false when no buffer is provided', async () => {
106+
it('should return false when no buffer is provided', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(false);
115+
expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
116116
});
117117

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', () => {
119119
const fileTypeValidator = new FileTypeValidator({
120120
fileType: /^image\//,
121121
});
@@ -128,10 +128,10 @@ describe('FileTypeValidator', () => {
128128
buffer: jpegBuffer,
129129
} as IFile;
130130

131-
expect(await fileTypeValidator.isValid(requestFile)).to.equal(true);
131+
expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
132132
});
133133

134-
it('should return true when no validation options are provided', async () => {
134+
it('should return true when no validation options are provided', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(true);
144+
expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
145145
});
146146

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', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(true);
157+
expect(fileTypeValidator.isValid(requestFile)).to.equal(true);
158158
});
159159

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', () => {
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(await fileTypeValidator.isValid(requestFile)).to.equal(false);
173+
expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
174174
});
175175

176-
it('should return false when the buffer is empty', async () => {
176+
it('should return false when the buffer is empty', () => {
177177
const fileTypeValidator = new FileTypeValidator({
178178
fileType: 'image/jpeg',
179179
});
@@ -184,7 +184,7 @@ describe('FileTypeValidator', () => {
184184
buffer: emptyBuffer,
185185
} as IFile;
186186

187-
expect(await fileTypeValidator.isValid(requestFile)).to.equal(false);
187+
expect(fileTypeValidator.isValid(requestFile)).to.equal(false);
188188
});
189189
});
190190

0 commit comments

Comments
 (0)