Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(plugins): cover auto-reply source gate and group continue-result

rmyndhariscf076b1b1e29
diff --git a/src/plugins/extensions/auto-reply/auto-reply.plugin.spec.ts b/src/plugins/extensions/auto-reply/auto-reply.plugin.spec.ts
index 3efdf5c27..2cdc605ca 100644
--- a/src/plugins/extensions/auto-reply/auto-reply.plugin.spec.ts
+++ b/src/plugins/extensions/auto-reply/auto-reply.plugin.spec.ts
@@ -63,8 +63,20 @@ describe('AutoReplyPlugin', () => {
const { context, getHandler } = makeContext(reply);
await new AutoReplyPlugin().onEnable(context);
- await getHandler()(ctxFor(inbound({ isGroup: true })));
+ const result = await getHandler()(ctxFor(inbound({ isGroup: true })));
expect(reply).not.toHaveBeenCalled();
+ expect(result).toEqual({ continue: true });
+ });
+
+ it('does NOT reply when the message did not originate from the engine', async () => {
+ const reply = jest.fn();
+ const { context, getHandler } = makeContext(reply);
+ await new AutoReplyPlugin().onEnable(context);
+
+ const result = await getHandler()({ ...ctxFor(inbound()), source: 'API' });
+
+ expect(reply).not.toHaveBeenCalled();
+ expect(result).toEqual({ continue: true });
});
});