Added more tests

This commit is contained in:
Daniel
2020-04-05 18:55:30 +02:00
parent 428f1ce29d
commit f15a4f807e
3 changed files with 172 additions and 68 deletions

21
test/hello-world.test.js Normal file
View File

@@ -0,0 +1,21 @@
describe('Hello world!', () => {
const { GET, expect } = require('@capire/tests').launch('cds serve', __dirname+'/../hello/world.cds', '')
it('should say hello with class impl', async () => {
const {data} = await GET `/say/hello(to='world')`
expect(data.value).to.eql('Hello world!')
})
it('should say hello with another impl', async () => {
const cds = require ('@sap/cds')
cds.serve('say').from(cds.model)
.at('/say-again').in(cds.app)
.with(srv => {
srv.on('hello', (req) => `Hello again ${req.data.to}!`)
})
const {data} = await GET `/say-again/hello(to='world')`
expect(data.value).to.eql('Hello again world!')
})
})