Skip to content

Commit e770527

Browse files
committed
chore: tests
1 parent 4cae789 commit e770527

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/idempotency/tests/unit/idempotencyDecorator.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTimeout } from 'node:timers/promises';
12
import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
23
import context from '@aws-lambda-powertools/testing-utils/context';
34
import type { Context } from 'aws-lambda';
@@ -7,15 +8,16 @@ import { BasePersistenceLayer } from '../../src/persistence/BasePersistenceLayer
78
import { PersistenceLayerTestClass } from '../helpers/idempotencyUtils.js';
89

910
describe('Given a class with a function to decorate', () => {
10-
it('maintains the scope of the decorated function', () => {
11+
it('maintains the scope of the decorated function', async () => {
1112
// Prepare
1213
class TestClass implements LambdaInterface {
1314
private readonly foo = 'foo';
1415

1516
@idempotent({
1617
persistenceStore: new PersistenceLayerTestClass(),
1718
})
18-
public handler(_event: unknown, _context: Context) {
19+
public async handler(_event: unknown, _context: Context) {
20+
await setTimeout(0); // Simulate some async operation
1921
return this.privateMethod();
2022
}
2123

@@ -28,7 +30,7 @@ describe('Given a class with a function to decorate', () => {
2830
const handler = handlerClass.handler.bind(handlerClass);
2931

3032
// Act
31-
const result = handler({}, context);
33+
const result = await handler({}, context);
3234

3335
// Assess
3436
expect(result).toBe('private foo');

0 commit comments

Comments
 (0)