Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 2f5d159

Browse files
committed
using cds.test
1 parent 2be3d50 commit 2f5d159

File tree

9 files changed

+16
-17
lines changed

9 files changed

+16
-17
lines changed

test/cds.ql.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { expect } = require('../test')
21
const cds = require('@sap/cds/lib')
2+
const { expect } = cds.test
33
const CQL = ([cql]) => cds.parse.cql(cql)
44
const Foo = { name: 'Foo' }
55
const Books = { name: 'capire.bookshop.Books' }

test/consuming-services.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const { expect } = require('../test') .run (
1+
const cds = require('@sap/cds/lib')
2+
const { expect } = cds.test (
23
'serve', 'AdminService', '--from', '@capire/bookshop,@capire/common', '--in-memory'
34
)
4-
const cds = require('@sap/cds/lib')
55

66
describe('Consuming Services locally', () => {
77
//
8-
it('bootrapped the database successfully', ()=>{
8+
it('bootstrapped the database successfully', ()=>{
99
const { AdminService } = cds.services
1010
const { Authors } = AdminService.entities
1111
expect(AdminService).not.to.be.undefined

test/custom-handlers.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const { GET, POST, expect } = require('../test') .run ('bookshop')
21
const cds = require('@sap/cds/lib')
2+
const { GET, POST, expect } = cds.test(__dirname+'/../bookshop')
33
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
44
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
55

66
describe('Custom Handlers', () => {
77

88
it('should reject out-of-stock orders', async () => {
9-
await POST('/browse/submitOrder', { book: 201, amount: 5 })
10-
await POST('/browse/submitOrder', { book: 201, amount: 5 })
11-
await expect(POST('/browse/submitOrder', { book: 201, amount: 5 })).to.be.rejectedWith(/409 - 5 exceeds stock for book #201/)
9+
await POST `/browse/submitOrder ${{ book: 201, amount: 5 }}`
10+
await POST `/browse/submitOrder ${{ book: 201, amount: 5 }}`
11+
await expect(POST `/browse/submitOrder ${{ book: 201, amount: 5 }}`).to.be.rejectedWith(/409 - 5 exceeds stock for book #201/)
1212
const { data } = await GET`/admin/Books/201/stock/$value`
1313
expect(data).to.equal(2)
1414
})

test/hello-world.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const { GET, expect } = require('../test') .run ('serve','hello/srv/world.cds')
1+
const cds = require('@sap/cds/lib')
2+
const { GET, expect } = cds.test (__dirname+'/../hello')
23

34
describe('Hello world!', () => {
45

test/hierarchical-data.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const {expect} = require('../test')
21
const cds = require('@sap/cds/lib')
2+
const {expect} = cds.test
33

44
const { parse:cdr } = cds.ql
55

test/index.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/localized-data.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { GET, expect } = require('../test') .run ('serve', 'test/localized-data.cds', '--in-memory')
21
const cds = require('@sap/cds/lib')
2+
const { GET, expect } = cds.test.run ('serve', __dirname+'/localized-data.cds', '--in-memory')
33
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
44
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
55

test/messaging.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { expect } = require('../test')
21
const cds = require('@sap/cds/lib')
2+
const { expect } = cds.test
33
const _model = '@capire/reviews'
44
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
55
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases

test/odata.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { GET, expect } = require('../test') .run ('bookshop')
21
const cds = require('@sap/cds/lib')
2+
const { GET, expect } = cds.test ('@capire/bookshop')
33
if (cds.User.default) cds.User.default = cds.User.Privileged // hard core monkey patch
44
else cds.User = cds.User.Privileged // hard core monkey patch for older cds releases
55

@@ -18,9 +18,9 @@ describe('OData Protocol', () => {
1818
})
1919

2020
it('supports $search in multiple fields', async () => {
21-
const { data } = await GET(`/browse/Books`, {
21+
const { data } = await GET `/browse/Books ${{
2222
params: { $search: 'Po', $select: `title,author` },
23-
})
23+
}}`
2424
expect(data.value).to.eql([
2525
{ ID: 201, title: 'Wuthering Heights', author: 'Emily Brontë' },
2626
{ ID: 207, title: 'Jane Eyre', author: 'Charlotte Brontë' },

0 commit comments

Comments
 (0)