Updated tests for 4.2

This commit is contained in:
Daniel
2020-08-27 13:26:46 +02:00
parent 2d608cd882
commit 62c3969185
2 changed files with 15 additions and 21 deletions

View File

@@ -15,14 +15,12 @@ describe('Consuming Services locally', () => {
it('supports targets as strings or reflected defs', async () => {
const AdminService = await cds.connect.to('AdminService')
const { Authors } = AdminService.entities
expect(await AdminService.read(Authors))
.to.eql(await AdminService.read('Authors'))
.to.eql(await AdminService.run(SELECT.from(Authors)))
const _ = expect (await AdminService.read(Authors))
.to.eql(await AdminService.read('Authors'))
.to.eql(await AdminService.run(SELECT.from(Authors)))
// temporary workaround
if (AdminService.read.fix_50)
expect(await AdminService.run(SELECT.from(Authors))).to.eql(
await AdminService.run(SELECT.from('Authors'))
)
if (cds.version >= '4.2.0')
_.to.eql(await AdminService.run(SELECT.from('Authors')))
})
it('allows reading from local services using cds.ql', async () => {
@@ -37,9 +35,8 @@ describe('Consuming Services locally', () => {
})
}).where(`name like`, 'E%')
// temporary workaround
if (!AdminService.read.fix_50) {
if (cds.version < '4.2.0')
query.SELECT.from.ref[0] = 'AdminService.Authors'
}
const authors = await AdminService.run(query)
expect(authors).to.containSubset([
{
@@ -77,17 +74,14 @@ describe('Consuming Services locally', () => {
})
}
const query1 = SELECT.from(Authors, projection).where(`name like`, 'E%')
expect(await cds.run(query1))
.to.eql(await db.run(query1))
.to.eql(await srv.run(query1))
.to.eql(await srv.read(Authors, projection).where(`name like`, 'E%'))
const query2 = cds.read(Authors, projection).where(`name like`, 'E%')
// temporary workaround
if (srv.read.fix_50)
expect(await cds.run(query1))
.to.eql(await cds.run(query2))
.to.eql(await db.run(query2))
.to.eql(await srv.run(query2))
.to.eql(await db.read(Authors, projection).where(`name like`, 'E%')) // FIXME!!
expect(await cds.run(query1))
.to.eql(await db.run(query1))
.to.eql(await srv.run(query1))
.to.eql(await srv.read(Authors, projection).where(`name like`, 'E%'))
.to.eql(await cds.run(query2))
.to.eql(await db.run(query2))
.to.eql(await srv.run(query2))
.to.eql(await db.read(Authors, projection).where(`name like`, 'E%'))
})
})