Skip to content

Commit

Permalink
Use sap/cds lib in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chgeo committed Jan 16, 2024
1 parent 300cec5 commit ae6f43a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/typescript/apis/project/cds-core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cds from '../../../../apis/cds'
import cds from '@sap/cds'

const x = cds.extend({ a: 42 }).with({ b: 'hello world' })
const a: number = x.a
Expand Down
15 changes: 7 additions & 8 deletions test/typescript/apis/project/cds-cqn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as cqn from "../../../../apis/cqn";
import cds from '@sap/cds'

// we just access expected properties without doing anything with them to see if they are present
// as expected. To apease the linter, we assign them to a variable.
let res = undefined

// CQN
const sqn: cqn.SELECT = {SELECT:{from:{ ref:[ 'Foo' ]}}}
const sqn: cds.SELECT = {SELECT:{from:{ ref:[ 'Foo' ]}}}
// order by
sqn.SELECT.orderBy = [{ ref: ["bar"], sort: "desc" }]
sqn.SELECT.orderBy = [{ ref: ["bar"], sort: "asc" }]
Expand All @@ -26,35 +26,34 @@ res = sqn.SELECT.limit
res = sqn.SELECT.mixin

// Runtime only...
import cds from "../../../../apis/cds";
let q = SELECT.from('Foo')
res = q.SELECT.forUpdate
res = q.SELECT.forShareLock
res = q.SELECT.search
res = q.SELECT.count

const iqn: cqn.INSERT = undefined as unknown as cqn.INSERT
const iqn: cds.INSERT = undefined as unknown as cds.INSERT
res = iqn.INSERT.into.hasOwnProperty('ref') || (typeof iqn.INSERT.into === 'string')
res = iqn.INSERT.columns
res = iqn.INSERT.values
res = iqn.INSERT.rows
res = iqn.INSERT.entries
res = iqn.INSERT.as.SELECT

const uqn: cqn.UPDATE = undefined as unknown as cqn.UPDATE
const uqn: cds.UPDATE = undefined as unknown as cds.UPDATE
res = uqn.UPDATE.data['foo']
// res = uqn.UPDATE.entity.toLowerCase() // lazy "type check" for string
res = uqn.UPDATE.where?.at(0)

const dqn: cqn.DELETE = undefined as unknown as cqn.DELETE
const dqn: cds.DELETE = undefined as unknown as cds.DELETE
// res = dqn.DELETE.from.toLowerCase() // lazy "type check" for string
res = dqn.DELETE.where?.at(0)

const crqn: cqn.CREATE = undefined as unknown as cqn.CREATE
const crqn: cds.CREATE = undefined as unknown as cds.CREATE
res = crqn.CREATE.entity.hasOwnProperty('ref') || (typeof crqn.CREATE.entity === 'string') // lazy "type check" for string
res = crqn.CREATE.as.SELECT

const drqn: cqn.DROP = undefined as unknown as cqn.DROP
const drqn: cds.DROP = undefined as unknown as cds.DROP
res = drqn.DROP.entity.toLowerCase() // lazy "type check" for string
res = drqn.DROP.table.ref
res = drqn.DROP.view.ref
2 changes: 1 addition & 1 deletion test/typescript/apis/project/cds-exit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import cds from '../../../../apis/cds'
import cds from '@sap/cds'

cds.exit()
2 changes: 1 addition & 1 deletion test/typescript/apis/project/cds-log.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cds from '../../../..'
import cds from '@sap/cds'
import * as winston from "winston"

cds.log('foo').debug('message')
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/apis/project/cds-services.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cds from '../../../..'
import cds from '@sap/cds'
import { Foo, Foos, action } from './dummy'

const model = cds.reflect({})
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/apis/project/cds-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cds from '../../../..'
import cds from '@sap/cds'

const test = cds.test(__dirname).in('other')
cds.test('serve', '--in-memory', '--project', __dirname)
Expand Down
3 changes: 1 addition & 2 deletions test/typescript/apis/project/cds-user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cds from '../../../..'
import { User } from '../../../../apis/cds'
import cds, { User } from '@sap/cds'

// accepts no args
const user = new User()
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/apis/project/cds-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cds from '../../../..'
import cds from '@sap/cds'

const uuid: string = cds.utils.uuid()
const decodeURI: string = cds.utils.decodeURI('https://developer.mozilla.org/docs/JavaScript%3A%20a_scripting_language')
Expand Down

0 comments on commit ae6f43a

Please sign in to comment.