Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz2 committed May 8, 2024
1 parent aa6104d commit d863510
Show file tree
Hide file tree
Showing 32 changed files with 1,163 additions and 1,019 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules/
reports/
test/
test-integration/
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ rules:
no-unused-vars: [off]
require-atomic-updates: [off]
jest/no-conditional-expect: [off]
jest/no-disabled-tests: [off]
jest/expect-expect: [off]
no-restricted-modules: [error, child_process] # security
no-eval: [error] # security
no-implied-eval: [error] # security
no-console: [error] # ops
no-useless-escape: [off]
strict: [off]
curly: [error]
no-constant-condition: [error, { checkLoops: false }]
Expand Down
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules/
reports/
test/
test-integration/
2 changes: 1 addition & 1 deletion test-integration/_env/app/parameters/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ui/generic/app/AppComponent"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
4 changes: 3 additions & 1 deletion test-integration/_env/srv/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const cov2ap = require("../../../src");
let credentials = JSON.parse(process.env.HANA_DB_CREDENTIALS || null);
try {
credentials = require("../db/default-services").hana[0].credentials;
} catch {}
} catch {
// ignore
}

cds.env.requires.db = {
kind: "hana",
Expand Down
16 changes: 8 additions & 8 deletions test-integration/integration-agreement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("integration-agreement", () => {
// Empty Parameters
let response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDate(datetime'2002-06-20T00:00:00')"
"/odata/v2/agreement/AgreementItemPricingForKeyDate(datetime'2002-06-20T00:00:00')",
);
expect(response.statusCode).toEqual(404);
expect(response.body).toBeDefined();
Expand Down Expand Up @@ -62,38 +62,38 @@ describe("integration-agreement", () => {
// Empty Set
response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2000-06-20T00:00:00')/Set"
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2000-06-20T00:00:00')/Set",
);
expect(response.body.d.results).toEqual([]);

// Parameters
response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDate(datetime'2022-06-20T00:00:00')"
"/odata/v2/agreement/AgreementItemPricingForKeyDate(datetime'2022-06-20T00:00:00')",
);
expect(response.body).toBeDefined();
expect(clean(response.body)).toMatchSnapshot();

// Result Set
response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2022-06-20T00:00:00')/Set"
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2022-06-20T00:00:00')/Set",
);
expect(response.body).toBeDefined();
expect(clean(response.body)).toMatchSnapshot();

// Single Entry
response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDateSet(keyDate=datetime'2022-06-20T00:00:00',ID=guid'f8420eac-a36b-49af-b91c-6559b8f7627e')"
"/odata/v2/agreement/AgreementItemPricingForKeyDateSet(keyDate=datetime'2022-06-20T00:00:00',ID=guid'f8420eac-a36b-49af-b91c-6559b8f7627e')",
);
expect(response.body).toBeDefined();
expect(clean(response.body)).toMatchSnapshot();

// Entry Parameters
response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDateSet(keyDate=datetime'2022-06-20T00:00:00',ID=guid'f8420eac-a36b-49af-b91c-6559b8f7627e')/Parameters"
"/odata/v2/agreement/AgreementItemPricingForKeyDateSet(keyDate=datetime'2022-06-20T00:00:00',ID=guid'f8420eac-a36b-49af-b91c-6559b8f7627e')/Parameters",
);
expect(response.body).toBeDefined();
expect(clean(response.body)).toMatchSnapshot();
Expand All @@ -102,15 +102,15 @@ describe("integration-agreement", () => {
it("GET with parameters and $count", async () => {
const response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2022-06-20T00:00:00')/Set/$count"
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2022-06-20T00:00:00')/Set/$count",
);
expect(response.text).toEqual("2");
});

it("GET with parameters and sort", async () => {
const response = await util.callRead(
request,
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2022-06-20T00:00:00')/Set?$skip=0&$top=20&$orderby=keyDate%20asc"
"/odata/v2/agreement/AgreementItemPricingForKeyDate(keyDate=datetime'2022-06-20T00:00:00')/Set?$skip=0&$top=20&$orderby=keyDate%20asc",
);
expect(response.body.d.results.length).toEqual(2);
});
Expand Down
52 changes: 37 additions & 15 deletions test-integration/integration-main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ describe("integration-main", () => {
// Single Entry
response = await util.callRead(
request,
`/odata/v2/main/HeaderParametersSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')`
`/odata/v2/main/HeaderParametersSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')`,
);
expect(response.body).toBeDefined();
expect(clean(response.body, ID)).toMatchSnapshot();

// Entry Parameters
response = await util.callRead(
request,
`/odata/v2/main/HeaderParametersSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')/Parameters`
`/odata/v2/main/HeaderParametersSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')/Parameters`,
);
expect(response.body).toBeDefined();
expect(clean(response.body, ID)).toMatchSnapshot();
Expand Down Expand Up @@ -181,14 +181,17 @@ describe("integration-main", () => {
expect(clean(response.body, ID)).toMatchSnapshot();

// Single Entry
response = await util.callRead(request, `/odata/v2/main/HeaderSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')`);
response = await util.callRead(
request,
`/odata/v2/main/HeaderSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')`,
);
expect(response.body).toBeDefined();
expect(clean(response.body, ID)).toMatchSnapshot();

// Entry Parameters
response = await util.callRead(
request,
`/odata/v2/main/HeaderSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')/Parameters`
`/odata/v2/main/HeaderSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')/Parameters`,
);
expect(response.body).toBeDefined();
expect(clean(response.body, ID)).toMatchSnapshot();
Expand Down Expand Up @@ -242,14 +245,17 @@ describe("integration-main", () => {
expect(clean(response.body, ID)).toMatchSnapshot();

// Single Entry
response = await util.callRead(request, `/odata/v2/main/HeaderUnionSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')`);
response = await util.callRead(
request,
`/odata/v2/main/HeaderUnionSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')`,
);
expect(response.body).toBeDefined();
expect(clean(response.body, ID)).toMatchSnapshot();

// Entry Parameters
response = await util.callRead(
request,
`/odata/v2/main/HeaderUnionSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')/Parameters`
`/odata/v2/main/HeaderUnionSetSet(STOCK=${stock},CURRENCY='EUR',ID=guid'${ID}')/Parameters`,
);
expect(response.body).toBeDefined();
expect(clean(response.body, ID)).toMatchSnapshot();
Expand All @@ -261,11 +267,20 @@ describe("integration-main", () => {
});
expect(response.statusCode).toEqual(201);
const id = response.body.d.ID;
response = await util.callRead(request, `/odata/v2/main/Header?$filter=ID eq guid'${id}' and substringof('es',name)`);
response = await util.callRead(
request,
`/odata/v2/main/Header?$filter=ID eq guid'${id}' and substringof('es',name)`,
);
expect(response.body.d.results).toHaveLength(1);
response = await util.callRead(request, `/odata/v2/main/Header?$filter=ID eq guid'${id}' and substringof('ES',name)`);
response = await util.callRead(
request,
`/odata/v2/main/Header?$filter=ID eq guid'${id}' and substringof('ES',name)`,
);
expect(response.body.d.results).toHaveLength(1);
response = await util.callRead(request, `/odata/v2/main/Header?$filter=ID eq guid'${id}' and substringof('XX',name)`);
response = await util.callRead(
request,
`/odata/v2/main/Header?$filter=ID eq guid'${id}' and substringof('XX',name)`,
);
expect(response.body.d.results).toHaveLength(0);
await util.callDelete(request, `/odata/v2/main/Header(guid'${id}')`);
});
Expand All @@ -276,11 +291,20 @@ describe("integration-main", () => {
});
expect(response.statusCode).toEqual(201);
const id = response.body.d.ID;
response = await util.callRead(request, `/odata/v2/main/Header?$filter=ID eq guid'${id}' and startswith(name,'Te')`);
response = await util.callRead(
request,
`/odata/v2/main/Header?$filter=ID eq guid'${id}' and startswith(name,'Te')`,
);
expect(response.body.d.results).toHaveLength(1);
response = await util.callRead(request, `/odata/v2/main/Header?$filter=ID eq guid'${id}' and startswith(name,'TE')`);
response = await util.callRead(
request,
`/odata/v2/main/Header?$filter=ID eq guid'${id}' and startswith(name,'TE')`,
);
expect(response.body.d.results).toHaveLength(1);
response = await util.callRead(request, `/odata/v2/main/Header?$filter=ID eq guid'${id}' and startswith(name,'XX')`);
response = await util.callRead(
request,
`/odata/v2/main/Header?$filter=ID eq guid'${id}' and startswith(name,'XX')`,
);
expect(response.body.d.results).toHaveLength(0);
await util.callDelete(request, `/odata/v2/main/Header(guid'${id}')`);
});
Expand Down Expand Up @@ -321,9 +345,7 @@ describe("integration-main", () => {

function clean(responseBody, ID) {
function replaceUri(text) {
return text
.replace(/localhost:([0-9]*)/g, "localhost:00000")
.replace(ID, "<ID>")
return text.replace(/localhost:([0-9]*)/g, "localhost:00000").replace(ID, "<ID>");
}

function replaceAll(entry) {
Expand Down
2 changes: 1 addition & 1 deletion test/_env/app/analytics/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ui/generic/app/AppComponent"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
2 changes: 1 addition & 1 deletion test/_env/app/basic/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ui/generic/app/AppComponent"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
2 changes: 1 addition & 1 deletion test/_env/app/draft/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ui/generic/app/AppComponent"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
2 changes: 1 addition & 1 deletion test/_env/app/hierarchy/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ui/generic/app/AppComponent"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
2 changes: 1 addition & 1 deletion test/_env/app/overview/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ovp/app/Component"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
2 changes: 1 addition & 1 deletion test/_env/app/xml/webapp/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ sap.ui.define(["sap/ui/generic/app/AppComponent"], (AppComponent) =>
metadata: {
manifest: "json",
},
})
}),
);
2 changes: 2 additions & 0 deletions test/_env/srv/handlers/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const cds = require("@sap/cds");

module.exports = (srv) => {
const { Header, HeaderStream, Book, User } = srv.entities("test.MainService");

Expand Down
10 changes: 5 additions & 5 deletions test/_env/srv/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ async function initData({ app }) {
});
responses.push(response);
}
console.log(
cds.log().info(
"Test Instances: " +
responses.filter((entry) => {
return entry.statusCode === 201;
}).length
}).length,
);
}

Expand All @@ -38,15 +38,15 @@ async function initBinary({ port }) {
data: file,
mediaType: "image/png",
filename: "file.png",
})
}),
);
await cds.run(
INSERT.into("test.HeaderStreamAttachment").entries({
ID: "f8a7a4f7-1901-4032-a237-3fba1d1b2343",
data: file,
mediaType: "image/png",
filename: "file.png",
})
}),
);
await cds.run(
INSERT.into("test.HeaderUrlStream").entries([
Expand All @@ -68,6 +68,6 @@ async function initBinary({ port }) {
mediaType: "image/png",
filename: "file.png",
},
])
]),
);
}
Loading

0 comments on commit d863510

Please sign in to comment.