diff --git a/test/consuming-services.test.js b/test/consuming-services.test.js index b4c92169..37a30d73 100644 --- a/test/consuming-services.test.js +++ b/test/consuming-services.test.js @@ -32,6 +32,27 @@ describe('Consuming Services locally', () => { }) }) }).where(`name like`, 'E%') + if (cds.version >= '5.9.0') { + expect(authors).to.containSubset([ + { + name: 'Emily Brontë', + books: [ + { + title: 'Wuthering Heights', + currency: { name: 'British Pound', symbol: '£' }, + }, + ], + }, + { + name: 'Edgar Allen Poe', + books: [ + { title: 'The Raven', currency: { name: 'US Dollar', symbol: '$' } }, + { title: 'Eleonora', currency: { name: 'US Dollar', symbol: '$' } }, + ], + }, + ]) + return + } expect(authors).to.containSubset([ { name: 'Emily Brontë', diff --git a/test/hierarchical-data.test.js b/test/hierarchical-data.test.js index 2e5e86e5..299a18d0 100644 --- a/test/hierarchical-data.test.js +++ b/test/hierarchical-data.test.js @@ -35,6 +35,21 @@ describe('Hierarchical Data', ()=>{ )) it ('supports nested reads', async()=>{ + if (cds.version >= '5.9.0') { + expect (await + SELECT.one.from (Cats, c=>{ + c.ID, c.name.as('parent'), c.children (c=>{ + c.name.as('child') + }) + }) .where ({name:'Cat'}) + ) .to.eql ( + { ID:101, parent:'Cat', children:[ + { child:'Kitty' }, + { child:'Catwoman' }, + ]} + ) + return + } expect (await SELECT.one.from (Cats, c=>{ c.ID, c.name.as('parent'), c.children (c=>{ @@ -50,6 +65,25 @@ describe('Hierarchical Data', ()=>{ }) it ('supports deeply nested reads', async()=>{ + if (cds.version >= '5.9.0') { + expect (await SELECT.one.from (Cats, c=>{ + c.ID, c.name, c.children ( + c => { c.name }, + {levels:3} + ) + }) .where ({name:'Cat'}) + ) .to.eql ( + { ID:101, name:'Cat', children:[ + { name:'Kitty', children:[ + { name:'Kitty Cat', children:[ + { name:'Aristocat' }, ]}, // level 3 + { name:'Kitty Bat', children:[] }, ]}, + { name:'Catwoman', children:[ + { name:'Catalina', children:[] } ]}, + ]} + ) + return + } expect (await SELECT.one.from (Cats, c=>{ c.ID, c.name, c.children ( c => { c.name },