Skip to content

Commit aef0751

Browse files
author
Dónal Murtagh
committed
add regression test for #900 that tests a form without a section
1 parent fefc721 commit aef0751

File tree

1 file changed

+48
-28
lines changed

1 file changed

+48
-28
lines changed

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

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -568,39 +568,39 @@ describe('schema-form.provider.js', function() {
568568
});
569569
});
570570

571-
it('regression test for merging schema that defines an array of objects #900', function() {
572-
inject(function(schemaForm) {
573-
574-
var arrayObjectSchema = {
571+
var arrayObjectSchema = {
572+
type: "object",
573+
properties: {
574+
peopleLivingWithYou: {
575575
type: "object",
576576
properties: {
577-
peopleLivingWithYou: {
578-
type: "object",
579-
properties: {
580-
dependentChildren: {
581-
type: "array",
582-
minItems: 1,
583-
items: {
584-
type: "object",
585-
properties: {
586-
name: {
587-
title: "Name",
588-
type: "string"
589-
},
590-
age: {
591-
title: "Age",
592-
type: "integer"
593-
}
594-
},
595-
required: ["name"]
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"
596590
}
597-
}
598-
},
599-
required: ["dependentChildren"]
591+
},
592+
required: ["name"]
593+
}
600594
}
601595
},
602-
required: ["peopleLivingWithYou"]
603-
};
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) {
604604

605605
var formInsideSection = [{
606606
type: 'section',
@@ -621,5 +621,25 @@ describe('schema-form.provider.js', function() {
621621
ageKey.join('.').should.eq("peopleLivingWithYou.dependentChildren..age");
622622
});
623623
});
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+
});
624644
});
625645
});

0 commit comments

Comments
 (0)