-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add default unittest * add new line * add templates unittest * Adjust unittest for latest main branch * add test placeholder * add newline * use snapshot instead of equal * remove comments and format test file * increase indent_size to 4 * reset default.js * fix cds 8.2.0 removed map function * udpate snapshot
- Loading branch information
1 parent
388c566
commit 5b14cc7
Showing
10 changed files
with
436 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`defaults $schema should return default value 1`] = `"https://sap.github.io/open-resource-discovery/spec-v1/interfaces/Document.schema.json"`; | ||
|
||
exports[`defaults baseTemplate should return default value 1`] = ` | ||
{ | ||
"openResourceDiscoveryV1": { | ||
"documents": [ | ||
{ | ||
"accessStrategies": [ | ||
{ | ||
"type": "open", | ||
}, | ||
], | ||
"url": "/open-resource-discovery/v1/documents/1", | ||
}, | ||
], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`defaults consumptionBundles should return default value 1`] = ` | ||
[ | ||
{ | ||
"description": "This Consumption Bundle contains all resources of the reference app which are unprotected and do not require authentication", | ||
"ordId": "MyConsumptionBundle:consumptionBundle:unknown:v1", | ||
"shortDescription": "If we have another protected API then it will be another object", | ||
"title": "Unprotected resources", | ||
"version": "1.0.0", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`defaults description should return default value 1`] = `"this is an application description"`; | ||
|
||
exports[`defaults groupTypeId should return default value 1`] = `"sap.cds:service"`; | ||
|
||
exports[`defaults openResourceDiscovery should return default value 1`] = `"1.9"`; | ||
|
||
exports[`defaults packages should return default value if policyLevel contains sap 1`] = ` | ||
[ | ||
{ | ||
"description": "Description for My Package", | ||
"ordId": "MyPackage:package:sample-api:v1", | ||
"partOfProducts": [ | ||
"customer:product:My.Package:", | ||
], | ||
"shortDescription": "Short description for My Package", | ||
"title": "My Package", | ||
"vendor": "customer:vendor:Customer:", | ||
"version": "1.0.0", | ||
}, | ||
{ | ||
"description": "Description for My Package", | ||
"ordId": "MyPackage:package:sample-event:v1", | ||
"partOfProducts": [ | ||
"customer:product:My.Package:", | ||
], | ||
"shortDescription": "Short description for My Package", | ||
"title": "My Package", | ||
"vendor": "customer:vendor:Customer:", | ||
"version": "1.0.0", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`defaults packages should return default value if policyLevel does not contain sap 1`] = ` | ||
[ | ||
{ | ||
"description": "Description for My Package", | ||
"ordId": "MyPackage:package:sample:v1", | ||
"partOfProducts": [ | ||
"customer:product:My.Package:", | ||
], | ||
"shortDescription": "Short description for My Package", | ||
"title": "My Package", | ||
"vendor": "customer:vendor:Customer:", | ||
"version": "1.0.0", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`defaults policyLevel should return default value 1`] = `"none"`; | ||
|
||
exports[`defaults products should return default value 1`] = ` | ||
[ | ||
{ | ||
"ordId": "customer:product:My.Product:", | ||
"shortDescription": "Description for My Product", | ||
"title": "My Product", | ||
"vendor": "customer:vendor:customer:", | ||
}, | ||
] | ||
`; |
110 changes: 110 additions & 0 deletions
110
__tests__/unittest/__snapshots__/templates.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`templates checkEntityFunctionAction should fail when entity is empty 1`] = ` | ||
[ | ||
{ | ||
"entitySet": "customer.testNamespace123.Books", | ||
"entitySetMapping": "undefined:entitySet:customer.testNamespace123.Books:v1", | ||
"entityType": "customer.testNamespace123.Books", | ||
"entityTypeMapping": "undefined:entityType:customer.testNamespace123.Books:v1", | ||
"name": "customer.testNamespace123.Books", | ||
"type": "entity", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`templates checkEntityFunctionAction should return entity 1`] = ` | ||
[ | ||
{ | ||
"entitySet": "customer.testNamespace123.Books", | ||
"entitySetMapping": "undefined:entitySet:customer.testNamespace123.Books:v1", | ||
"entityType": "customer.testNamespace123.Books", | ||
"entityTypeMapping": "undefined:entityType:customer.testNamespace123.Books:v1", | ||
"name": "customer.testNamespace123.Books", | ||
"type": "entity", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`templates fCreateAPIResourceTemplate should create API resource template correctly 1`] = ` | ||
[ | ||
{ | ||
"apiProtocol": "odata-v4", | ||
"description": "Here we have the description for MyService", | ||
"entityTypeMappings": [ | ||
{ | ||
"entityTypeTargets": undefined, | ||
}, | ||
], | ||
"entryPoints": [ | ||
"/odata/v4/my", | ||
], | ||
"extensible": { | ||
"supported": "no", | ||
}, | ||
"ordId": "customer:apiResource:undefined.MyService:v1", | ||
"partOfGroups": [ | ||
"sap.cds:service:customer:undefined.MyService", | ||
], | ||
"partOfPackage": undefined, | ||
"releaseStatus": "active", | ||
"resourceDefinitions": [ | ||
{ | ||
"accessStrategies": [ | ||
{ | ||
"type": "open", | ||
}, | ||
], | ||
"mediaType": "application/json", | ||
"type": "openapi-v3", | ||
"url": "/.well-known/open-resource-discovery/v1/api-metadata/MyService.oas3.json", | ||
}, | ||
{ | ||
"accessStrategies": [ | ||
{ | ||
"type": "open", | ||
}, | ||
], | ||
"mediaType": "application/xml", | ||
"type": "edmx", | ||
"url": "/.well-known/open-resource-discovery/v1/api-metadata/MyService.edmx", | ||
}, | ||
], | ||
"shortDescription": "Here we have the shortDescription for MyService", | ||
"title": "The service is for MyService", | ||
"version": "1.0.0", | ||
"visibility": "public", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`templates fCreateEventResourceTemplate should create API resource template correctly 1`] = ` | ||
{ | ||
"description": "This is an example event catalog that contains only a partial ODM testAppName V1 event", | ||
"extensible": { | ||
"supported": "no", | ||
}, | ||
"ordId": "customer:eventResource:undefined.MyService:v1", | ||
"partOfGroups": [ | ||
"sap.cds:service:customer:undefined.MyService", | ||
], | ||
"partOfPackage": undefined, | ||
"releaseStatus": "beta", | ||
"resourceDefinitions": [ | ||
{ | ||
"accessStrategies": [ | ||
{ | ||
"type": "open", | ||
}, | ||
], | ||
"mediaType": "application/json", | ||
"type": "asyncapi-v2", | ||
"url": "/.well-known/open-resource-discovery/v1/api-metadata/MyService.asyncapi2.json", | ||
}, | ||
], | ||
"shortDescription": "Example ODM Event", | ||
"title": "ODM testAppName Events", | ||
"version": "1.0.0", | ||
"visibility": "public", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const defaults = require('../../lib/defaults'); | ||
|
||
describe('defaults', () => { | ||
describe('$schema', () => { | ||
it('should return default value', () => { | ||
expect(defaults.$schema).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('openResourceDiscovery', () => { | ||
it('should return default value', () => { | ||
expect(defaults.openResourceDiscovery).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('policyLevel', () => { | ||
it('should return default value', () => { | ||
expect(defaults.policyLevel).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('description', () => { | ||
it('should return default value', () => { | ||
expect(defaults.description).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('products', () => { | ||
const testProductsName = 'My Product'; | ||
it('should return default value', () => { | ||
expect(defaults.products(testProductsName)).toMatchSnapshot() | ||
}); | ||
}); | ||
|
||
describe('groupTypeId', () => { | ||
it('should return default value', () => { | ||
expect(defaults.groupTypeId).toMatchSnapshot() | ||
}); | ||
}); | ||
|
||
describe('packages', () => { | ||
const testGetPackageDataName = 'My Package'; | ||
const testGetPackageCapNamespace = 'sample'; | ||
it('should return default value if policyLevel contains sap', () => { | ||
const testPolicyLevel = 'sap:policy'; | ||
|
||
expect(defaults.packages(testGetPackageDataName, testPolicyLevel, testGetPackageCapNamespace)).toMatchSnapshot(); | ||
}); | ||
|
||
it('should return default value if policyLevel does not contain sap', () => { | ||
const testPolicyLevel = 'policy'; | ||
|
||
expect(defaults.packages(testGetPackageDataName, testPolicyLevel, testGetPackageCapNamespace)).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('consumptionBundles', () => { | ||
const testConsumptionBundlesName = 'My Consumption Bundle'; | ||
it('should return default value', () => { | ||
expect(defaults.consumptionBundles(testConsumptionBundlesName)).toMatchSnapshot(); | ||
}); | ||
}); | ||
describe('baseTemplate', () => { | ||
it('should return default value', () => { | ||
expect(defaults.baseTemplate).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('metaData', () => { | ||
it('test placeholder', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('ord', () => { | ||
it('test placeholder', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('plugin', () => { | ||
it('test placeholder', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.