Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bookstore
Submodule bookstore updated 2 files
+12 −5 readme.md
+1 −1 srv/mashup.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"orders": "cds watch orders",
"reviews": "cds watch reviews",
"lint": "npx eslint",
"test": "chest",
"test": "npx jest",
"jest": "npx jest",
"mocha": "npx mocha",
"node:test": "node --test",
Expand Down
2 changes: 1 addition & 1 deletion reviews
30 changes: 29 additions & 1 deletion tests/protocols/hcql-adapter.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const cds = require('@sap/cds/lib')
const { GET, expect, axios } = cds.test(__dirname)
const { GET, POST, DELETE, expect, axios } = cds.test(__dirname)

// Fetch API disallows GET|HEAD requests with body
if (axios.constructor.name === 'Naxios') it = it.skip
Expand Down Expand Up @@ -123,4 +123,32 @@ describe ('Sluggified variants', () => {
expect(b2).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
})

})


describe ('CREATE', () => {

it ('creates entities', async () => {
let res = await POST ('/hcql/admin/Books', { title: "Neuromancer", author_ID: 101 })
// expect(res.status).to.equal(201)
expect(res.data).to.have.property('ID') // server-generated ID
})

})

describe ('DELETE', () => {

it ('deletes single entities with affected rows as result', async () => {
let res = await DELETE `/hcql/admin/Books/201`
expect(res.status).to.equal(200)
expect(res.data).to.equal(1) // 1 affected row
})

it ('deletes multiple entities with affected rows as result', async () => {
const { DELETE } = cds.ql
let res = await POST ('/hcql/admin', DELETE.from `Books` .where `author.name = 'Edgar Allen Poe'`)
expect(res.status).to.equal(200)
expect(res.data).to.equal(2) // 2 affected rows
})

})