From ba7a6922e97ebc6d26e61304606651308194f486 Mon Sep 17 00:00:00 2001 From: Paulius Michelevicius Date: Thu, 7 Sep 2023 16:01:34 +0100 Subject: [PATCH] L3-134: some unit tests examples. --- tests/integration/command-functions.test.ts | 38 ++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tests/integration/command-functions.test.ts b/tests/integration/command-functions.test.ts index 2b27703..895f01c 100644 --- a/tests/integration/command-functions.test.ts +++ b/tests/integration/command-functions.test.ts @@ -2,6 +2,11 @@ import { default as chai, expect, assert } from 'chai' import chaiAsPromised from 'chai-as-promised' chai.use(chaiAsPromised) +// TODO subtask of L3-138 +// - [ ] - test for list process including verbose flag +// - [ ] - test for disable process including verbose flag +// - [ ] - test for create process including verbose flag e.g. --verbose + import { createProcess, disableProcess, loadProcesses } from '../../src/lib/process/index.js' import { validAllRestrictions, @@ -98,12 +103,11 @@ describe('Process creation and deletion, listing', () => { const processName = '0' const currentVersion = await getVersionHelper(processName) const bumpedVersion = currentVersion + 1 - const newProcess = await createProcess(processName, bumpedVersion, simple, false, polkadotOptions, true) + const newProcess = await createProcess(processName, bumpedVersion, simple, false, polkadotOptions) expect(newProcess.process).to.deep.equal({ id: processName, version: bumpedVersion, - status: 'Enabled', - program: simple, + status: 'Enabled', }) const disabledProcess = await disableProcess(processName, bumpedVersion, false, polkadotOptions) @@ -113,6 +117,30 @@ describe('Process creation and deletion, listing', () => { version: bumpedVersion, status: 'Disabled', }) + + /* + it('creates then disables a process and returns a program when with --verbose flag', () => { + const processName = '0' + const currentVersion = await getVersionHelper(processName) + const bumpedVersion = currentVersion + 1 + const newProcess = await createProcess(processName, bumpedVersion, simple, false, polkadotOptions, true) + expect(newProcess.process).to.deep.equal({ + id: processName, + version: bumpedVersion, + status: 'Enabled', + program: simple, + }) + + const disabledProcess = await disableProcess(processName, bumpedVersion, false, polkadotOptions, true) // last arg is a verbose boolean + expect(disabledProcess.message).to.equal('Process has been disabled') + expect(disabledProcess.process).to.deep.equal({ + id: processName, + version: bumpedVersion, + status: 'Disabled', + program: simple, + }) + }) + */ }) it('does not create process if dry run', async () => { @@ -138,7 +166,8 @@ describe('Process creation and deletion, listing', () => { }) }) - it('returns a list of raw processes', async () => { + // it('returns a list of raw processes when with --verbose flag', () => { + it('returns a list of processes', async () => { const res = await getAll(polkadotOptions) expect(res).to.be.an('array') @@ -146,6 +175,7 @@ describe('Process creation and deletion, listing', () => { .to.be.an('object') .that.has.keys(['id', 'createdAtHash', 'initialU8aLength', 'program', 'status', 'version']) }) + }) describe('Sad path', () => {