'how to test window listener(listen chrome extension result) with callback in react?

I am testing windows listener for notification from chrome extension. But I am struggling writing test... The event signer:connected is from chrome extension click.

useEffect(() => {

    window.addEventListener("signer:connected", (msg) => {
      setSignerLocked(!msg.detail.isUnlocked);
      setSignerConnected(true);
      setActiveKey(msg.detail.activeKey);
      
 
    });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source