From 9ca50cbe8275f960f803a3342512eebd7d708108 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 26 Mar 2023 16:02:05 -0500 Subject: [PATCH] Add test for hellthreadPolicy --- src/policies/hellthread-policy.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/policies/hellthread-policy.test.ts diff --git a/src/policies/hellthread-policy.test.ts b/src/policies/hellthread-policy.test.ts new file mode 100644 index 0000000..b350e78 --- /dev/null +++ b/src/policies/hellthread-policy.test.ts @@ -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'); +});