From 26a75cc3694de8104c11d04d40884dbcb7586e81 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Mon, 9 Oct 2023 13:00:33 +0530 Subject: [PATCH] test: add test for passing multiple arguments to hooks --- tests/runner.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/runner.spec.ts b/tests/runner.spec.ts index b0c2739..bb74af4 100644 --- a/tests/runner.spec.ts +++ b/tests/runner.spec.ts @@ -113,6 +113,25 @@ test.group('Runner', () => { assert.deepEqual(stack, ['hello world', 'hello world']) }) + test('pass multiple arguments to hook handlers', async ({ assert }) => { + const hooks = new Hooks() + const stack: string[] = [] + + hooks.add('save', (message: string, message1: string) => { + stack.push(message) + stack.push(message1) + }) + hooks.add('save', (message: string, message1: string) => { + stack.push(message) + stack.push(message1) + }) + + const runner = hooks.runner('save') + await runner.run('hi world', 'hello world') + + assert.deepEqual(stack, ['hi world', 'hello world', 'hi world', 'hello world']) + }) + test('filter hooks by name', async ({ assert }) => { const hooks = new Hooks() const stack: string[] = []