Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Testing on method #120

Open
esponges opened this issue Aug 4, 2024 · 0 comments
Open

Unit Testing on method #120

esponges opened this issue Aug 4, 2024 · 0 comments

Comments

@esponges
Copy link

esponges commented Aug 4, 2024

Hi,

We're using this tool in an internal SDK using React and I was wondering if there's a way to unit test the on event? I was checking the src code and you use the getWindows method helper but I'm not very sure if using a similar approach would work.

// App.tsx
  useEffect(() => {
    const onEvent = on('test', (event) => {
      console.log('do something', event);
      return Promise.resolve(event);
    });
    return () => onEvent.cancel();
  }, []);

// App.spec.tsx
describe('App', () => {
  it('test post-robot', async() => {
    const {container} = render(<App />);

    // this doesn't work — probably pass window from `getWindows` helper? 
    send(window, 'test', {
      name: 'test',
    });

    // probably assert using spying post-robot calls
  })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant