Skip to content

Add support for window.show() #151

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

Merged
merged 2 commits into from
Dec 29, 2024

Conversation

curtisblackwell
Copy link
Contributor

This PR adds support for showing windows (I'll open the necessary PR in the NativePHP/laravel repo soon). I tried adding tests to match the dialog and clipboard tests, but I couldn't figure out why I was getting an error when I tried asserting a method was called.

Here's the error in case you have suggestions you'd like me to try:

FAIL  electron-plugin/tests/endpoints/window.test.ts
  ● Test suite failed to run

    electron-plugin/tests/endpoints/window.test.ts:36:21 - error TS2339: Property 'window' does not exist on type 'typeof CrossProcessExports'.

    36     expect(electron.window.show).toHaveBeenCalled();

@simonhamp
Copy link
Member

I think the error you're seeing is because window isn't a child of electron - I think you'll need to mock the BrowserWindow API.

But bear in mind I don't know much about how Jest works 😅

@curtisblackwell
Copy link
Contributor Author

Turns out it was just the state that needed to be mocked for these specific tests and they're now passing.

I spent a long time trying to figure out how to mock electron.BrowserWindow correctly as well, but no dice. That'll be necessary to more thoroughly test window.ts, but I'm not great with JavaScript mocking and don't really have the patience to figure it out on my own.

Copy link
Member

@simonhamp simonhamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This is fine

@simonhamp simonhamp merged commit e14d68e into NativePHP:main Dec 29, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants