-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for window.show() (#151)
* Add support for window.show() * Mock state to ensure method is called
- Loading branch information
1 parent
0ef239b
commit e14d68e
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
resources/js/electron-plugin/tests/endpoints/window.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import startAPIServer, { APIProcess } from "../../src/server/api"; | ||
import axios from "axios"; | ||
import state from "../../src/server/state"; | ||
|
||
let apiServer: APIProcess; | ||
|
||
jest.mock('../../src/server/state', () => ({ | ||
...jest.requireActual('../../src/server/state'), | ||
windows: { | ||
main: { | ||
hide: jest.fn(), | ||
show: jest.fn(), | ||
}, | ||
} | ||
})) | ||
|
||
describe('Window test', () => { | ||
beforeEach(async () => { | ||
apiServer = await startAPIServer('randomSecret') | ||
|
||
axios.defaults.baseURL = `http://localhost:${apiServer.port}/api`; | ||
axios.defaults.headers.common['x-nativephp-secret'] = 'randomSecret'; | ||
}) | ||
|
||
afterEach(done => { | ||
apiServer.server.close(done); | ||
}); | ||
|
||
it('can hide a window', async () => { | ||
const response = await axios.post('/window/hide', { id: 'main' }); | ||
expect(response.status).toBe(200); | ||
expect(state.windows.main.hide).toHaveBeenCalled(); | ||
}); | ||
|
||
it('can show a window', async () => { | ||
const response = await axios.post('/window/show', { id: 'main' }); | ||
expect(response.status).toBe(200); | ||
expect(state.windows.main.show).toHaveBeenCalled(); | ||
}); | ||
}); |