Skip to content

Commit 2f888d3

Browse files
refactor() adjust code style
1 parent 0db05f6 commit 2f888d3

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

packages/common/test/pipes/validation.pipe.spec.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import * as sinon from 'sinon';
21
import { expect } from 'chai';
2+
import { Exclude, Expose } from 'class-transformer';
3+
import { IsOptional, IsString } from 'class-validator';
34
import { ArgumentMetadata } from '../../interfaces';
4-
import { IsString, IsOptional } from 'class-validator';
55
import { ValidationPipe } from '../../pipes/validation.pipe';
6-
import { Exclude, Expose } from 'class-transformer';
76

87
@Exclude()
98
class TestModelInternal {
@@ -36,7 +35,7 @@ describe('ValidationPipe', () => {
3635
metatype: TestModel,
3736
data: '',
3837
};
39-
const metadatainternal: ArgumentMetadata = {
38+
const transformMetadata: ArgumentMetadata = {
4039
type: 'body',
4140
metatype: TestModelInternal,
4241
data: '',
@@ -93,38 +92,38 @@ describe('ValidationPipe', () => {
9392
});
9493
describe('when transformation is internal', () => {
9594
it('should return a TestModel with internal property', async () => {
96-
target = new ValidationPipe({
95+
target = new ValidationPipe({
9796
transform: true,
98-
transformOptions: { groups: ['internal'] }
97+
transformOptions: { groups: ['internal'] },
9998
});
10099
const testObj = {
101100
prop1: 'value1',
102101
prop2: 'value2',
103-
propInternal: 'value3'
102+
propInternal: 'value3',
104103
};
105104
expect(
106-
await target.transform(testObj, metadatainternal)
107-
).to.have.property('propInternal');
105+
await target.transform(testObj, transformMetadata),
106+
).to.have.property('propInternal');
108107
});
109108
});
110109
describe('when transformation is external', () => {
111110
it('should return a TestModel without internal property', async () => {
112-
target = new ValidationPipe({
111+
target = new ValidationPipe({
113112
transform: true,
114-
transformOptions: { groups: ['external'] }
113+
transformOptions: { groups: ['external'] },
115114
});
116115
const testObj = {
117116
prop1: 'value1',
118117
prop2: 'value2',
119-
propInternal: 'value3'
118+
propInternal: 'value3',
120119
};
121120
expect(
122-
await target.transform(testObj, metadatainternal)
121+
await target.transform(testObj, transformMetadata),
123122
).to.not.have.property('propInternal');
124123
});
125124
});
126125
});
127-
describe("when validation doesn't transform", () => {
126+
describe('when validation doesn\'t transform', () => {
128127
describe('when validation strips', () => {
129128
it('should return a plain object without extra properties', async () => {
130129
target = new ValidationPipe({ transform: false, whitelist: true });

0 commit comments

Comments
 (0)