-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1fb6c3
commit a1cf0a8
Showing
6 changed files
with
760 additions
and
6 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"printWidth": 150 | ||
"printWidth": 200 | ||
} |
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 |
---|---|---|
@@ -1,17 +1,21 @@ | ||
const cds = require("@sap/cds"); | ||
const { validateNotificationTypes, readFile } = require("./utils"); | ||
const { createNotificationTypesMap, processNotificationTypes } = require("./notificationTypes"); | ||
const { processNotificationTypes } = require("./notificationTypes"); | ||
const { setGlobalLogLevel } = require("@sap-cloud-sdk/util"); | ||
|
||
async function deployNotificationTypes() { | ||
setGlobalLogLevel("error"); | ||
|
||
// read notification types | ||
const notificationTypes = readFile(cds.env.requires?.notifications?.types); | ||
const notificationTypes = readFile(cds.env?.requires?.notifications?.types); | ||
|
||
if (validateNotificationTypes(notificationTypes)) { | ||
await processNotificationTypes(notificationTypes); | ||
} | ||
} | ||
|
||
deployNotificationTypes(); | ||
|
||
module.exports = { | ||
deployNotificationTypes | ||
} |
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
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
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,49 @@ | ||
// import required modules and functions | ||
const cds = require("@sap/cds"); | ||
const { validateNotificationTypes, readFile } = require("../../lib/utils"); | ||
const { processNotificationTypes } = require("../../lib/notificationTypes"); | ||
const { setGlobalLogLevel } = require("@sap-cloud-sdk/util"); | ||
const { expect } = require("chai"); | ||
|
||
jest.mock("@sap/cds"); | ||
jest.mock("../../lib/utils"); | ||
jest.mock("../../lib/notificationTypes"); | ||
jest.mock("@sap-cloud-sdk/util"); | ||
|
||
const contentDeployment = require("../../lib/content-deployment"); | ||
|
||
describe("contentDeployment", () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test("Given valid notification types | When Deploy is called | Then process is called", async () => { | ||
setGlobalLogLevel.mockImplementation(() => undefined); | ||
readFile.mockImplementation(() => []); | ||
validateNotificationTypes.mockImplementation(() => true); | ||
processNotificationTypes.mockImplementation(() => Promise.resolve()); | ||
|
||
await contentDeployment.deployNotificationTypes(); | ||
|
||
console.log(setGlobalLogLevel.mock.calls) | ||
assert.expect(setGlobalLogLevel.mock.calls[0][0]).to.be.equal("error"); | ||
assert.expect(readFile.mock.calls[0][0]).to.be.equal(cds.env?.requires?.notifications?.types); | ||
assert.expect(validateNotificationTypes.mock.calls[0][0]).to.be.deep.equal([]); | ||
assert.expect(processNotificationTypes.mock.calls[0][0]).to.be.deep.equal([]); | ||
}); | ||
|
||
test("Given invalid notification types | When Deploy is called | Then process is called", async () => { | ||
setGlobalLogLevel.mockImplementation(() => undefined); | ||
readFile.mockImplementation(() => []); | ||
validateNotificationTypes.mockImplementation(() => false); | ||
processNotificationTypes.mockImplementation(() => Promise.resolve()); | ||
|
||
await contentDeployment.deployNotificationTypes(); | ||
|
||
console.log(setGlobalLogLevel.mock.calls) | ||
assert.expect(setGlobalLogLevel.mock.calls[0][0]).to.be.equal("error"); | ||
assert.expect(readFile.mock.calls[0][0]).to.be.equal(cds.env?.requires?.notifications?.types); | ||
assert.expect(validateNotificationTypes.mock.calls[0][0]).to.be.deep.equal([]); | ||
assert.expect(processNotificationTypes.mock.calls[0]).to.be.deep.equal(undefined); | ||
}); | ||
}); |
Oops, something went wrong.