Closed riceyeh closed 1 year ago
Hi, The following 2 tests show nested array items are added when adding an array item:
it('nested array item inside array item 1', () => { const fields = [ 'options', 'options[]', 'options[].oid', 'options[].amendments', 'options[].amendments[]', 'options[].amendments[].oid', ] const $form = new Form({fields}, {name: 'form'}) const $option = $form.$('options').add() $option.update({oid: 1}) expect($form.select('options.0', null, false)).not.to.be.undefined expect($form.select('options.0.amendments.0', null, false)).to.be.undefined // <--- fail })
it('nested array item inside array item 2', () => { const fields = [ 'a', 'a[]', 'a[].oid', 'a[].b.c', 'a[].b.c[]', 'a[].b.c[].oid' ] const $form = new Form({fields}, {name: 'form'}) const $a = $form.$('a').add() $a.update({oid: 1}) expect($form.select('a.0', null, false)).not.to.be.undefined expect($form.select('a.0.b', null, false)).not.to.be.undefined expect($form.select('a.0.b.c', null, false)).not.to.be.undefined expect($form.select('a.0.b.c.0', null, false)).to.be.undefined // <--- fail })
Hi, The following 2 tests show nested array items are added when adding an array item:
it('nested array item inside array item 1', () => { const fields = [ 'options', 'options[]', 'options[].oid', 'options[].amendments', 'options[].amendments[]', 'options[].amendments[].oid', ] const $form = new Form({fields}, {name: 'form'}) const $option = $form.$('options').add() $option.update({oid: 1}) expect($form.select('options.0', null, false)).not.to.be.undefined expect($form.select('options.0.amendments.0', null, false)).to.be.undefined // <--- fail })
it('nested array item inside array item 2', () => { const fields = [ 'a', 'a[]', 'a[].oid', 'a[].b.c', 'a[].b.c[]', 'a[].b.c[].oid' ] const $form = new Form({fields}, {name: 'form'}) const $a = $form.$('a').add() $a.update({oid: 1}) expect($form.select('a.0', null, false)).not.to.be.undefined expect($form.select('a.0.b', null, false)).not.to.be.undefined expect($form.select('a.0.b.c', null, false)).not.to.be.undefined expect($form.select('a.0.b.c.0', null, false)).to.be.undefined // <--- fail })