diff --git a/test/cds.ql.test.js b/test/cds.ql.test.js index b6d23c6e..1a6fc861 100644 --- a/test/cds.ql.test.js +++ b/test/cds.ql.test.js @@ -1,5 +1,5 @@ -const { expect } = require('../test') const cds = require('@sap/cds/lib') +const { expect } = cds.test const CQL = ([cql]) => cds.parse.cql(cql) const Foo = { name: 'Foo' } const Books = { name: 'capire.bookshop.Books' } diff --git a/test/consuming-services.test.js b/test/consuming-services.test.js index ff5c1b96..97c9db24 100644 --- a/test/consuming-services.test.js +++ b/test/consuming-services.test.js @@ -1,11 +1,11 @@ -const { expect } = require('../test') .run ( +const cds = require('@sap/cds/lib') +const { expect } = cds.test ( 'serve', 'AdminService', '--from', '@capire/bookshop,@capire/common', '--in-memory' ) -const cds = require('@sap/cds/lib') describe('Consuming Services locally', () => { // - it('bootrapped the database successfully', ()=>{ + it('bootstrapped the database successfully', ()=>{ const { AdminService } = cds.services const { Authors } = AdminService.entities expect(AdminService).not.to.be.undefined diff --git a/test/custom-handlers.test.js b/test/custom-handlers.test.js index 80b9ed71..f3c422d1 100644 --- a/test/custom-handlers.test.js +++ b/test/custom-handlers.test.js @@ -1,14 +1,14 @@ -const { GET, POST, expect } = require('../test') .run ('bookshop') const cds = require('@sap/cds/lib') +const { GET, POST, expect } = cds.test(__dirname+'/../bookshop') if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases describe('Custom Handlers', () => { it('should reject out-of-stock orders', async () => { - await POST('/browse/submitOrder', { book: 201, amount: 5 }) - await POST('/browse/submitOrder', { book: 201, amount: 5 }) - await expect(POST('/browse/submitOrder', { book: 201, amount: 5 })).to.be.rejectedWith(/409 - 5 exceeds stock for book #201/) + await POST `/browse/submitOrder ${{ book: 201, amount: 5 }}` + await POST `/browse/submitOrder ${{ book: 201, amount: 5 }}` + await expect(POST `/browse/submitOrder ${{ book: 201, amount: 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) }) diff --git a/test/hello-world.test.js b/test/hello-world.test.js index 346b295f..1b22a602 100644 --- a/test/hello-world.test.js +++ b/test/hello-world.test.js @@ -1,4 +1,5 @@ -const { GET, expect } = require('../test') .run ('serve','hello/srv/world.cds') +const cds = require('@sap/cds/lib') +const { GET, expect } = cds.test (__dirname+'/../hello') describe('Hello world!', () => { diff --git a/test/hierarchical-data.test.js b/test/hierarchical-data.test.js index dafa2367..00a4a2b1 100644 --- a/test/hierarchical-data.test.js +++ b/test/hierarchical-data.test.js @@ -1,5 +1,5 @@ -const {expect} = require('../test') const cds = require('@sap/cds/lib') +const {expect} = cds.test const { parse:cdr } = cds.ql diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 5a4fdd26..00000000 --- a/test/index.js +++ /dev/null @@ -1,2 +0,0 @@ -const cds = require('@sap/cds') -module.exports = cds.test.in(__dirname,'..') diff --git a/test/localized-data.test.js b/test/localized-data.test.js index 5ba9bd19..4d399786 100644 --- a/test/localized-data.test.js +++ b/test/localized-data.test.js @@ -1,5 +1,5 @@ -const { GET, expect } = require('../test') .run ('serve', 'test/localized-data.cds', '--in-memory') const cds = require('@sap/cds/lib') +const { GET, expect } = cds.test.run ('serve', __dirname+'/localized-data.cds', '--in-memory') if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases diff --git a/test/messaging.test.js b/test/messaging.test.js index 3e2176b1..cd01e4a6 100644 --- a/test/messaging.test.js +++ b/test/messaging.test.js @@ -1,5 +1,5 @@ -const { expect } = require('../test') const cds = require('@sap/cds/lib') +const { expect } = cds.test const _model = '@capire/reviews' if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases diff --git a/test/odata.test.js b/test/odata.test.js index 7d8c8123..43b90791 100644 --- a/test/odata.test.js +++ b/test/odata.test.js @@ -1,5 +1,5 @@ -const { GET, expect } = require('../test') .run ('bookshop') const cds = require('@sap/cds/lib') +const { GET, expect } = cds.test ('@capire/bookshop') if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases @@ -18,9 +18,9 @@ describe('OData Protocol', () => { }) it('supports $search in multiple fields', async () => { - const { data } = await GET(`/browse/Books`, { + const { data } = await GET `/browse/Books ${{ params: { $search: 'Po', $select: `title,author` }, - }) + }}` expect(data.value).to.eql([ { ID: 201, title: 'Wuthering Heights', author: 'Emily Brontë' }, { ID: 207, title: 'Jane Eyre', author: 'Charlotte Brontë' },