Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/protocols/hcql-adapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const cds = require('@sap/cds/lib')
const { GET, POST, DELETE, expect, axios } = cds.test(__dirname)

// Fetch API disallows GET|HEAD requests with body
if (axios.constructor.name === 'Naxios') it = it.skip
const FetchAPI = axios.constructor.name === 'Naxios'

const _unwrap = data => {
data = data.data ?? data
return Array.isArray(data) ? data : [data]
}

describe ('GET w/ query in body', () => {
FetchAPI || describe ('GET w/ query in body', () => {
it ('serves CQN query objects in body', async () => {
const { data, books = _unwrap(data) } = await GET ('/hcql/admin', {
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -97,7 +97,7 @@ describe ('Sluggified variants', () => {
expect(books[0]).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
})

it ('GET /Books/201 w/ CQL fragment in body' , async () => {
FetchAPI || it ('GET /Books/201 w/ CQL fragment in body' , async () => {
const { data, books = _unwrap(data) } = await GET ('/hcql/admin/Books/201', {
headers: { 'Content-Type': 'text/plain' },
data: `{ title, author.name as author }`
Expand All @@ -106,15 +106,15 @@ describe ('Sluggified variants', () => {
expect(books[0]).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
})

it ('GET /Books/201 w/ CQN fragment in body' , async () => {
FetchAPI || it ('GET /Books/201 w/ CQN fragment in body' , async () => {
const { data, books = _unwrap(data) } = await GET ('/hcql/admin/Books/201', {
data: cds.ql `SELECT title, author.name as author` .SELECT
})
expect(books).to.be.an('array').of.length(1)
expect(books[0]).to.deep.equal ({ title: "Wuthering Heights", author: "Emily Brontë" })
})

it ('GET /Books/201 w/ tail in URL plus CQL/CQN fragments in body' , async () => {
FetchAPI || it ('GET /Books/201 w/ tail in URL plus CQL/CQN fragments in body' , async () => {
const { data: d1, b1 = _unwrap(d1)[0] } = await GET ('/hcql/admin/Books where ID=201', {
data: cds.ql `SELECT title, author.name as author` .SELECT
})
Expand Down