Skip to content

Commit

Permalink
fixing up some aws receiver specs, expanding on shortcut type tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj committed Sep 27, 2024
1 parent e2bc2f8 commit 02024fe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
23 changes: 15 additions & 8 deletions test/types/shortcut.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,27 @@ app.shortcut<MessageShortcut>({}, async ({ shortcut, say }) => {
expectType<SayFn>(say);
});

// If the constraint is unspecific, say may be undefined and the shortcut is the more general SlackShortcut type
app.shortcut({}, async ({ shortcut, say }) => {
// If the constraint is unspecific, say will be unavailable
expectError(app.shortcut({}, async ({ say }) => say()));

// If the constraint is unspecific, the shortcut is the more general SlackShortcut type
app.shortcut({}, async ({ shortcut }) => {
expectType<SlackShortcut>(shortcut);
expectType<SayFn | undefined>(say);
});

// `say` in listener should be unavailable if constraint is type:shortcut
expectError(app.shortcut({ type: 'shortcut' }, async ({ say }) => say()));

// Shortcut in listener should be GlobalShortcut if constraint is type:shortcut
app.shortcut({ type: 'shortcut' }, async ({ shortcut, say }) => {
app.shortcut({ type: 'shortcut' }, async ({ shortcut }) => {
expectType<GlobalShortcut>(shortcut);
expectType<undefined>(say);
});
// If shortcut is parameterized with GlobalShortcut, say argument in callback should be type undefined
app.shortcut<GlobalShortcut>({}, async ({ shortcut, say }) => {
expectType<undefined>(say);

// If shortcut is parameterized with GlobalShortcut, say argument in callback should not be available
expectError(app.shortcut<GlobalShortcut>({}, async ({ say }) => say()));

// If shortcut is parameterized with GlobalShortcut, shortcut parameter should be of type GlobalShortcut
app.shortcut<GlobalShortcut>({}, async ({ shortcut }) => {
expectType<GlobalShortcut>(shortcut);
});

Expand Down
2 changes: 1 addition & 1 deletion test/unit/helpers/receivers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function createDummyAWSPayload(
'X-Slack-Signature': `v0=${signature}`,
},
multiValueHeaders: {},
queryStringParameters: null,
queryStringParameters: {},
multiValueQueryStringParameters: null,
pathParameters: null,
stageVariables: null,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/receivers/AwsLambdaReceiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('AwsLambdaReceiver', () => {
'X-Slack-Signature': `v0=${signature}XXXXXXXX`, // invalid signature
},
multiValueHeaders: {},
queryStringParameters: null,
queryStringParameters: {},
multiValueQueryStringParameters: null,
pathParameters: null,
stageVariables: null,
Expand Down

0 comments on commit 02024fe

Please sign in to comment.