From afa87a27a53a37fbf37b8c65dbbfb03209cb51ce Mon Sep 17 00:00:00 2001 From: Mark Addis <35331926+nitro-marky@users.noreply.github.com> Date: Mon, 11 Sep 2023 12:52:41 +0100 Subject: [PATCH] LintTransformation tests added --- package-lock.json | 4 +- package.json | 2 +- src/lib/process/_tests_/unit.test.ts | 97 ++++++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index c497f6b..a75de1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@digicatapult/dscp-process-management", - "version": "1.7.47", + "version": "1.7.48", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@digicatapult/dscp-process-management", - "version": "1.7.47", + "version": "1.7.48", "license": "Apache-2.0", "dependencies": { "@polkadot/api": "^10.9.1", diff --git a/package.json b/package.json index 6d55467..3b042dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digicatapult/dscp-process-management", - "version": "1.7.47", + "version": "1.7.48", "description": "DSCP Process Management Flow", "main": "./lib/index.js", "bin": { diff --git a/src/lib/process/_tests_/unit.test.ts b/src/lib/process/_tests_/unit.test.ts index d591990..120e36f 100644 --- a/src/lib/process/_tests_/unit.test.ts +++ b/src/lib/process/_tests_/unit.test.ts @@ -24,17 +24,106 @@ describe('listTranforming', () => { const enriched: Process.RawPayload = { ...sample[0], id: '123', - status: 'Disabled', + status: 'Enabled', createdAtHash: 'abc', initialU8aLength: '32', } const res = await listTransforming([enriched], processes, { ...defaultPolkadot, verbose: false }) - expect(res[0]) - .to.be.an('object') - .that.not.contain.keys(['program']) + console.log(res) + + expect(res[0]).to.deep.contain({ + id: '123', + status: 'Enabled', + version: 1, + }) + }) + + it('returns all transformed processes with a program (--verbose=true)', async () => { + let processes: Process.RawPayload[] + const enriched: Process.RawPayload = { + ...sample[0], + id: '123', + status: 'Disabled', + createdAtHash: 'abc', + initialU8aLength: '32', + } + + const res = await listTransforming([enriched], processes, { ...defaultPolkadot, verbose: true}) + console.log(res) + expect(res[0]).to.deep.contain({ + id: '123', + status: 'Disabled', + version: 1, + }) + }) + + it('returns all options active', async () => { + let processes: Process.RawPayload[] + const enriched: Process.RawPayload = { + ...sample[0], + id: '123', + status: 'Enabled', + createdAtHash: 'abc', + initialU8aLength: '32', + } + + const res = await listTransforming([enriched], processes, { ...defaultPolkadot, active: true}) + console.log(res) + expect(res[0]).to.deep.contain({ + id: '123', + status: 'Enabled', + version: 1, + }) + }) + it('returns all options disabled but with active true', async () => { + let processes: Process.RawPayload[] + const enriched: Process.RawPayload = { + ...sample[0], + id: '123', + status: 'Disabled', + createdAtHash: 'abc', + initialU8aLength: '32', + } + + const res = await listTransforming([enriched], processes, { ...defaultPolkadot, active: true}) + console.log(res) + expect(res[0]).to.equal(undefined) + }) + + it('returns all options disabled', async () => { + let processes: Process.RawPayload[] + const enriched: Process.RawPayload = { + ...sample[0], + id: '123', + status: 'Disabled', + createdAtHash: 'abc', + initialU8aLength: '32', + } + + const res = await listTransforming([enriched], processes, { ...defaultPolkadot}) + console.log(res) + expect(res[0]).to.deep.contain({ + id: '123', + status: 'Disabled', + version: 1, + }) + }) + + it('returns all options active with status enabled', async () => { + let processes: Process.RawPayload[] + const enriched: Process.RawPayload = { + ...sample[0], + id: '123', + status: 'Disabled', + createdAtHash: 'abc', + initialU8aLength: '32', + } + + const res = await listTransforming([enriched], processes, { ...defaultPolkadot, active: false}) + console.log(res) expect(res[0]).to.deep.contain({ id: '123', status: 'Disabled',