@wmfs/statebox
Version:
Orchestrate Node functions using Amazon States Language
66 lines (55 loc) • 1.56 kB
JavaScript
/* eslint-env mocha */
const chai = require('chai')
const expect = chai.expect
const succeedStateMachines = require('./fixtures/state-machines/succeed-state')
const Statebox = require('./../lib')
let statebox
describe('Success State', function () {
before('setup statebox', async () => {
statebox = new Statebox()
await statebox.ready
await statebox.createStateMachines(succeedStateMachines, {})
})
const address = {
line1: 'Hescwm Uchaf',
line2: 'Dinas Cross',
postCode: 'SA42 0XL'
}
const blobOfStuff = {
person: {
name: 'Bill',
address
}
}
const passStates = {
succeed: blobOfStuff,
// succeedWithInputPath: address,
// succeedWithNullInputPath: { },
succeedWithOutputPath: address,
succeedWithNullOutputPath: { }
}
for (const [name, result] of Object.entries(passStates)) {
test(
name,
name,
blobOfStuff,
result
)
} // for ...
})
function test (label, statemachine, input, result) {
it(label, async () => {
const executionDescription = await statebox.startExecution(
Object.assign({}, input),
statemachine,
{
sendResponse: 'COMPLETED'
} // options
)
expect(executionDescription.status).to.eql('SUCCEEDED')
expect(executionDescription.stateMachineName).to.eql(statemachine)
expect(executionDescription.currentStateName).to.eql('SucceedState')
expect(executionDescription.currentResource).to.eql(undefined)
expect(executionDescription.ctx).to.eql(result)
}) // it ...
}