Skip to content

Commit

Permalink
chore: adjust tests for cds^8 (#662)
Browse files Browse the repository at this point in the history
- update does not return deep (as per odata spec)
- adjustment to fix in lean draft (with new adapter)
  • Loading branch information
sjvans committed May 29, 2024
1 parent dd7395c commit 5b07296
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions sqlite/test/deep/deepInputProcessing.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const cds = require('../../../test/cds')

const { POST, PUT } = cds.test(__dirname, 'deep.cds')
const { POST, PUT, GET } = cds.test(__dirname, 'deep.cds')

describe('UUID Generation', () => {
test('generate UUID on insert', async () => {
Expand Down Expand Up @@ -55,10 +55,12 @@ describe('UUID Generation', () => {
})
expect(resUpdate.status).toBe(200)

const resRead = await GET(`/bla/RootUUID(${uuid})?$expand=toOneChild($expand=toManySubChild)`)

// foreign keys are set correctly (deep)
expect(resUpdate.data.toOneChild.ID).toEqual(resUpdate.data.toOneChild_ID)
expect(resUpdate.data.toOneChild.ID).toEqual(resUpdate.data.toOneChild.toManySubChild[0].backlink_ID)
expect(resUpdate.data.toOneChild.ID).toEqual(resUpdate.data.toOneChild.toManySubChild[1].backlink_ID)
expect(resRead.data.toOneChild.ID).toEqual(resRead.data.toOneChild_ID)
expect(resRead.data.toOneChild.ID).toEqual(resRead.data.toOneChild.toManySubChild[0].backlink_ID)
expect(resRead.data.toOneChild.ID).toEqual(resRead.data.toOneChild.toManySubChild[1].backlink_ID)
})

test('generate UUID on update programmatically', async () => {
Expand Down Expand Up @@ -124,11 +126,16 @@ describe('UUID Generation', () => {
toOneChild: null,
})
expect(resUpdate.status).toBe(200)

expect(resUpdate.data).toMatchObject({
'@odata.context': '$metadata#RootUUID/$entity',
ID: uuid,
name: null,
})

const resRead = await GET(`/bla/RootUUID(${uuid})?$expand=toOneChild`)
expect(resRead.data).toMatchObject({
ID: uuid,
name: null,
toOneChild: null,
})
})
Expand Down
2 changes: 1 addition & 1 deletion sqlite/test/lean-draft.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ describe('draft tests', () => {
Price: null,
CurrencyCode_code: null,
to_Booking_BookingUUID: BookingUUID,
to_Travel_TravelUUID: null, // Should be TravelUUID!
to_Travel_TravelUUID: cds.env.features.odata_new_adapter ? TravelUUID : null, // Should be TravelUUID!
to_Supplement_SupplementID: null,
HasActiveEntity: false,
IsActiveEntity: false,
Expand Down

0 comments on commit 5b07296

Please sign in to comment.