import pytest
from app.hooks import EventDispatcher, listen_event

def test_register_and_dispatch():
    results = []
    def listener(a, b=None):
        results.append((a, b))
    EventDispatcher.register('evt', listener)
    EventDispatcher.dispatch('evt', 1, b=2)
    assert results == [(1, 2)]

def test_listen_event_decorator():
    results = []
    @listen_event('evt2')
    def handler(x):
        results.append(x)
    EventDispatcher.dispatch('evt2', 'hello')
    assert results == ['hello']
