Skip to content

Commit

Permalink
test: Update lint-staged config
Browse files Browse the repository at this point in the history
  • Loading branch information
dashmug committed Jul 21, 2023
1 parent 3557582 commit 656938c
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
"*.js": ["prettier --write", "eslint --format=pretty --quiet --fix --cache"],
"*.ts": () => ["pnpm format", "pnpm typecheck", "pnpm test --only-changed"],
"*.ts": () => [
"pnpm format",
"pnpm typecheck",
"pnpm test -- --only-changed",
],
"*.{json,yml,md}": "prettier --write --ignore-unknown",
"*.sh": "shellcheck",
};
124 changes: 124 additions & 0 deletions src/lib/__tests__/__snapshots__/base-stack.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`BaseStack generates an expected CloudFormation template 1`] = `
{
"Parameters": {
"BootstrapVersion": {
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]",
"Type": "AWS::SSM::Parameter::Value<String>",
},
},
"Resources": {
"Bucket83908E77": {
"DeletionPolicy": "Retain",
"Properties": {
"Tags": [
{
"Key": "myorg:application:description",
"Value": "Opinionated CDK Typescript Boilerplate",
},
{
"Key": "myorg:application:environment",
"Value": "prod",
},
{
"Key": "myorg:application:name",
"Value": "cdk-app-ts-boilerplate",
},
{
"Key": "myorg:application:repository",
"Value": "https://github.com/dashmug/cdk-app-ts-boilerplate",
},
{
"Key": "myorg:project:customer",
"Value": "myclient",
},
{
"Key": "myorg:project:name",
"Value": "myproject",
},
{
"Key": "myorg:project:owner",
"Value": "myteam",
},
{
"Key": "myorg:stack:name",
"Value": "TestStack",
},
],
},
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Retain",
},
"Queue4A7E3555": {
"DeletionPolicy": "Delete",
"Properties": {
"Tags": [
{
"Key": "myorg:application:description",
"Value": "Opinionated CDK Typescript Boilerplate",
},
{
"Key": "myorg:application:environment",
"Value": "prod",
},
{
"Key": "myorg:application:name",
"Value": "cdk-app-ts-boilerplate",
},
{
"Key": "myorg:application:repository",
"Value": "https://github.com/dashmug/cdk-app-ts-boilerplate",
},
{
"Key": "myorg:project:customer",
"Value": "myclient",
},
{
"Key": "myorg:project:name",
"Value": "myproject",
},
{
"Key": "myorg:project:owner",
"Value": "myteam",
},
{
"Key": "myorg:stack:name",
"Value": "TestStack",
},
],
},
"Type": "AWS::SQS::Queue",
"UpdateReplacePolicy": "Delete",
},
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5",
],
{
"Ref": "BootstrapVersion",
},
],
},
],
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.",
},
],
},
},
}
`;
8 changes: 7 additions & 1 deletion src/lib/__tests__/base-stack.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { App, StackProps } from "aws-cdk-lib";
import { App, type StackProps } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { Bucket } from "aws-cdk-lib/aws-s3";
import { Queue } from "aws-cdk-lib/aws-sqs";
import type { Construct } from "constructs";
import { BaseStack } from "src/lib/base-stack";

Expand All @@ -9,6 +10,7 @@ class TestStack extends BaseStack {
super(scope, id, props);

new Bucket(this, "Bucket");
new Queue(this, "Queue");
}
}

Expand Down Expand Up @@ -55,4 +57,8 @@ describe("BaseStack", () => {
],
});
});

it("generates an expected CloudFormation template", () => {
expect(template).toMatchSnapshot();
});
});

0 comments on commit 656938c

Please sign in to comment.