Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
aramovic79 committed Dec 9, 2024
1 parent a5fdaee commit 2860721
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
11 changes: 1 addition & 10 deletions __tests__/mockedCsn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const cds = require("@sap/cds");
const path = require("path");

describe("Tests for ORD document generated out of mocked csn files", () => {
let ord; //, errorSpy;
let ord;

function checkOrdDocument(csn) {
const document = ord(csn);
Expand All @@ -26,7 +26,6 @@ describe("Tests for ORD document generated out of mocked csn files", () => {
description: "this is my custom description",
policyLevel: "sap:core:v1"
};
// errorSpy = jest.spyOn(console, "error");
});

afterAll(() => {
Expand Down Expand Up @@ -101,12 +100,4 @@ describe("Tests for ORD document generated out of mocked csn files", () => {
expect(document.eventResources[0].ordId).toEqual(expect.stringContaining("CatalogService"));
});
});

describe("Tests for ORD document when namespace is not correctly defined", () => {
test("Namespace is not correctly defined in cdsrc.json: throw error", () => {
cds.env.ord.namespace = "invalid_namespace";
const csn = require("./__mocks__/publicResourcesCsn.json");
expect(() => ord(csn)).toThrowError(expect.objectContaining({"message": expect.stringContaining("Namespace is not correctly defined in cdsrc.json")}));
});
});
});
4 changes: 2 additions & 2 deletions __tests__/unittest/__snapshots__/templates.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ exports[`templates createEntityTypeTemplate should return entity type with incor
"lastUpdate": "2022-12-19T15:47:04+00:00",
"level": "root-entity",
"localId": "SomeAribaDummyEntity",
"ordId": "sap.sm:entityType:SomeAribaDummyEntity:v1.2b.3",
"ordId": "sap.sm:entityType:SomeAribaDummyEntity:v3b",
"partOfPackage": "sap.test.cdsrc.sample:package:test-entityType:v1",
"releaseStatus": "active",
"shortDescription": "Short description of SomeAribaDummyEntity",
"title": "Title of SomeAribaDummyEntity",
"version": "v1.2b.3",
"version": "3b.0.0",
"visibility": "public",
}
`;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/unittest/templates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('templates', () => {
const packageIds = ['sap.test.cdsrc.sample:package:test-entityType:v1'];
it('should return entity type with incorrect version, title and level:root-entity', () => {
const entityWithVersion = {
ordId: "sap.sm:entityType:SomeAribaDummyEntity:v1.2b.3",
ordId: "sap.sm:entityType:SomeAribaDummyEntity:v3b",
entityName: "SomeAribaDummyEntity",
"@title": "Title of SomeAribaDummyEntity",
"@ObjectModel.compositionRoot": true,
Expand All @@ -48,7 +48,7 @@ describe('templates', () => {
expect(entityType).toBeDefined();
expect(entityType).toMatchSnapshot();
expect(warningSpy).toHaveBeenCalledTimes(1);
expect(entityType.version).toEqual('v1.2b.3');
expect(entityType.version).toEqual('3b.0.0');
expect(entityType.level).toEqual('root-entity');
expect(entityType.partOfPackage).toEqual('sap.test.cdsrc.sample:package:test-entityType:v1');
});
Expand Down
4 changes: 2 additions & 2 deletions lib/ord.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ function _getConsumptionBundles(appConfig) {
function validateNamespace(appConfig) {
const validateSystemNamespace = new RegExp(`^${appConfig.eventApplicationNamespace}\\.[^.]+\\..+$`);
if (
appConfig.ordNamespace === undefined ||
appConfig.ordNamespace === undefined &&
!validateSystemNamespace.test(appConfig.ordNamespace)
) {
let error = new Error(
`Namespace is not correctly defined in cdsrc.json or it is not in the format of ${appConfig.eventApplicationNamespace}.<appName>.<service>`
`Namespace is not defined in cdsrc.json or it is not in the format of ${appConfig.eventApplicationNamespace}.<appName>.<service>`
);
Logger.error('Namespace error:', error.message);
throw error;
Expand Down

0 comments on commit 2860721

Please sign in to comment.