Skip to content

Commit

Permalink
L3-134: some unit tests examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3op2 committed Sep 7, 2023
1 parent 6b8cdf7 commit ba7a692
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions tests/integration/command-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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 () => {
Expand All @@ -138,14 +166,16 @@ 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')
expect(res[0])
.to.be.an('object')
.that.has.keys(['id', 'createdAtHash', 'initialU8aLength', 'program', 'status', 'version'])
})

})

describe('Sad path', () => {
Expand Down

0 comments on commit ba7a692

Please sign in to comment.