kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
46 wiersze
972 B
TypeScript
46 wiersze
972 B
TypeScript
![]() |
import test from 'ava'
|
||
|
|
||
|
import { SlackClient } from '@/services/slack'
|
||
|
|
||
|
import './_utils'
|
||
|
|
||
|
test('SlackClient.sendMessage', async (t) => {
|
||
|
if (!process.env.SLACK_API_KEY) {
|
||
|
return t.pass()
|
||
|
}
|
||
|
|
||
|
t.timeout(2 * 60 * 1000)
|
||
|
const client = new SlackClient()
|
||
|
|
||
|
const result = await client.sendMessage({
|
||
|
text: 'Hello World!',
|
||
|
channelId: 'D05B1AHA55L'
|
||
|
})
|
||
|
t.truthy(result)
|
||
|
})
|
||
|
|
||
|
test('SlackClient.sendAndWaitForReply', async (t) => {
|
||
|
if (!process.env.SLACK_API_KEY) {
|
||
|
return t.pass()
|
||
|
}
|
||
|
|
||
|
t.timeout(2 * 60 * 1000)
|
||
|
const client = new SlackClient()
|
||
|
|
||
|
await t.throwsAsync(
|
||
|
async () => {
|
||
|
await client.sendAndWaitForReply({
|
||
|
text: 'Please reply to this message with "yes" or "no"',
|
||
|
channelId: 'D05B1AHA55L',
|
||
|
validate: () => false, // never validate so we timeout
|
||
|
timeoutMs: 1000,
|
||
|
intervalMs: 100
|
||
|
})
|
||
|
},
|
||
|
{
|
||
|
instanceOf: Error,
|
||
|
message: 'Reached timeout waiting for reply'
|
||
|
}
|
||
|
)
|
||
|
})
|