Skip to content

Commit 22764c7

Browse files
authored
Merge pull request #902 from donalmurtagh/development
add regression tests for #900
2 parents d120b6a + aef0751 commit 22764c7

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/services/schema-form.provider.spec.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,5 +567,79 @@ describe('schema-form.provider.js', function() {
567567

568568
});
569569
});
570+
571+
var arrayObjectSchema = {
572+
type: "object",
573+
properties: {
574+
peopleLivingWithYou: {
575+
type: "object",
576+
properties: {
577+
dependentChildren: {
578+
type: "array",
579+
minItems: 1,
580+
items: {
581+
type: "object",
582+
properties: {
583+
name: {
584+
title: "Name",
585+
type: "string"
586+
},
587+
age: {
588+
title: "Age",
589+
type: "integer"
590+
}
591+
},
592+
required: ["name"]
593+
}
594+
}
595+
},
596+
required: ["dependentChildren"]
597+
}
598+
},
599+
required: ["peopleLivingWithYou"]
600+
};
601+
602+
it('merge a schema that defines an array of objects with a form inside a section #900', function() {
603+
inject(function(schemaForm) {
604+
605+
var formInsideSection = [{
606+
type: 'section',
607+
items: [{
608+
key: 'peopleLivingWithYou.dependentChildren',
609+
add: "Add Child",
610+
title: 'Dependent children details',
611+
validationMessage: 'Complete all required fields for at least one child'
612+
}]
613+
}];
614+
615+
var merged = schemaForm.merge(arrayObjectSchema, formInsideSection);
616+
var objectPropertyKeys = merged[0].items[0].items[0];
617+
var nameKey = objectPropertyKeys.items[0].key;
618+
var ageKey = objectPropertyKeys.items[1].key;
619+
620+
nameKey.join('.').should.eq("peopleLivingWithYou.dependentChildren..name");
621+
ageKey.join('.').should.eq("peopleLivingWithYou.dependentChildren..age");
622+
});
623+
});
624+
625+
it('merge a schema that defines an array of objects with a form without a section #900', function() {
626+
inject(function(schemaForm) {
627+
628+
var formWithoutSection = [{
629+
key: 'peopleLivingWithYou.dependentChildren',
630+
add: "Add Child",
631+
title: 'Dependent children details',
632+
validationMessage: 'Complete all required fields for at least one child'
633+
}];
634+
635+
var merged = schemaForm.merge(arrayObjectSchema, formWithoutSection);
636+
var objectPropertyKeys = merged[0].items[0];
637+
var nameKey = objectPropertyKeys.items[0].key;
638+
var ageKey = objectPropertyKeys.items[1].key;
639+
640+
nameKey.join('.').should.eq("peopleLivingWithYou.dependentChildren..name");
641+
ageKey.join('.').should.eq("peopleLivingWithYou.dependentChildren..age");
642+
});
643+
});
570644
});
571645
});

0 commit comments

Comments
 (0)