From dc811bf784c4d8123a000930dfafc4f8a808e7d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 21:40:41 +0800 Subject: [PATCH] Bump @adobe/aio-lib-core-config from 3.1.0 to 4.0.0 (#75) * Bump @adobe/aio-lib-core-config from 3.1.0 to 4.0.0 Bumps [@adobe/aio-lib-core-config](https://github.com/adobe/aio-lib-core-config) from 3.1.0 to 4.0.0. - [Release notes](https://github.com/adobe/aio-lib-core-config/releases) - [Commits](https://github.com/adobe/aio-lib-core-config/compare/3.1.0...4.0.0) --- updated-dependencies: - dependency-name: "@adobe/aio-lib-core-config" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * fix: update eslint-config, fix eslint test issues --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Shazron Abdullah <36107+shazron@users.noreply.github.com> --- .eslintrc.json | 10 ++++ package.json | 18 +++--- .../event/eventmetadata/create.test.js | 8 +-- .../event/eventmetadata/delete.test.js | 12 ++-- test/commands/event/eventmetadata/get.test.js | 8 +-- .../commands/event/eventmetadata/list.test.js | 8 +-- .../event/eventmetadata/update.test.js | 8 +-- test/commands/event/provider/create.test.js | 10 ++-- test/commands/event/provider/delete.test.js | 6 +- test/commands/event/provider/get.test.js | 8 +-- test/commands/event/provider/list.test.js | 14 ++--- test/commands/event/provider/update.test.js | 10 ++-- .../event/registration/delete.test.js | 2 +- test/commands/event/registration/get.test.js | 6 +- test/commands/event/registration/list.test.js | 4 +- test/hooks/post-deploy-event-reg.test.js | 56 +++++++++---------- test/hooks/pre-deploy-event-reg.test.js | 6 +- test/hooks/pre-undeploy-event-reg.test.js | 26 ++++----- 18 files changed, 115 insertions(+), 105 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6eef70a..1613426 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,5 +4,15 @@ "jsdoc": { "ignorePrivate": true } + }, + "rules": { + "jsdoc/tag-lines": [ + // The Error level should be `error`, `warn`, or `off` (or 2, 1, or 0) + "error", + "never", + { + "startLines": null + } + ] } } diff --git a/package.json b/package.json index 2648af5..f42bbff 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "license": "Apache-2.0", "dependencies": { "@adobe/aio-lib-console": "^4.0.0", - "@adobe/aio-lib-core-config": "^3.0.0", + "@adobe/aio-lib-core-config": "^4.0.0", "@adobe/aio-lib-core-logging": "^2.0.0", "@adobe/aio-lib-events": "^3.1.0", "@adobe/aio-lib-ims": "^6.0.1", @@ -19,19 +19,19 @@ }, "repository": "adobe/aio-cli-plugin-events", "devDependencies": { - "@adobe/eslint-config-aio-lib-config": "^2.0.0", + "@adobe/eslint-config-aio-lib-config": "^2.0.1", "@types/jest": "^29.5.3", "acorn": "^8.10.0", "babel-runtime": "^6.26.0", "chalk": "^4.0.0", "eol": "^0.9.1", - "eslint": "^8.38.0", + "eslint": "^8.47.0", "eslint-config-oclif": "^3.1.0", - "eslint-config-standard": "^17.0.0", - "eslint-plugin-import": "^2.27.5", - "eslint-plugin-jest": "^23.20.0", - "eslint-plugin-jsdoc": "^37.9.7", - "eslint-plugin-n": "^15.7.0", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.28.0", + "eslint-plugin-jest": "^27.2.3", + "eslint-plugin-jsdoc": "^42.0.0", + "eslint-plugin-n": "^16.0.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-standard": "^5.0.0", @@ -42,7 +42,7 @@ "jest-resolve": "^29.5.0", "oclif": "^3.2.0", "stdout-stderr": "^0.1.13", - "typescript": "^5.0.4" + "typescript": "^5.1.6" }, "engines": { "node": "^14.18 || ^16.13 || >=18" diff --git a/test/commands/event/eventmetadata/create.test.js b/test/commands/event/eventmetadata/create.test.js index 92b5b54..27be3aa 100644 --- a/test/commands/event/eventmetadata/create.test.js +++ b/test/commands/event/eventmetadata/create.test.js @@ -80,21 +80,21 @@ describe('console:eventmetadata:create', () => { test('should create an event metadata and return response', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', event_code: 'come.adobe.CODE01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/create.txt') }) test('should create an event metadata and return response as json', async () => { command.argv = ['providerId', '--json'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', event_code: 'come.adobe.CODE01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('eventmetadata/create.json') }) test('should create an event metadata and return response as yaml', async () => { command.argv = ['providerId', '--yml'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', event_code: 'come.adobe.CODE01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/create.yml') }) }) @@ -113,7 +113,7 @@ describe('console:eventmetadata:create', () => { test('should return error on create event metadata', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', event_code: 'come.adobe.CODE01' }) - await expect(command.run()).rejects.toThrowError(new Error('Error creating event metadata')) + await expect(command.run()).rejects.toThrow(new Error('Error creating event metadata')) }) }) }) diff --git a/test/commands/event/eventmetadata/delete.test.js b/test/commands/event/eventmetadata/delete.test.js index 7e91a37..9a93c82 100644 --- a/test/commands/event/eventmetadata/delete.test.js +++ b/test/commands/event/eventmetadata/delete.test.js @@ -76,27 +76,27 @@ describe('console:eventmetadata:delete', () => { command.argv = ['providerId'] command.eventClient = { deleteAllEventMetadata: jest.fn().mockReturnValue('OK') } inquirer.prompt.mockResolvedValueOnce({ delete: true }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('All event metadata of provider providerId has been deleted successfully\n') }) test('should delete one event metadata', async () => { command.argv = ['providerId', 'com.adobe.CODE01'] command.eventClient = { deleteEventMetadata: jest.fn().mockReturnValue('OK') } inquirer.prompt.mockResolvedValueOnce({ delete: true }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('com.adobe.CODE01 event metadata of provider providerId has been deleted successfully\n') }) test('cancel delete all event metadata', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ delete: false }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('Deletion operation has been cancelled. For more information on delete use --help\n') }) test('cancel delete one event metadata', async () => { command.argv = ['providerId', 'com.adobe.CODE01'] inquirer.prompt.mockResolvedValueOnce({ delete: false }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('Deletion operation has been cancelled. For more information on delete use --help\n') }) }) @@ -115,14 +115,14 @@ describe('console:eventmetadata:delete', () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ delete: true }) command.eventClient = { deleteAllEventMetadata: jest.fn().mockRejectedValue('Error deleting all event metadata') } - await expect(command.run()).rejects.toThrowError(new Error('Error deleting all event metadata')) + await expect(command.run()).rejects.toThrow(new Error('Error deleting all event metadata')) }) test('should return error on delete one event metadata', async () => { command.argv = ['providerId', 'com.adobe.CODE01'] command.eventClient = { deleteEventMetadata: jest.fn().mockRejectedValue('Error deleting event metadata') } inquirer.prompt.mockResolvedValueOnce({ delete: true }) - await expect(command.run()).rejects.toThrowError(new Error('Error deleting event metadata')) + await expect(command.run()).rejects.toThrow(new Error('Error deleting event metadata')) }) }) }) diff --git a/test/commands/event/eventmetadata/get.test.js b/test/commands/event/eventmetadata/get.test.js index 78defd4..6bbc840 100644 --- a/test/commands/event/eventmetadata/get.test.js +++ b/test/commands/event/eventmetadata/get.test.js @@ -68,19 +68,19 @@ describe('console:eventmetadata:get', () => { }) test('should return am event metadata', async () => { - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/get.txt') }) test('should return event metadata as json', async () => { command.argv = ['providerId', 'com.adobe.CODE01', '--json'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('eventmetadata/get.json') }) test('should return event metadata as yaml', async () => { command.argv = ['providerId', 'com.adobe.CODE01', '--yml'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/get.yml') }) }) @@ -98,7 +98,7 @@ describe('console:eventmetadata:get', () => { test('should return error on get event metadata', async () => { command.argv = ['providerId', 'com.adobe.CODE01'] - await expect(command.run()).rejects.toThrowError(new Error('Error retrieving event metadata')) + await expect(command.run()).rejects.toThrow(new Error('Error retrieving event metadata')) }) }) }) diff --git a/test/commands/event/eventmetadata/list.test.js b/test/commands/event/eventmetadata/list.test.js index 46476fc..dfab7f4 100644 --- a/test/commands/event/eventmetadata/list.test.js +++ b/test/commands/event/eventmetadata/list.test.js @@ -65,19 +65,19 @@ describe('console:eventmetadata:list', () => { test('should return list of event metadata', async () => { command.argv = ['providerId'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/list.txt') }) test('should return list of event metadata as json', async () => { command.argv = ['providerId', '--json'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('eventmetadata/list.json') }) test('should return list of event metadata as yaml', async () => { command.argv = ['providerId', '--yml'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/list.yml') }) }) @@ -95,7 +95,7 @@ describe('console:eventmetadata:list', () => { test('should return error on get list of event metadata', async () => { command.argv = ['providerId'] - await expect(command.run()).rejects.toThrowError(new Error('Error retrieving event metadata')) + await expect(command.run()).rejects.toThrow(new Error('Error retrieving event metadata')) }) }) }) diff --git a/test/commands/event/eventmetadata/update.test.js b/test/commands/event/eventmetadata/update.test.js index 6ba9b84..2393d6d 100644 --- a/test/commands/event/eventmetadata/update.test.js +++ b/test/commands/event/eventmetadata/update.test.js @@ -82,21 +82,21 @@ describe('console:eventmetadata:update', () => { test('should update an event metadata and return response', async () => { command.argv = ['providerId', 'com.adobe.CODE01'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/update.txt') }) test('should update an event metadata and return response as json', async () => { command.argv = ['providerId', 'com.adobe.CODE01', '--json'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('eventmetadata/update.json') }) test('should update a provider and return response as yaml', async () => { command.argv = ['providerId', 'com.adobe.CODE01', '--yml'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('eventmetadata/update.yml') }) }) @@ -115,7 +115,7 @@ describe('console:eventmetadata:update', () => { test('should return error on update provider', async () => { command.argv = ['providerId', 'com.adobe.CODE01'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).rejects.toThrowError(new Error('Error updating event metadata')) + await expect(command.run()).rejects.toThrow(new Error('Error updating event metadata')) }) }) }) diff --git a/test/commands/event/provider/create.test.js b/test/commands/event/provider/create.test.js index d74d5f0..d295753 100644 --- a/test/commands/event/provider/create.test.js +++ b/test/commands/event/provider/create.test.js @@ -78,28 +78,28 @@ describe('console:provider:create', () => { test('should create a provider and return response', async () => { inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/create.txt') }) test('should create a provider and return response for empty desc and docs', async () => { command.eventClient = { createProvider: jest.fn().mockReturnValue(mock.data.createProviderWithoutDescAndDocsUrlResponse) } inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: '', docs_url: '' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/emptyDescCreate.txt') }) test('should create a provider and return response as json', async () => { command.argv = ['--json'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('provider/create.json') }) test('should create a provider and return response as yaml', async () => { command.argv = ['--yml'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/create.yml') }) }) @@ -117,7 +117,7 @@ describe('console:provider:create', () => { test('should return error on create provider', async () => { inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL01', description: 'DESC01', docs_url: 'DOCS01' }) - await expect(command.run()).rejects.toThrowError(new Error('Error creating provider')) + await expect(command.run()).rejects.toThrow(new Error('Error creating provider')) }) }) }) diff --git a/test/commands/event/provider/delete.test.js b/test/commands/event/provider/delete.test.js index 192c2d4..dc7896f 100644 --- a/test/commands/event/provider/delete.test.js +++ b/test/commands/event/provider/delete.test.js @@ -75,14 +75,14 @@ describe('console:provider:delete', () => { test('should delete provider', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ delete: true }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('Provider providerId has been deleted successfully\n') }) test('cancel delete provider', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ delete: false }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('Delete operation has been cancelled\n') }) }) @@ -101,7 +101,7 @@ describe('console:provider:delete', () => { test('should return error on delete provider', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ delete: true }) - await expect(command.run()).rejects.toThrowError(new Error('Error deleting provider')) + await expect(command.run()).rejects.toThrow(new Error('Error deleting provider')) }) }) }) diff --git a/test/commands/event/provider/get.test.js b/test/commands/event/provider/get.test.js index 7aa3747..4734bdb 100644 --- a/test/commands/event/provider/get.test.js +++ b/test/commands/event/provider/get.test.js @@ -67,19 +67,19 @@ describe('console:provider:get', () => { }) test('should return a provider', async () => { - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/get.txt') }) test('should return provider as json', async () => { command.argv = ['providerId', '--json'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('provider/get.json') }) test('should return provider as yaml', async () => { command.argv = ['providerId', '--yml'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/get.yml') }) }) @@ -97,7 +97,7 @@ describe('console:provider:get', () => { test('should return error on get provider', async () => { command.argv = ['providerId'] - await expect(command.run()).rejects.toThrowError(new Error('Error retrieving provider')) + await expect(command.run()).rejects.toThrow(new Error('Error retrieving provider')) }) }) }) diff --git a/test/commands/event/provider/list.test.js b/test/commands/event/provider/list.test.js index 693a491..960af45 100644 --- a/test/commands/event/provider/list.test.js +++ b/test/commands/event/provider/list.test.js @@ -71,25 +71,25 @@ describe('console:provider:list', () => { }) test('should return list of providers', async () => { - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/list.txt') }) test('should return list of providers as json', async () => { command.argv = ['--json'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('provider/list.json') }) test('should return list of providers as yaml', async () => { command.argv = ['--yml'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/list.yml') }) test('should return list of providers with event metadata', async () => { command.argv = ['--fetchEventMetadata'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(command.eventClient.getAllProviders).toHaveBeenCalledWith(ORG_ID, { fetchEventMetadata: true, filterBy: { @@ -102,7 +102,7 @@ describe('console:provider:list', () => { test('should return providers for provider metadata id and instance id', async () => { command.argv = ['--providerMetadataId', 'pm-1', '--instanceId', 'instance1'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(command.eventClient.getAllProviders).toHaveBeenCalledWith(ORG_ID, { fetchEventMetadata: undefined, filterBy: { @@ -115,7 +115,7 @@ describe('console:provider:list', () => { test('should return list of providers for provider metadata id list', async () => { command.argv = ['--providerMetadataIds', 'pm-1', 'pm-2'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(command.eventClient.getAllProviders).toHaveBeenCalledWith(ORG_ID, { fetchEventMetadata: undefined, filterBy: { @@ -139,7 +139,7 @@ describe('console:provider:list', () => { }) test('should return error on get list of providers', async () => { - await expect(command.run()).rejects.toThrowError(new Error('Error retrieving providers')) + await expect(command.run()).rejects.toThrow(new Error('Error retrieving providers')) }) test('should return error on passing both providerMetadataId and providerMetadataIds flags', async () => { diff --git a/test/commands/event/provider/update.test.js b/test/commands/event/provider/update.test.js index 0ee15d2..564c2d8 100644 --- a/test/commands/event/provider/update.test.js +++ b/test/commands/event/provider/update.test.js @@ -80,7 +80,7 @@ describe('console:provider:update', () => { test('should update a provider and return response', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/update.txt') }) @@ -88,21 +88,21 @@ describe('console:provider:update', () => { command.argv = ['providerId'] command.eventClient = { updateProvider: jest.fn().mockReturnValue(mock.data.updateProviderWithoutDescAndDocsUrlResponse) } inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: '', docs_url: '' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/emptyDescUpdate.txt') }) test('should update a provider and return response as json', async () => { command.argv = ['providerId', '--json'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('provider/update.json') }) test('should update a provider and return response as yaml', async () => { command.argv = ['providerId', '--yml'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('provider/update.yml') }) }) @@ -121,7 +121,7 @@ describe('console:provider:update', () => { test('should return error on update provider', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ label: 'LABEL04', description: 'DESC04', docs_url: 'DOCS01' }) - await expect(command.run()).rejects.toThrowError(new Error('Error updating provider')) + await expect(command.run()).rejects.toThrow(new Error('Error updating provider')) }) }) }) diff --git a/test/commands/event/registration/delete.test.js b/test/commands/event/registration/delete.test.js index a583253..10f01e0 100644 --- a/test/commands/event/registration/delete.test.js +++ b/test/commands/event/registration/delete.test.js @@ -69,7 +69,7 @@ describe('console:registration:delete', () => { test('cancel delete provider', async () => { command.argv = ['providerId'] inquirer.prompt.mockResolvedValueOnce({ delete: false }) - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toBe('Delete operation has been cancelled\n') expect(command.eventClient.deleteRegistration).not.toHaveBeenCalled() }) diff --git a/test/commands/event/registration/get.test.js b/test/commands/event/registration/get.test.js index 41080cc..2dfc291 100644 --- a/test/commands/event/registration/get.test.js +++ b/test/commands/event/registration/get.test.js @@ -64,21 +64,21 @@ describe('console:registration:get', () => { test('registrationId', async () => { command.argv = ['registrationId'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('registration/get.txt') expect(command.eventClient.getRegistration).toHaveBeenCalledWith('ORGID', 'PROJECTID', 'WORKSPACEID', 'registrationId') }) test('registrationId --json', async () => { command.argv = ['registrationId', '--json'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('registration/get.json') expect(command.eventClient.getRegistration).toHaveBeenCalledWith('ORGID', 'PROJECTID', 'WORKSPACEID', 'registrationId') }) test('registrationId --yml', async () => { command.argv = ['registrationId', '--yml'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('registration/get.yml') expect(command.eventClient.getRegistration).toHaveBeenCalledWith('ORGID', 'PROJECTID', 'WORKSPACEID', 'registrationId') }) diff --git a/test/commands/event/registration/list.test.js b/test/commands/event/registration/list.test.js index 12a6f65..5b9f4ae 100644 --- a/test/commands/event/registration/list.test.js +++ b/test/commands/event/registration/list.test.js @@ -70,14 +70,14 @@ describe('console:registration:list', () => { test('--json', async () => { command.argv = ['--json'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(JSON.parse(stdout.output)).toMatchFixtureJson('registration/list.json') expect(command.eventClient.getAllRegistrationsForWorkspace).toHaveBeenCalledWith('ORGID', 'PROJECTID', 'WORKSPACEID') }) test('registrationId --yml', async () => { command.argv = ['--yml'] - await expect(command.run()).resolves.not.toThrowError() + await expect(command.run()).resolves.not.toThrow() expect(stdout.output).toMatchFixture('registration/list.yml') expect(command.eventClient.getAllRegistrationsForWorkspace).toHaveBeenCalledWith('ORGID', 'PROJECTID', 'WORKSPACEID') }) diff --git a/test/hooks/post-deploy-event-reg.test.js b/test/hooks/post-deploy-event-reg.test.js index e20d820..8a60b79 100644 --- a/test/hooks/post-deploy-event-reg.test.js +++ b/test/hooks/post-deploy-event-reg.test.js @@ -44,26 +44,26 @@ describe('post deploy event registration hook interfaces', () => { test('command-error', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: {} })).rejects.toThrowError(new Error('No project found, skipping event registration in post-deploy-event-reg hook')) + await expect(hook({ appConfig: {} })).rejects.toThrow(new Error('No project found, skipping event registration in post-deploy-event-reg hook')) }) test('no project error', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: {} })).rejects.toThrowError(new Error('No project found, skipping event registration in post-deploy-event-reg hook')) + await expect(hook({ appConfig: {} })).rejects.toThrow(new Error('No project found, skipping event registration in post-deploy-event-reg hook')) }) test('no events should return without error', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: { project: mock.data.sampleProject } })).resolves.not.toThrowError() + await expect(hook({ appConfig: { project: mock.data.sampleProject } })).resolves.not.toThrow() }) test('no service api key error', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') process.env = mock.data.dotEnvMissingApiKey - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError(new Error('Required SERVICE_API_KEY is missing from .env file')) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow(new Error('Required SERVICE_API_KEY is missing from .env file')) }) test('events sdk not initialised correctly error', async () => { @@ -72,7 +72,7 @@ describe('post deploy event registration hook interfaces', () => { process.env = mock.data.dotEnvMissingProviderMetadataToProviderIdMapping getToken.mockReturnValue('accessToken') eventsSdk.init.mockResolvedValue(undefined) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError(new Error('Events SDK could not be initialised correctly. Skipping event registration in post-deploy-event-reg hook')) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow(new Error('Events SDK could not be initialised correctly. Skipping event registration in post-deploy-event-reg hook')) }) test('no providerMetadata to providerId mapping env variable error', async () => { @@ -80,7 +80,7 @@ describe('post deploy event registration hook interfaces', () => { expect(typeof hook).toBe('function') process.env = mock.data.dotEnvMissingProviderMetadataToProviderIdMapping getToken.mockReturnValue('accessToken') - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError(new Error('No environment variables for provider metadata to provider id mappings found.')) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow(new Error('No environment variables for provider metadata to provider id mappings found.')) }) test('empty providerMetadata to providerId mapping env variable error', async () => { @@ -89,7 +89,7 @@ describe('post deploy event registration hook interfaces', () => { process.env = mock.data.dotEnvMissingProviderMetadataToProviderIdMapping process.env.AIO_events_providermetadata_to_provider_mapping = '' getToken.mockReturnValue('accessToken') - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError(new Error('No environment variables for provider metadata to provider id mappings found.')) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow(new Error('No environment variables for provider metadata to provider id mappings found.')) }) test('error in create registration', async () => { @@ -103,8 +103,8 @@ describe('post deploy event registration hook interfaces', () => { message: 'Internal Server Error' } })) - await expect(hook({ appConfig: { project: mock.data.sampleProjectWithoutEvents, events: mock.data.sampleEvents } })).rejects.toThrowError() - expect(mockEventsSdkInstance.createRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProjectWithoutEvents, events: mock.data.sampleEvents } })).rejects.toThrow() + expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, mock.data.hookDecodedEventRegistration1 ) @@ -116,8 +116,8 @@ describe('post deploy event registration hook interfaces', () => { process.env = mock.data.dotEnv getToken.mockReturnValue('accessToken') mockEventsSdkInstance.createRegistration.mockReturnValue(mock.data.createWebhookRegistrationResponse) - await expect(hook({ appConfig: { project: mock.data.sampleProjectWithoutEvents, events: mock.data.sampleEvents } })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.createRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProjectWithoutEvents, events: mock.data.sampleEvents } })).resolves.not.toThrow() + expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, mock.data.hookDecodedEventRegistration1 ) @@ -134,8 +134,8 @@ describe('post deploy event registration hook interfaces', () => { mockEventsSdkInstance.createRegistration.mockReturnValue(mock.data.createWebhookRegistrationResponse) const projectWithEmptyEvents = mock.data.sampleProjectWithoutEvents projectWithEmptyEvents.workspace.details.events = {} - await expect(hook({ appConfig: { project: projectWithEmptyEvents, events } })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.createRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: projectWithEmptyEvents, events } })).resolves.not.toThrow() + expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, mock.data.hookDecodedEventRegistration1 ) @@ -153,8 +153,8 @@ describe('post deploy event registration hook interfaces', () => { message: 'Internal Server Error' } })) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError() - expect(mockEventsSdkInstance.updateRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow() + expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, 'REGID1', mock.data.hookDecodedEventRegistration1 ) @@ -167,8 +167,8 @@ describe('post deploy event registration hook interfaces', () => { getToken.mockReturnValue('accessToken') mockEventsSdkInstance.getAllRegistrationsForWorkspace.mockResolvedValue(mock.data.getAllWebhookRegistrationsResponse) mockEventsSdkInstance.updateRegistration.mockReturnValue(mock.data.createWebhookRegistrationResponse) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.updateRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrow() + expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, 'REGID1', mock.data.hookDecodedEventRegistration1 ) @@ -187,26 +187,26 @@ describe('post deploy event registration hook interfaces', () => { mockEventsSdkInstance.getAllRegistrationsForWorkspace.mockResolvedValue(mock.data.getAllWebhookRegistrationsResponse) mockEventsSdkInstance.updateRegistration.mockReturnValue(mock.data.createWebhookRegistrationResponse) const projectWithEmptyEvents = mock.data.sampleProjectWithoutEvents - await expect(hook({ appConfig: { project: projectWithEmptyEvents, events }, force: true })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.updateRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: projectWithEmptyEvents, events }, force: true })).resolves.not.toThrow() + expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, 'REGID2') }) - test('test delete registrations not part of the config, with no registrations to delete', async () => { + test('delete registrations not part of the config, with no registrations to delete', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') process.env = mock.data.dotEnv getToken.mockReturnValue('accessToken') mockEventsSdkInstance.getAllRegistrationsForWorkspace.mockResolvedValue(mock.data.getAllWebhookRegistrationsResponse) mockEventsSdkInstance.updateRegistration.mockReturnValue(mock.data.createWebhookRegistrationResponse) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents }, force: true })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.updateRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents }, force: true })).resolves.not.toThrow() + expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, 'REGID1', mock.data.hookDecodedEventRegistration1) expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledTimes(0) }) - test('test delete registrations not part of the config, with no registrations in workspace', async () => { + test('delete registrations not part of the config, with no registrations in workspace', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') process.env = mock.data.dotEnv @@ -214,14 +214,14 @@ describe('post deploy event registration hook interfaces', () => { mockEventsSdkInstance.getAllRegistrationsForWorkspace.mockResolvedValue(mock.data.getAllWebhookRegistrationsWithEmptyResponse) mockEventsSdkInstance.createRegistration.mockReturnValue(mock.data.createWebhookRegistrationResponse) - await expect(hook({ appConfig: { project: mock.data.sampleProjectWithoutEvents, events: mock.data.sampleEvents }, force: true })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.createRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProjectWithoutEvents, events: mock.data.sampleEvents }, force: true })).resolves.not.toThrow() + expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.createRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, mock.data.hookDecodedEventRegistration1) expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledTimes(0) }) - test('test error on delete registrations not part of the config', async () => { + test('error on delete registrations not part of the config', async () => { const hook = require('../../src/hooks/post-deploy-event-reg') expect(typeof hook).toBe('function') process.env = mock.data.dotEnv @@ -240,8 +240,8 @@ describe('post deploy event registration hook interfaces', () => { } }) const projectWithEmptyEvents = mock.data.sampleProjectWithoutEvents - await expect(hook({ appConfig: { project: projectWithEmptyEvents, events }, force: true })).rejects.toThrowError() - expect(mockEventsSdkInstance.updateRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: projectWithEmptyEvents, events }, force: true })).rejects.toThrow() + expect(mockEventsSdkInstance.updateRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, 'REGID2') }) }) diff --git a/test/hooks/pre-deploy-event-reg.test.js b/test/hooks/pre-deploy-event-reg.test.js index b1a0efb..4862468 100644 --- a/test/hooks/pre-deploy-event-reg.test.js +++ b/test/hooks/pre-deploy-event-reg.test.js @@ -34,18 +34,18 @@ describe('pre deploy event registration hook interfaces', () => { test('no events should return without error', async () => { const hook = require('../../src/hooks/pre-deploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: { project: mock.data.sampleProject } })).resolves.not.toThrowError() + await expect(hook({ appConfig: { project: mock.data.sampleProject } })).resolves.not.toThrow() }) test('no events registrations should return without error', async () => { const hook = require('../../src/hooks/pre-deploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: { registrations: [] } } })).resolves.not.toThrowError() + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: { registrations: [] } } })).resolves.not.toThrow() }) test('Registrations of journal type should return without error', async () => { const hook = require('../../src/hooks/pre-deploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrowError() + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrow() }) }) diff --git a/test/hooks/pre-undeploy-event-reg.test.js b/test/hooks/pre-undeploy-event-reg.test.js index 6c2cbd5..7d3c040 100644 --- a/test/hooks/pre-undeploy-event-reg.test.js +++ b/test/hooks/pre-undeploy-event-reg.test.js @@ -42,20 +42,20 @@ describe('pre undeploy event registration hook interfaces', () => { test('no project error', async () => { const hook = require('../../src/hooks/pre-undeploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: {} })).rejects.toThrowError(new Error('No project found, skipping deletion of event registrations')) + await expect(hook({ appConfig: {} })).rejects.toThrow(new Error('No project found, skipping deletion of event registrations')) }) test('no events should return without error', async () => { const hook = require('../../src/hooks/pre-undeploy-event-reg') expect(typeof hook).toBe('function') - await expect(hook({ appConfig: { project: mock.data.sampleProject } })).resolves.not.toThrowError() + await expect(hook({ appConfig: { project: mock.data.sampleProject } })).resolves.not.toThrow() }) test('no service api key error', async () => { const hook = require('../../src/hooks/pre-undeploy-event-reg') expect(typeof hook).toBe('function') process.env = mock.data.dotEnvMissingApiKey - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError(new Error('Required SERVICE_API_KEY is missing from .env file')) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow(new Error('Required SERVICE_API_KEY is missing from .env file')) }) test('events sdk not initialised correctly error', async () => { @@ -64,7 +64,7 @@ describe('pre undeploy event registration hook interfaces', () => { process.env = mock.data.dotEnvMissingProviderMetadataToProviderIdMapping getToken.mockReturnValue('accessToken') eventsSdk.init.mockResolvedValue(undefined) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError(new Error('Events SDK could not be initialised correctly. Skipping deletion of event registrations')) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow(new Error('Events SDK could not be initialised correctly. Skipping deletion of event registrations')) }) test('no event registrations in workspace to return without error', async () => { @@ -73,8 +73,8 @@ describe('pre undeploy event registration hook interfaces', () => { process.env = mock.data.dotEnvMissingProviderMetadataToProviderIdMapping mockEventsSdkInstance.getAllRegistrationsForWorkspace.mockResolvedValue(mock.data.getAllWebhookRegistrationsWithEmptyResponse) getToken.mockReturnValue('accessToken') - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.deleteRegistration).toBeCalledTimes(0) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrow() + expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledTimes(0) }) test('error in delete registration', async () => { @@ -90,8 +90,8 @@ describe('pre undeploy event registration hook interfaces', () => { message: 'Internal Server Error' } })) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrowError() - expect(mockEventsSdkInstance.deleteRegistration).toBeCalledTimes(1) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).rejects.toThrow() + expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledTimes(1) expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledWith(CONSUMER_ID, PROJECT_ID, WORKSPACE_ID, 'REGID1') }) @@ -102,11 +102,11 @@ describe('pre undeploy event registration hook interfaces', () => { getToken.mockReturnValue('accessToken') mockEventsSdkInstance.getAllRegistrationsForWorkspace.mockResolvedValue(mock.data.getAllWebhookRegistrationsResponse) - await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.deleteRegistration).toBeCalledTimes(2) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events: mock.data.sampleEvents } })).resolves.not.toThrow() + expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledTimes(2) }) - test('test do not delete registrations that are not part of the latest workspace', async () => { + test('do not delete registrations that are not part of the latest workspace', async () => { const hook = require('../../src/hooks/pre-undeploy-event-reg') expect(typeof hook).toBe('function') process.env = mock.data.dotEnv @@ -117,7 +117,7 @@ describe('pre undeploy event registration hook interfaces', () => { 'Event Registration 3': mock.data.sampleEvents.registrations['Event Registration 1'] } } - await expect(hook({ appConfig: { project: mock.data.sampleProject, events } })).resolves.not.toThrowError() - expect(mockEventsSdkInstance.deleteRegistration).toBeCalledTimes(0) + await expect(hook({ appConfig: { project: mock.data.sampleProject, events } })).resolves.not.toThrow() + expect(mockEventsSdkInstance.deleteRegistration).toHaveBeenCalledTimes(0) }) })