cds.events test
This commit is contained in:
22
test/cds.events.test.js
Normal file
22
test/cds.events.test.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const cds = require ('@sap/cds/lib')
|
||||||
|
const { expect } = cds.test.in (__dirname)
|
||||||
|
|
||||||
|
describe('cds.events tests', ()=>{
|
||||||
|
|
||||||
|
let m; before (async ()=> m = await cds.load('events.cds'))
|
||||||
|
|
||||||
|
it ('should have the model loaded', ()=>{
|
||||||
|
expect(m.definitions).to.have.property('Sue.Foo')
|
||||||
|
})
|
||||||
|
|
||||||
|
it ('should compile the model to edmx', ()=>{
|
||||||
|
const edmx = cds.compile(m).to.edmx({service:'Sue'})
|
||||||
|
expect(edmx).to.match(/<EntitySet Name="Foo" EntityType="Sue.Foo"\/>/)
|
||||||
|
})
|
||||||
|
|
||||||
|
it ('should compile the model to sql', ()=>{
|
||||||
|
const sql = cds.compile(m).to.sql().join(';\n')
|
||||||
|
expect(sql).not.to.match(/CREATE TABLE Sue_Foo/)
|
||||||
|
expect(sql).to.match(/CREATE TABLE Sue_Bar/)
|
||||||
|
})
|
||||||
|
})
|
||||||
6
test/events.cds
Normal file
6
test/events.cds
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
service Sue {
|
||||||
|
@cds.persistence.skip
|
||||||
|
entity Foo { key ID:Integer; title:String; status:String(1); }
|
||||||
|
entity Bar { key ID:Integer; foo: Association to Foo }
|
||||||
|
event Foo.changed : projection on Foo { ID, status }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user