|
| 1 | +import * as assert from '@aws-cdk/assertions'; |
1 | 2 | import * as cdk from '@aws-cdk/core';
|
2 | 3 | import { FakeTask } from './fake-task';
|
3 |
| -import { renderGraph } from './private/render-util'; |
4 |
| -import { JsonPath } from '../lib'; |
| 4 | +import { JsonPath, StateMachine } from '../lib'; |
5 | 5 |
|
6 | 6 | test('JsonPath.DISCARD can be used to discard a state\'s output', () => {
|
7 |
| - const stack = new cdk.Stack(); |
8 |
| - |
| 7 | + // GIVEN |
| 8 | + const app = new cdk.App(); |
| 9 | + const stack = new cdk.Stack(app, 'TestStack'); |
9 | 10 | const task = new FakeTask(stack, 'my-state', {
|
10 | 11 | inputPath: JsonPath.DISCARD,
|
11 | 12 | outputPath: JsonPath.DISCARD,
|
12 | 13 | resultPath: JsonPath.DISCARD,
|
13 | 14 | });
|
| 15 | + new StateMachine(stack, 'state-machine', { |
| 16 | + definition: task, |
| 17 | + }); |
| 18 | + |
| 19 | + // WHEN |
| 20 | + const definitionString = new assert.Capture(); |
| 21 | + assert.Template.fromStack(stack).hasResourceProperties('AWS::StepFunctions::StateMachine', { |
| 22 | + DefinitionString: definitionString, |
| 23 | + }); |
| 24 | + |
| 25 | + // THEN |
| 26 | + const definition = JSON.parse(definitionString.asString()); |
14 | 27 |
|
15 |
| - expect(renderGraph(task)).toEqual({ |
16 |
| - StartAt: 'my-state', |
| 28 | + expect(definition).toMatchObject({ |
17 | 29 | States: {
|
18 | 30 | 'my-state': {
|
19 |
| - End: true, |
20 |
| - Type: 'Task', |
21 |
| - Resource: expect.any(String), |
22 |
| - Parameters: expect.any(Object), |
23 |
| - // The important bits: |
24 | 31 | InputPath: null,
|
25 | 32 | OutputPath: null,
|
26 | 33 | ResultPath: null,
|
|
0 commit comments