← Public packages
@kentcdodds/slack
Read Slack conversations and safely send messages as the authorizing user through the saved slack OAuth integration.
Files
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { assertSlackMethod, isValidSlackMethod } from '../src/validation.ts'
test('accepts real Slack Web API method names, including camelCase', () => {
for (const method of [
'chat.postMessage',
'chat.postEphemeral',
'conversations.history',
'conversations.replies',
'conversations.list',
'users.info',
'users.list',
'auth.test',
]) {
assert.equal(isValidSlackMethod(method), true, method)
assert.equal(assertSlackMethod(method), method)
}
})
test('rejects invalid method names', () => {
for (const method of ['', 'a', '../x', 'Chat.post', '.chat', 'chat/post', 'chat.post?x=1', 'chat post', undefined, null, 42]) {
assert.equal(isValidSlackMethod(method), false, String(method))
assert.throws(() => assertSlackMethod(method), /Invalid Slack Web API method name\./)
}
})