Clone components argument to keep tests independent

This commit is contained in:
Ankit Saini
2021-10-05 17:35:31 +05:30
parent 2f7e214037
commit 60ee47b01b

View File

@@ -93,13 +93,15 @@ describe('DEREF FUNCTION TESTS ', function() {
} }
}, },
parameterSource = 'REQUEST', parameterSource = 'REQUEST',
output = deref.resolveRefs(schema, parameterSource, componentsAndPaths), // deref.resolveRefs modifies the input schema and components so cloning to keep tests independent of each other
output_withdot = deref.resolveRefs(schemaWithDotInKey, parameterSource, componentsAndPaths), output = deref.resolveRefs(schema, parameterSource, _.cloneDeep(componentsAndPaths)),
output_customFormat = deref.resolveRefs(schemaWithCustomFormat, parameterSource, componentsAndPaths), output_withdot = deref.resolveRefs(schemaWithDotInKey, parameterSource, _.cloneDeep(componentsAndPaths)),
output_withAllOf = deref.resolveRefs(schemaWithAllOf, parameterSource, componentsAndPaths), output_customFormat = deref.resolveRefs(schemaWithCustomFormat, parameterSource,
output_validationTypeArray = deref.resolveRefs(schemaWithTypeArray, parameterSource, componentsAndPaths, _.cloneDeep(componentsAndPaths)),
{}, 'VALIDATION'), output_withAllOf = deref.resolveRefs(schemaWithAllOf, parameterSource, _.cloneDeep(componentsAndPaths)),
output_emptyObject = deref.resolveRefs(schemaWithEmptyObject, parameterSource, componentsAndPaths); output_validationTypeArray = deref.resolveRefs(schemaWithTypeArray, parameterSource,
_.cloneDeep(componentsAndPaths), {}, 'VALIDATION'),
output_emptyObject = deref.resolveRefs(schemaWithEmptyObject, parameterSource, _.cloneDeep(componentsAndPaths));
expect(output).to.deep.include({ type: 'object', expect(output).to.deep.include({ type: 'object',
required: ['id'], required: ['id'],
@@ -116,7 +118,7 @@ describe('DEREF FUNCTION TESTS ', function() {
type: 'object', type: 'object',
description: 'Schema 2', description: 'Schema 2',
properties: { properties: {
id: { default: '<long>', type: 'integer', format: 'int64' }, id: { default: '<long>', type: 'integer' },
test_prop: { default: '<string>', type: 'string' } test_prop: { default: '<string>', type: 'string' }
} }
}); });