Files
cloud-cap-samples/test/hello-world.test.js
2020-08-19 09:38:07 +02:00

23 lines
679 B
JavaScript

const cds = require ('./cds')
const { GET, expect } = cds.test('serve','hello/world.cds').in(__dirname,'..')
describe('Hello world!', () => {
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!')
})
})