Skip to content

Commit 3f87b4d

Browse files
authored
chore(lambda-nodejs): migrate tests to assertions (#18497)
---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 03d388d commit 3f87b4d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/@aws-cdk/aws-lambda-nodejs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
"license": "Apache-2.0",
7373
"devDependencies": {
74-
"@aws-cdk/assert-internal": "0.0.0",
74+
"@aws-cdk/assertions": "0.0.0",
7575
"@aws-cdk/aws-ec2": "0.0.0",
7676
"@aws-cdk/cdk-build-tools": "0.0.0",
7777
"@aws-cdk/cdk-integ-tools": "0.0.0",

packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import '@aws-cdk/assert-internal/jest';
21
import * as fs from 'fs';
32
import * as path from 'path';
4-
import { ABSENT } from '@aws-cdk/assert-internal';
3+
import { Template, Match } from '@aws-cdk/assertions';
54
import { Vpc } from '@aws-cdk/aws-ec2';
65
import { CodeConfig, Runtime } from '@aws-cdk/aws-lambda';
76
import { Stack } from '@aws-cdk/core';
@@ -40,7 +39,7 @@ test('NodejsFunction with .ts handler', () => {
4039
entry: expect.stringContaining('function.test.handler1.ts'), // Automatically finds .ts handler file
4140
}));
4241

43-
expect(stack).toHaveResource('AWS::Lambda::Function', {
42+
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
4443
Handler: 'index.handler',
4544
Runtime: 'nodejs14.x',
4645
});
@@ -155,7 +154,7 @@ test('configures connection reuse for aws sdk', () => {
155154
// WHEN
156155
new NodejsFunction(stack, 'handler1');
157156

158-
expect(stack).toHaveResource('AWS::Lambda::Function', {
157+
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
159158
Environment: {
160159
Variables: {
161160
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
@@ -170,8 +169,8 @@ test('can opt-out of connection reuse for aws sdk', () => {
170169
awsSdkConnectionReuse: false,
171170
});
172171

173-
expect(stack).toHaveResource('AWS::Lambda::Function', {
174-
Environment: ABSENT,
172+
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
173+
Environment: Match.absent(),
175174
});
176175
});
177176

@@ -183,7 +182,7 @@ test('NodejsFunction in a VPC', () => {
183182
new NodejsFunction(stack, 'handler1', { vpc });
184183

185184
// THEN
186-
expect(stack).toHaveResource('AWS::Lambda::Function', {
185+
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
187186
VpcConfig: {
188187
SecurityGroupIds: [
189188
{

0 commit comments

Comments
 (0)