Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit c8c10b7

Browse files
danjoauwe-klinger
authored andcommitted
cds.events test
1 parent d9d7203 commit c8c10b7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

test/cds.events.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const cds = require ('@sap/cds/lib')
2+
const { expect } = cds.test.in (__dirname)
3+
4+
describe('cds.events tests', ()=>{
5+
6+
let m; before (async ()=> m = await cds.load('events.cds'))
7+
8+
it ('should have the model loaded', ()=>{
9+
expect(m.definitions).to.have.property('Sue.Foo')
10+
})
11+
12+
it ('should compile the model to edmx', ()=>{
13+
const edmx = cds.compile(m).to.edmx({service:'Sue'})
14+
expect(edmx).to.match(/<EntitySet Name="Foo" EntityType="Sue.Foo"\/>/)
15+
})
16+
17+
it ('should compile the model to sql', ()=>{
18+
const sql = cds.compile(m).to.sql().join(';\n')
19+
expect(sql).not.to.match(/CREATE TABLE Sue_Foo/)
20+
expect(sql).to.match(/CREATE TABLE Sue_Bar/)
21+
})
22+
})

test/events.cds

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
service Sue {
2+
@cds.persistence.skip
3+
entity Foo { key ID:Integer; title:String; status:String(1); }
4+
entity Bar { key ID:Integer; foo: Association to Foo }
5+
event Foo.changed : projection on Foo { ID, status }
6+
}

0 commit comments

Comments
 (0)