Add test for hellthreadPolicy

This commit is contained in:
Alex Gleason 2023-03-26 16:02:05 -05:00
parent 254b0f1f11
commit 9ca50cbe82
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

View File

@ -0,0 +1,14 @@
import { assert } from '../deps.ts';
import { buildEvent, buildInputMessage } from '../test.ts';
import hellthreadPolicy from './hellthread-policy.ts';
Deno.test('blocks events with too many mentioned users', async () => {
const tags = [['p'], ['p'], ['p']];
const msg0 = buildInputMessage();
const msg1 = buildInputMessage({ event: buildEvent({ tags }) });
assert((await hellthreadPolicy(msg0, { limit: 1 })).action === 'accept');
assert((await hellthreadPolicy(msg1, { limit: 1 })).action === 'reject');
});