Skip to content

Commit 105df9e

Browse files
refactor(lint): code format fixed depending on new lint rules.
1 parent 6c978f5 commit 105df9e

10 files changed

+77
-77
lines changed

lib/core/normalizer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { expandArraysPaths } = require('../helpers/objectPathHelper');
1616
* @param {object} customConfig - normalization configuration (see '/config/normalizer.js')
1717
* @returns {object}
1818
*/
19-
const normalize = async (jsonNode, jsonSchema, customConfig = {}) => {
19+
const normalize = async(jsonNode, jsonSchema, customConfig = {}) => {
2020
const config = { ...defaultConfig, ...customConfig };
2121
logger.debug(`Trying to normalize : '${JSON.stringify(jsonNode)}'`);
2222
logger.debug(`Based on Json-Schema information : '${JSON.stringify(jsonSchema)}'`);

tests/index.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
describe('start.js', () => {
2-
it('launching the app', async () => {});
2+
it('launching the app', async() => {});
33
});

tests/unit/lib/core/converter-to-boolean.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const JsonNodeNormalizer = require('../../../../index');
22

33
describe('normalizer.js', () => {
4-
it('try to normalize json data with some boolean values', async () => {
4+
it('try to normalize json data with some boolean values', async() => {
55
// Given
66
const jsonToNormalize = {
77
fields: {

tests/unit/lib/core/converter-to-string.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const JsonNodeNormalizer = require('../../../../index');
22

33
describe('normalizer.js', () => {
4-
it('try to normalize json data to string', async () => {
4+
it('try to normalize json data to string', async() => {
55
// Given
66
const jsonToNormalize = {
77
fields: {

tests/unit/lib/core/default-value.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const JsonNodeNormalizer = require('../../../../index');
22

33
describe('normalizer.js', () => {
4-
it('Should normalize and add default values if field is undefined', async () => {
4+
it('Should normalize and add default values if field is undefined', async() => {
55
// Given
66
const jsonToNormalize = {
77
fields: {

tests/unit/lib/core/formats.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class UnknownType {
77
}
88

99
describe('formats.js', () => {
10-
it('try to normalize json node to \'UPPERCASE\'', async () => {
10+
it('try to normalize json node to \'UPPERCASE\'', async() => {
1111
// Given
1212
const jsonNode = 'test';
1313
const targetFormat = FormatTypes.UPPERCASE;
@@ -20,7 +20,7 @@ describe('formats.js', () => {
2020
expect(normalizedNode).toBe(expectedResult);
2121
});
2222

23-
it('try to normalize json node to \'LOWERCASE\'', async () => {
23+
it('try to normalize json node to \'LOWERCASE\'', async() => {
2424
// Given
2525
const jsonNode = 'TEST';
2626
const targetFormat = FormatTypes.LOWERCASE;
@@ -33,7 +33,7 @@ describe('formats.js', () => {
3333
expect(normalizedNode).toBe(expectedResult);
3434
});
3535

36-
it('try to normalize json node to unknown format', async () => {
36+
it('try to normalize json node to unknown format', async() => {
3737
// Given
3838
const jsonNode = 'TEST';
3939
const targetFormat = 'unknown';
@@ -45,7 +45,7 @@ describe('formats.js', () => {
4545
expect(normalizedNode).toBe(jsonNode);
4646
});
4747

48-
it('try to normalize unknown json type object that cannot be formatted', async () => {
48+
it('try to normalize unknown json type object that cannot be formatted', async() => {
4949
// Given
5050
const jsonNode = new UnknownType('TEST');
5151
const targetFormat = FormatTypes.LOWERCASE;

tests/unit/lib/core/normalizer.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('normalizer.js', () => {
2020
});
2121

2222
describe('normalizer.js', () => {
23-
it('try to normalize json data from json schema', async () => {
23+
it('try to normalize json data from json schema', async() => {
2424
// Given
2525
const jsonToNormalize = {
2626
fields: {
@@ -78,7 +78,7 @@ describe('normalizer.js', () => {
7878
expect(typeof result.fields.active === 'boolean').toBe(true);
7979
});
8080

81-
it('try to normalize json data that should not be normalized from json schema', async () => {
81+
it('try to normalize json data that should not be normalized from json schema', async() => {
8282
// Given
8383
const jsonToNormalize = {
8484
fields: {
@@ -143,7 +143,7 @@ describe('normalizer.js', () => {
143143
expect(result.fields.externalField).toBe(null);
144144
});
145145

146-
it('should normalize jsonData with specific normalization type field name (See #13)', async () => {
146+
it('should normalize jsonData with specific normalization type field name (See #13)', async() => {
147147
// Given
148148
const jsonData = { data: { enable: 'true' } };
149149
const jsonSchema = {
@@ -165,7 +165,7 @@ describe('normalizer.js', () => {
165165
expect(typeof result.data.enable).toBe('boolean');
166166
});
167167

168-
it('should normalize jsonData with specific normalization format field name (See #19)', async () => {
168+
it('should normalize jsonData with specific normalization format field name (See #19)', async() => {
169169
// Given
170170
const jsonData = {
171171
data: {
@@ -203,7 +203,7 @@ describe('normalizer.js', () => {
203203
expect(result).toStrictEqual(expectedResult);
204204
});
205205

206-
it('should normalize jsonData from JsonSchema with type & format definitions', async () => {
206+
it('should normalize jsonData from JsonSchema with type & format definitions', async() => {
207207
// Given
208208
const jsonData = {
209209
data: {
@@ -243,7 +243,7 @@ describe('normalizer.js', () => {
243243
expect(result).toStrictEqual(expectedResult);
244244
});
245245

246-
it('should normalize jsonData from JsonPaths with type & format definitions', async () => {
246+
it('should normalize jsonData from JsonPaths with type & format definitions', async() => {
247247
// Given
248248
const jsonData = {
249249
data: {
@@ -281,7 +281,7 @@ describe('normalizer.js', () => {
281281
expect(result).toStrictEqual(expectedResult);
282282
});
283283

284-
it('should not normalize paths matching an exclude path', async () => {
284+
it('should not normalize paths matching an exclude path', async() => {
285285
// Given
286286
const jsonToNormalize = {
287287
fields: {
+53-53
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
const JsonNodeNormalizer = require('../../../../index');
2-
3-
describe('oasFlatter.js', () => {
4-
it('try to convert oas2 basic example', () => {
5-
// Given
6-
const jsonSample = require('../../mock-sample/oas2_basic.json');
7-
const expected = require('../../mock-sample/oas2_basic_flattered.json');
8-
// When
9-
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
10-
// Then
11-
expect(oasFlattered).toEqual(expected);
12-
});
13-
14-
it('try to convert oas3 basic example', () => {
15-
// Given
16-
const jsonSample = require('../../mock-sample/oas3_basic.json');
17-
const expected = require('../../mock-sample/oas3_basic_flattered.json');
18-
// When
19-
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
20-
// Then
21-
expect(oasFlattered).toEqual(expected);
22-
});
23-
24-
it('try to convert oas3 with ref error example', () => {
25-
// Given
26-
const jsonSample = require('../../mock-sample/oas3_ref_error.json');
27-
const expected = require('../../mock-sample/oas3_ref_error_flattered.json');
28-
// When
29-
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
30-
// Then
31-
expect(oasFlattered).toEqual(expected);
32-
});
33-
34-
it('try to convert oas3 with allOf & oneOf example', () => {
35-
// Given
36-
const jsonSample = require('../../mock-sample/oas3_allof_oneof.json');
37-
const expected = require('../../mock-sample/oas3_allof_oneof_flattered.json');
38-
// When
39-
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
40-
// Then
41-
expect(oasFlattered).toEqual(expected);
42-
});
43-
44-
it('try to convert oas3 with allOf & anyOf example', () => {
45-
// Given
46-
const jsonSample = require('../../mock-sample/oas3_allOf_anyOf.json');
47-
const expected = require('../../mock-sample/oas3_allOf_anyOf_flattered.json');
48-
// When
49-
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
50-
// Then
51-
expect(oasFlattered).toEqual(expected);
52-
});
53-
});
1+
const JsonNodeNormalizer = require('../../../../index');
2+
3+
describe('oasFlatter.js', () => {
4+
it('try to convert oas2 basic example', () => {
5+
// Given
6+
const jsonSample = require('../../mock-sample/oas2_basic.json');
7+
const expected = require('../../mock-sample/oas2_basic_flattered.json');
8+
// When
9+
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
10+
// Then
11+
expect(oasFlattered).toEqual(expected);
12+
});
13+
14+
it('try to convert oas3 basic example', () => {
15+
// Given
16+
const jsonSample = require('../../mock-sample/oas3_basic.json');
17+
const expected = require('../../mock-sample/oas3_basic_flattered.json');
18+
// When
19+
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
20+
// Then
21+
expect(oasFlattered).toEqual(expected);
22+
});
23+
24+
it('try to convert oas3 with ref error example', () => {
25+
// Given
26+
const jsonSample = require('../../mock-sample/oas3_ref_error.json');
27+
const expected = require('../../mock-sample/oas3_ref_error_flattered.json');
28+
// When
29+
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
30+
// Then
31+
expect(oasFlattered).toEqual(expected);
32+
});
33+
34+
it('try to convert oas3 with allOf & oneOf example', () => {
35+
// Given
36+
const jsonSample = require('../../mock-sample/oas3_allof_oneof.json');
37+
const expected = require('../../mock-sample/oas3_allof_oneof_flattered.json');
38+
// When
39+
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
40+
// Then
41+
expect(oasFlattered).toEqual(expected);
42+
});
43+
44+
it('try to convert oas3 with allOf & anyOf example', () => {
45+
// Given
46+
const jsonSample = require('../../mock-sample/oas3_allOf_anyOf.json');
47+
const expected = require('../../mock-sample/oas3_allOf_anyOf_flattered.json');
48+
// When
49+
const oasFlattered = JsonNodeNormalizer.oasFlatten(jsonSample);
50+
// Then
51+
expect(oasFlattered).toEqual(expected);
52+
});
53+
});

tests/unit/lib/core/schema.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { deReferenceSchema, _getFieldPaths, getFieldsToNormalize } = require('../
22
const { schemaWithRef } = require('../../mock-sample/json-schema');
33

44
describe('schema.js', () => {
5-
it('try to dereference a Json Schema', async () => {
5+
it('try to dereference a Json Schema', async() => {
66
const schemaWithoutRef = await deReferenceSchema(schemaWithRef);
77
expect(schemaWithRef.properties.vegetables.items).not.toHaveProperty('properties');
88
expect(schemaWithRef.properties.vegetables.items).toHaveProperty('$ref');
@@ -13,7 +13,7 @@ describe('schema.js', () => {
1313
});
1414

1515
describe('schema.js', () => {
16-
it('try to get all field types from Json Schema', async () => {
16+
it('try to get all field types from Json Schema', async() => {
1717
const schemaWithoutRef = await deReferenceSchema(schemaWithRef);
1818
const typePaths = _getFieldPaths(schemaWithoutRef);
1919
expect(typePaths).toContainEqual('$.properties.fruits');
@@ -31,7 +31,7 @@ describe('schema.js', () => {
3131
});
3232

3333
describe('schema.js', () => {
34-
it('try to get all fields that must be normalized from Json-Schema, using default config', async () => {
34+
it('try to get all fields that must be normalized from Json-Schema, using default config', async() => {
3535
const schemaWithoutRef = await deReferenceSchema(schemaWithRef);
3636
const fields = getFieldsToNormalize(schemaWithoutRef);
3737

@@ -51,7 +51,7 @@ describe('schema.js', () => {
5151
expect(fields).not.toContainEqual({ path: '$.definition.veggie.veggieName', type: 'string' });
5252
});
5353

54-
it('try to get all fields that must be normalized from Json-Schema, using excludePaths', async () => {
54+
it('try to get all fields that must be normalized from Json-Schema, using excludePaths', async() => {
5555
const schemaWithoutRef = await deReferenceSchema(schemaWithRef);
5656
const fields = getFieldsToNormalize(schemaWithoutRef, {
5757
excludePaths: [{ type: 'string', format: 'date-time' }, { path: '$.vegetables[*].veggieColor' }],

tests/unit/lib/core/schemaCache.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const JsonNodeNormalizer = require('../../../../index');
1010
const sleepy = ms => new Promise(resolve => { setTimeout(() => resolve(), ms); });
1111

1212
describe('schemaCache.js', () => {
13-
it('should store object data into the cache', async () => {
13+
it('should store object data into the cache', async() => {
1414
// Given
1515
const objectToStore = {
1616
test: "OK"
@@ -26,7 +26,7 @@ describe('schemaCache.js', () => {
2626
await sleepy(200); // Wait for cache clear
2727
});
2828

29-
it('should remove object from cache after delay', async () => {
29+
it('should remove object from cache after delay', async() => {
3030
// Given
3131
const objectToStore = {
3232
test: "OK"
@@ -40,7 +40,7 @@ describe('schemaCache.js', () => {
4040
expect(SchemaCache.getData('objectTest')).toEqual(undefined);
4141
});
4242

43-
it(`'fieldsToNormalize' should be store & removed from the cache`, async () => {
43+
it(`'fieldsToNormalize' should be store & removed from the cache`, async() => {
4444
// Given
4545
const cacheSpy = jest.spyOn(SchemaCache, 'setData');
4646
const jsonData = {
@@ -99,7 +99,7 @@ describe('schemaCache.js', () => {
9999
jest.clearAllMocks();
100100
});
101101

102-
it(`Should clear cache between each calls`, async () => {
102+
it(`Should clear cache between each calls`, async() => {
103103
// Given
104104
const cacheSpy = jest.spyOn(SchemaCache, 'setData');
105105
const jsonData = {

0 commit comments

Comments
 (0)