Skip to content

Commit 95319d0

Browse files
authored
chore: more tests (#18)
1 parent 144fbf9 commit 95319d0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/sample/db/schema.cds

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using { Currency, managed, sap } from '@sap/cds/common';
22
namespace sap.capire.bookshop;
33

4+
@odata.draft.enabled
45
entity Books : managed {
56
key ID : Integer;
67
@mandatory title : localized String(111);

tests/tools.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ test.describe('tools', () => {
3838
assert(Array.isArray(books[0].endpoints), 'Should contain endpoints')
3939
assert.equal(books[0].endpoints[0].kind, 'odata', 'Should contain odata endpoint kind')
4040
assert.equal(books[0].endpoints[0].path, 'odata/v4/admin/Books', 'Should contain endpoint path')
41+
42+
// Check that keys are present and correct
43+
assert(books[0].elements.ID, 'Books entity should have key ID')
44+
assert(books[0].elements.ID.key === true, 'ID should be marked as key')
45+
// Check draft fields
46+
assert(books[0].elements.IsActiveEntity, 'Draft-enabled entity should have IsActiveEntity')
47+
assert(books[0].elements.IsActiveEntity.key === true, 'IsActiveEntity should be marked as key')
48+
assert(books[0].elements.HasActiveEntity, 'Draft-enabled entity should have HasActiveEntity')
49+
assert(books[0].elements.HasDraftEntity, 'Draft-enabled entity should have HasDraftEntity')
4150
})
4251

4352
test('search_cds_definitions: should list all entities (namesOnly)', async () => {

0 commit comments

Comments
 (0)