From 54ebb82fd7dff3db1ba883cf11ff0bd6c2a06299 Mon Sep 17 00:00:00 2001 From: Kathleen Tuite Date: Tue, 12 Dec 2023 16:39:38 -0800 Subject: [PATCH] Add little empty structure unit test (#1063) --- test/unit/data/schema.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/unit/data/schema.js b/test/unit/data/schema.js index e0ce34bba..028bf88b2 100644 --- a/test/unit/data/schema.js +++ b/test/unit/data/schema.js @@ -785,6 +785,35 @@ describe('form schema', () => { stack.pop(); })); + it('should navigate in and out of empty structures', async () => { + const form = ` + + + + + + + + + + + + + + + + `; + const fields = await fieldsFor(form); + const stack = new SchemaStack(fields); + stack.push('data'); + stack.push('meta').should.eql(new MockField({ name: 'meta', path: '/meta', type: 'structure', order: 0 })); + stack.push('entity').should.eql(new MockField({ name: 'entity', path: '/meta/entity', type: 'structure', order: 1 })); + stack.children().should.eql([]); + stack.pop('entity').should.eql(new MockField({ name: 'entity', path: '/meta/entity', type: 'structure', order: 1 })); + stack.pop('meta').should.eql(new MockField({ name: 'meta', path: '/meta', type: 'structure', order: 0 })); + stack.push('age').should.eql(new MockField({ name: 'age', path: '/age', type: 'int', order: 2, propertyName: 'age' })); + }); + it('should ignore children of unknown repeats', () => fieldsFor(testData.forms.doubleRepeat) .then((fields) => { const stack = new SchemaStack(fields.filter((field) => field.path !== ('/children/child')));