Skip to content
Snippets Groups Projects
Commit c6771a81 authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Only merge arrays; fixed max object-props to be generated

parent bc2c6fda
Branches
No related tags found
No related merge requests found
......@@ -178,7 +178,7 @@ function merge(a, b) {
a[key] = a[key] || [];
// fix #292 - skip duplicated values from merge object (b)
b[key].forEach(value => {
if (a[key].indexOf(value) === -1) {
if (Array.isArray(a[key]) && a[key].indexOf(value) === -1) {
a[key].push(value);
}
});
......
......@@ -50,10 +50,10 @@ function objectType(value, path, resolve, traverseCallback) {
const fixedProbabilities = optionAPI('alwaysFakeOptionals') || optionAPI('fixedProbabilities') || false;
const ignoreProperties = optionAPI('ignoreProperties') || [];
const min = Math.max(value.minProperties || 0, random.number(requiredProperties.length, allProperties.length));
const min = Math.max(value.minProperties || 0, requiredProperties.length);
const max = value.maxProperties || (allProperties.length + (allowsAdditional ? random.number(1, 5) : 0));
let neededExtras = Math.max(0, min - requiredProperties.length);
let neededExtras = Math.max(0, allProperties.length - min);
if (allProperties.length === 1 && !requiredProperties.length) {
neededExtras = random.number(neededExtras, allProperties.length + (allProperties.length - min));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment