Skip to content

Commit

Permalink
test: add test for passing multiple arguments to hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Oct 9, 2023
1 parent 44f378a commit 26a75cc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/runner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand Down

0 comments on commit 26a75cc

Please sign in to comment.