Skip to content

Commit d8fd911

Browse files
committed
fix code review
1 parent 1a2c9d9 commit d8fd911

7 files changed

+61
-6
lines changed

src/infra/configuration/configuration.decorator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export function Configuration() {
3535
},
3636
});
3737

38-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
3938
return proxyInstance;
4039
}
4140

src/infra/configuration/configuration.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-process-env */
21
import { DynamicModule, Module } from '@nestjs/common';
32
import { ConfigModule, ConfigModuleOptions, ConfigService } from '@nestjs/config';
43
import { ConfigurationFactory } from './configuration.factory.js';

src/shared/guard/type.guard.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,50 @@ describe('TypeGuard', () => {
370370
});
371371
});
372372

373+
describe('isArrayOfStrings', () => {
374+
describe('when passing type of value is an array of strings', () => {
375+
it('should return true', () => {
376+
expect(TypeGuard.isArrayOfStrings(['', '', ''])).toBe(true);
377+
});
378+
});
379+
380+
describe('when passing type of value is NOT an array of strings', () => {
381+
it('should return false', () => {
382+
expect(TypeGuard.isArrayOfStrings([1, 2, 3])).toBe(false);
383+
});
384+
385+
it('should return false', () => {
386+
expect(TypeGuard.isArrayOfStrings(['a', 'b', 3])).toBe(false);
387+
});
388+
389+
it('should return false', () => {
390+
expect(TypeGuard.isArrayOfStrings([{}, {}, {}])).toBe(false);
391+
});
392+
});
393+
});
394+
395+
describe('checkArrayOfStrings', () => {
396+
describe('when passing type of value is an array of strings', () => {
397+
it('should return value', () => {
398+
expect(TypeGuard.checkArrayOfStrings(['', '', ''])).toEqual(['', '', '']);
399+
});
400+
});
401+
402+
describe('when passing type of value is NOT an array of strings', () => {
403+
it('should throw an error', () => {
404+
expect(() => TypeGuard.checkArrayOfStrings([1, 2, 3])).toThrow('Type is not an array of strings.');
405+
});
406+
407+
it('should throw an error', () => {
408+
expect(() => TypeGuard.checkArrayOfStrings(['a', 'b', 3])).toThrow('Type is not an array of strings.');
409+
});
410+
411+
it('should throw an error', () => {
412+
expect(() => TypeGuard.checkArrayOfStrings([{}, {}, {}])).toThrow('Type is not an array of strings.');
413+
});
414+
});
415+
});
416+
373417
describe('isArrayWithElements', () => {
374418
describe('when passing type of value is an array with elements', () => {
375419
it('should return true', () => {
@@ -687,6 +731,18 @@ describe('TypeGuard', () => {
687731
});
688732
});
689733

734+
describe('checkKeysInObject', () => {
735+
it('should be return the key value', () => {
736+
const result = TypeGuard.checkKeysInObject({ x1: 'abc', x2: 'bcd' }, ['x1', 'x2']);
737+
expect(result).toEqual({ x1: 'abc', x2: 'bcd' });
738+
});
739+
it('should throw an error', () => {
740+
expect(() => TypeGuard.checkKeysInObject({ x1: 'abc', x2: 'bcd' }, ['b1'])).toThrow(
741+
'Object has missing key. Required are: [\"b1\"]. Get object keys: [\"x1\",\"x2\"]',
742+
);
743+
});
744+
});
745+
690746
describe('when param contract is not fullfilled', () => {
691747
it('should be throw an error', () => {
692748
// @ts-expect-error test-case

src/shared/transformer/comma-separated-string-to-array.transformer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CommaSeparatedStringToArray } from './comma-separated-string-to-array.t
44
describe('CommaSeparatedStringToArray()', () => {
55
class TestDto {
66
@CommaSeparatedStringToArray()
7-
items!: string[];
7+
public items!: string[];
88
}
99

1010
it('should transform a comma separated string to an array of trimmed strings', () => {

src/shared/transformer/comma-separated-string-to-array.transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function CommaSeparatedStringToArray(): PropertyDecorator {
1111
if (params.value.trim() === '') {
1212
return [];
1313
}
14+
1415
return params.value.split(',').map((item: string) => item.trim());
1516
}
1617

src/shared/transformer/string-to-boolean.transformer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ describe('ToBooleanTransformer Decorator', () => {
66
describe('when transform a string to boolean', () => {
77
class WithBooleanDto {
88
@StringToBoolean()
9-
booleanProp!: boolean;
9+
public booleanProp!: boolean;
1010

1111
@StringToBoolean()
12-
optionalBooleanProp?: boolean;
12+
public optionalBooleanProp?: boolean;
1313
}
1414

1515
it('should ignore undefined and null values', () => {

src/shared/transformer/string-to-number.transformer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('ToNumberTransformer Decorator', () => {
55
describe('when transform a string to number', () => {
66
class WithNumberDto {
77
@StringToNumber()
8-
booleanProp!: boolean;
8+
public booleanProp!: boolean;
99
}
1010

1111
it('should transform from string to number', () => {

0 commit comments

Comments
 (0)