Files
dsh-telegram-channel/tests/apply.test.ts
T
owoandCursor a83af2f33c Simplify install with one-click scripts; honor HTTP(S)_PROXY for Telegram.
Add install.ps1/install.sh, shrink README to script-first flow, register bot commands, and route API calls through undici EnvHttpProxyAgent when a proxy is set (v0.2.2).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 17:46:01 +08:00

22 lines
721 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { apply } from '../src/index.ts'
test('apply without token does not throw and does not start effect', () => {
const effects: string[] = []
const ctx = {
effect(_fn: () => () => void, name: string) {
effects.push(name)
return () => {}
},
logger: { info() {}, error() {}, warn() {} },
agents: {},
} as any
const prev = process.env.DSH_TELEGRAM_TOKEN
delete process.env.DSH_TELEGRAM_TOKEN
assert.doesNotThrow(() => apply(ctx, { token: '', allowedUserIds: [1] }))
assert.deepEqual(effects, [])
if (prev !== undefined) process.env.DSH_TELEGRAM_TOKEN = prev
else delete process.env.DSH_TELEGRAM_TOKEN
})