diff --git a/test/cds.events.test.js b/test/cds.events.test.js new file mode 100644 index 00000000..1ebe576c --- /dev/null +++ b/test/cds.events.test.js @@ -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(//) + }) + + 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/) + }) +}) diff --git a/test/events.cds b/test/events.cds new file mode 100644 index 00000000..2eae34aa --- /dev/null +++ b/test/events.cds @@ -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 } +}