From bf21d0220cbf414add1cc6f5b24bba4c7d5a0ea9 Mon Sep 17 00:00:00 2001 From: Christian Georgi Date: Fri, 7 Feb 2020 12:32:39 +0000 Subject: [PATCH] Test cosmetics, remove obsolete stuff --- packages/bookshop/package.json | 3 +- packages/bookshop/tests/bookshop.test.js | 9 ++--- packages/bookshop/tests/openSAP.http | 47 ------------------------ packages/bookshop/tests/utils.js | 23 ------------ 4 files changed, 5 insertions(+), 77 deletions(-) delete mode 100644 packages/bookshop/tests/openSAP.http delete mode 100644 packages/bookshop/tests/utils.js diff --git a/packages/bookshop/package.json b/packages/bookshop/package.json index b869f130..57c1cbee 100644 --- a/packages/bookshop/package.json +++ b/packages/bookshop/package.json @@ -9,6 +9,7 @@ "hdb": "^0.17.1" }, "scripts": { - "start": "npx cds run" + "start": "npx cds run", + "test": "../../node_modules/.bin/jest" } } diff --git a/packages/bookshop/tests/bookshop.test.js b/packages/bookshop/tests/bookshop.test.js index 454d0412..1b14195c 100644 --- a/packages/bookshop/tests/bookshop.test.js +++ b/packages/bookshop/tests/bookshop.test.js @@ -94,17 +94,14 @@ describe('Bookshop: OData Protocol Level Testing', () => { describe('Bookshop: CDS Service Level Testing', () => { let srv, Books - test('Should serve bookshop', async () => { + it('Should serve bookshop', async () => { srv = await cds.serve('CatalogService').from(__dirname + '/../srv/cat-service') Books = srv.entities.Books expect(Books).toBeDefined() }) - test('GET all books', async () => { - const books = await srv.read( - //Books, b=>{ b.ID, b.title } - Books, b => { b.title } - ) + it('GETs all books', async () => { + const books = await srv.read(Books, b => { b.title }) expect(books).toMatchObject([ { title: 'Wuthering Heights' }, diff --git a/packages/bookshop/tests/openSAP.http b/packages/bookshop/tests/openSAP.http deleted file mode 100644 index 64e3bff5..00000000 --- a/packages/bookshop/tests/openSAP.http +++ /dev/null @@ -1,47 +0,0 @@ -########################################## -# Test bookstore -########################################## - -@PORT = 4004 -@HOST = localhost -####### -# List books -####### - -GET http://{{HOST}}:{{PORT}}/browse/Books HTTP/1.1 - -### List Books with their current stocks via Browse service -### title containts "discount" info due to custom handler in cat-service.js -GET http://{{HOST}}:{{PORT}}/browse/Books?$select=ID,title,stock - -### List Books with their current stocks via Admin service -### title DOES NOT containt "discount" info as there is no custom handler for admin service -# skip admin service -# GET http://{{HOST}}:{{PORT}}/admin/Books?$select=ID,title,stock - -### List all Orders -GET http://{{HOST}}:{{PORT}}/admin/Orders?&$expand=Items - -####### -# Create order -####### -# Sending this three times should result in a 409: 5 exceeds stock for book #201 -POST http://{{HOST}}:{{PORT}}/browse/Orders HTTP/1.1 -Content-Type: application/json;IEEE754Compatible=true - -{ "OrderNo":"2019-09...", "Items":[ - { "book_ID":201, "amount":3 }, - { "book_ID":207, "amount":3 } -]} - - -####### -# Delete order not allowed due to annotation @insertonly in cat-service.cds -####### -DELETE http://{{HOST}}:{{PORT}}//browse/Orders/7e2f2640-6866-4dcf-8f4d-3027aa831cad HTTP/1.1 - - -####### -# List order not allowed due to @insertonly -####### -GET http://{{HOST}}:{{PORT}}//browse/Orders HTTP/1.1 diff --git a/packages/bookshop/tests/utils.js b/packages/bookshop/tests/utils.js deleted file mode 100644 index 7323ae85..00000000 --- a/packages/bookshop/tests/utils.js +++ /dev/null @@ -1,23 +0,0 @@ -const cds = require('@sap/cds/lib/cds') -const run = require('@sap/cds/bin/run') - -let testServer -const cwd = process.cwd() - -const setup = (model, done) => { - cds.once('listening', ({ server }) => { - testServer = server - done() - }) - run([model], { 'in-memory?': true }) -} - -const close = done => { - testServer.close(done) - process.chdir(cwd) -} - -module.exports = { - setup, - close -} \ No newline at end of file