From 7865a723754981ac042d6b3905462fa48cbfb363 Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Tue, 27 Aug 2019 12:52:02 +0100 Subject: [PATCH] fix(cloudwatch): don't ignore 'stacked' property in GraphWidget class (#2103) --- packages/@aws-cdk/aws-cloudwatch/lib/graph.ts | 1 + .../aws-cloudwatch/test/test.graphs.ts | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts index ecd9ee9389dee..c97463a218cbd 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts @@ -181,6 +181,7 @@ export class GraphWidget extends ConcreteWidget { view: 'timeSeries', title: this.props.title, region: this.props.region || cdk.Aws.REGION, + stacked: this.props.stacked, metrics: metrics.length > 0 ? metrics : undefined, annotations: horizontalAnnoations.length > 0 ? { horizontal: horizontalAnnoations } : undefined, yAxis: { diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts index 8e994cde8de34..2d5a2a9375343 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts @@ -3,6 +3,31 @@ import { Test } from 'nodeunit'; import { Alarm, AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib'; export = { + 'add stacked property to graphs'(test: Test) { + // WHEN + const stack = new Stack(); + const widget = new GraphWidget({ + title: 'Test widget', + stacked: true + }); + + // THEN + test.deepEqual(stack.resolve(widget.toJson()), [{ + type: 'metric', + width: 6, + height: 6, + properties: { + view: 'timeSeries', + title: 'Test widget', + region: { Ref: 'AWS::Region' }, + stacked: true, + yAxis: {} + } + }]); + + test.done(); + }, + 'add metrics to graphs on either axis'(test: Test) { // WHEN const stack = new Stack();