forked from cap-js-community/odata-v2-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest.test.js
51 lines (41 loc) · 1.45 KB
/
rest.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
const cds = require("@sap/cds");
const supertest = require("supertest");
const util = require("./_env/util/request");
cds.test(__dirname + "/_env");
let request;
describe("rest", () => {
beforeAll(async () => {
await global._init;
request = supertest(cds.app.server);
});
it("GET rest", async () => {
const response = await util.callRead(request, "/rest/rest/Header", {
accept: "application/json",
});
expect(response.body).toBeDefined();
expect(response.body.length).toEqual(7);
});
it("GET reject rest for V2", async () => {
let response = await util.callRead(request, "/odata/v2/rest/rest/$metadata", {
accept: "application/json",
});
expect(response.body).toBeDefined();
expect(response.text).toEqual("Invalid service protocol. Only OData services supported");
response = await util.callRead(request, "/odata/v2/rest/rest/Header", {
accept: "application/json",
});
expect(response.body).toBeDefined();
expect(response.text).toEqual("Invalid service protocol. Only OData services supported");
});
it("GET not found for unknown", async () => {
let response = await util.callRead(request, "/odata/v2/rest/$metadata", {
accept: "application/json",
});
expect(response.status).toEqual(404);
response = await util.callRead(request, "/odata/v2/rest/Header", {
accept: "application/json",
});
expect(response.status).toEqual(404);
});
});