Files
cloud-cap-samples/test/custom-handlers.test.js
Daniel Hutzel 7b92463394 Spring cleaning, part 2 (#813)
* Remove OData v2 show case: Genres TreeView
* Refactored bookstore and fiori services: consolidate routing and remove deprecated files
* Add Jest configuration file with silent mode enabled
* Refactor test files: streamline imports and remove redundant code
* Change price field type to Price for better clarity and precision
* Example for separation of concerns: access-control.cds
2025-03-21 09:48:11 +01:00

16 lines
691 B
JavaScript

const cds = require('@sap/cds')
const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
cds.User.default = cds.User.Privileged // hard core monkey patch
describe('cap/samples - Custom Handlers', () => {
it('should reject out-of-stock orders', async () => {
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.fulfilled
await expect(POST `/browse/submitOrder ${{ book: 201, quantity: 5 }}`).to.be.rejectedWith(
/409 - 5 exceeds stock for book #201/)
const { data } = await GET`/admin/Books/201/stock/$value`
expect(data).to.equal(2)
})
})