From fd29a6995c27d1106b07595882f3f581ae602530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Wed, 26 Feb 2025 17:44:27 +0200 Subject: [PATCH] chore: update test fixture --- packages/util/index.test-d.ts | 47 +++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/packages/util/index.test-d.ts b/packages/util/index.test-d.ts index fe053fb4b..57fe89e8f 100644 --- a/packages/util/index.test-d.ts +++ b/packages/util/index.test-d.ts @@ -1,7 +1,11 @@ import middy from '@middy/core' import { expectType } from 'tsd' import { SSMClient } from '@aws-sdk/client-ssm' -import { APIGatewayProxyEvent, APIGatewayProxyResult, Context as LambdaContext } from 'aws-lambda' +import { + APIGatewayProxyEvent, + APIGatewayProxyResult, + Context as LambdaContext +} from 'aws-lambda' import * as util from '.' // eslint-disable-next-line @typescript-eslint/consistent-type-definitions @@ -85,6 +89,7 @@ TInternal succeed: () => {} }, response: null, + earlyResponse: null, error: null, internal: { boolean: true, @@ -133,7 +138,8 @@ interface DeepAwaitedTInternal { key: 'value' } promise: string // this was Promise in TInternal; - promiseObject: { // this was Promise<{key: "value"}> in TInternal + promiseObject: { + // this was Promise<{key: "value"}> in TInternal key: 'value' } } @@ -153,23 +159,44 @@ async function testGetInternalField (): Promise<{ number: 1 }> { expectType>(testGetInternalField()) // getInternal should get from internal store when array[string] -async function testGetInternalFields (): Promise<{ boolean: true, string: 'string', promiseObject_key: 'value' }> { - const result = await util.getInternal(['boolean', 'string', 'promiseObject.key'], sampleRequest) - expectType<{ boolean: true, string: 'string', promiseObject_key: 'value' }>(result) +async function testGetInternalFields (): Promise<{ + boolean: true + string: 'string' + promiseObject_key: 'value' +}> { + const result = await util.getInternal( + ['boolean', 'string', 'promiseObject.key'], + sampleRequest + ) + expectType<{ boolean: true, string: 'string', promiseObject_key: 'value' }>( + result + ) return result } -expectType>(testGetInternalFields()) +expectType< +Promise<{ boolean: true, string: 'string', promiseObject_key: 'value' }> +>(testGetInternalFields()) // getInternal should get from internal store when object -async function testGetAndRemapInternal (): Promise<{ newKey: string, newKey2: 'value' }> { - const result = await util.getInternal({ newKey: 'promise', newKey2: 'promiseObject.key' }, sampleRequest) +async function testGetAndRemapInternal (): Promise<{ + newKey: string + newKey2: 'value' +}> { + const result = await util.getInternal( + { newKey: 'promise', newKey2: 'promiseObject.key' }, + sampleRequest + ) expectType<{ newKey: string, newKey2: 'value' }>(result) return result } -expectType>(testGetAndRemapInternal()) +expectType>( + testGetAndRemapInternal() +) // getInternal should get from internal store a nested value -async function testGetInternalNested (): Promise<{ promiseObject_key: 'value' }> { +async function testGetInternalNested (): Promise<{ + promiseObject_key: 'value' +}> { const result = await util.getInternal('promiseObject.key', sampleRequest) expectType<{ promiseObject_key: 'value' }>(result) return result