-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor arguments and type tests for functions.* APIs.
- Loading branch information
Filip Maj
committed
Dec 7, 2023
1 parent
456c49b
commit 2f1f9da
Showing
4 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { TokenOverridable } from './common'; | ||
|
||
interface ExecutionID { | ||
function_execution_id: string; | ||
} | ||
|
||
// https://api.slack.com/methods/functions.completeError | ||
export interface FunctionsCompleteErrorArguments extends ExecutionID, TokenOverridable { | ||
error: string; | ||
} | ||
|
||
// https://api.slack.com/methods/functions.completeSuccess | ||
export interface FunctionsCompleteSuccessArguments extends ExecutionID, TokenOverridable { | ||
outputs: Record<string, unknown>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expectAssignable, expectError } from 'tsd'; | ||
import { WebClient } from '../../../src/WebClient'; | ||
|
||
const web = new WebClient('TOKEN'); | ||
|
||
// functions.completeError | ||
// -- sad path | ||
expectError(web.functions.completeError()); // lacking argument | ||
expectError(web.functions.completeError({})); // empty argument | ||
expectError(web.functions.completeError({ | ||
function_execution_id: 'Fx1234', // missing error | ||
})); | ||
expectError(web.functions.completeError({ | ||
error: 'boomsies', // missing function_execution_id | ||
})); | ||
// -- happy path | ||
expectAssignable<Parameters<typeof web.functions.completeError>>([{ | ||
function_execution_id: 'Fx1234', | ||
error: 'oh noes', | ||
}]); | ||
|
||
// functions.completeSuccess | ||
// -- sad path | ||
expectError(web.functions.completeSuccess()); // lacking argument | ||
expectError(web.functions.completeSuccess({})); // empty argument | ||
expectError(web.functions.completeSuccess({ | ||
function_execution_id: 'Fx1234', // missing output | ||
})); | ||
expectError(web.functions.completeSuccess({ | ||
outputs: {}, // missing function_execution_id | ||
})); | ||
// -- happy path | ||
expectAssignable<Parameters<typeof web.functions.completeSuccess>>([{ | ||
function_execution_id: 'Fx1234', | ||
outputs: {}, | ||
}]); |