Skip to content

Commit

Permalink
adding tags object test case
Browse files Browse the repository at this point in the history
  • Loading branch information
RoshniNaveenaS committed Nov 5, 2024
1 parent b01575d commit 5c8d1d4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
20 changes: 2 additions & 18 deletions test/lib/compile/csdl2openapi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,8 @@ describe('Edge cases', function () {
};
const openapi = lib.csdl2openapi(csdl, {});
assert.deepStrictEqual(openapi, expected, 'Empty CSDL document');
})

it('tags object exists and it does not have duplicates', function () {
const csdl = {
$EntityContainer: 'this.Container',
this: {
ET: { $Kind: 'EntityType', $Key: ['key'], key
: {} },
Container: {
Set: { $Type: 'this.ET', $Collection: true }
}
}
};
const openapi = lib.csdl2openapi(csdl, {});
assert.ok(openapi.tags, 'Tags object exists');
assert.strictEqual(openapi.tags.length, 1, 'Tags object does not have duplicates');
})

});

it('omit unused types', function () {
const csdl = {
$Reference: { dummy: { '$Include': [{ '$Namespace': 'Org.OData.Core.V1', '$Alias': 'Core' }] } },
Expand Down
34 changes: 34 additions & 0 deletions test/lib/compile/openapi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,40 @@ describe('OpenAPI export', () => {
expect(filesFound).toMatchObject(new Set(['.odata', '.rest']));
});

test('Check for tags object having any duplicate entries ', () => {
const csn = cds.compile.to.csn(`
namespace my.sample;
service CatalogService {
@title: 'Auditable Fields'
aspect Auditable {
createdAt : Timestamp;
createdBy : String;
modifiedAt : Timestamp;
modifiedBy : String;
}
entity Products : Auditable {
key ID : UUID;
name : String;
description : String;
price : Decimal(10, 2);
}
entity Orders : Auditable {
key ID : UUID;
orderDate : Date;
totalAmount : Decimal(10, 2);
product : Association to Products;
}
}
`);

const openAPI = toOpenApi(csn);
expect(openAPI).toBeDefined();
console.log(openAPI.tags);
expect(openAPI.tags.length).toBe(1);
});

test('multiple services', () => {
const csn = cds.compile.to.csn(`
service A {entity E { key ID : UUID; };};
Expand Down

0 comments on commit 5c8d1d4

Please sign in to comment.