-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimization about preference window
- Delete action and store of preference - because It don't need to manage globally. - unnecessary action can cause confuse.
- Loading branch information
Showing
22 changed files
with
131 additions
and
306 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
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
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
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,22 @@ | ||
import { ipcMain } from 'electron'; | ||
import * as pref from 'main/utils/window/preference'; | ||
import handleIPC from '../handleIPC'; | ||
|
||
describe('test handleIPC', () => { | ||
handleIPC(); | ||
|
||
it('should match number of whole handler', () => { | ||
expect(ipcMain.on).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should call preference open', () => { | ||
expect(ipcMain.on) | ||
.toHaveBeenCalledWith('preference.open', expect.any(Function)); | ||
|
||
const openPreference = jest.spyOn(pref, 'openPreference'); | ||
const cb = ipcMain.on.mock.calls.filter(i => i[0] === 'preference.open')[0][1]; | ||
|
||
cb(); | ||
expect(openPreference).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,46 @@ | ||
import { BrowserWindow } from 'electron'; | ||
import { PREFERENCE_PATH } from 'config'; | ||
import { preference, openPreference } from 'main/utils/window/preference'; | ||
|
||
|
||
describe('test window/preference', () => { | ||
describe('when preference is null', () => { | ||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
const mockWindow = new BrowserWindow(); | ||
BrowserWindow.mockImplementationOnce(() => mockWindow); | ||
|
||
openPreference(); | ||
|
||
it('match preference', () => { | ||
expect(preference).toEqual(mockWindow); | ||
}); | ||
|
||
it('match loadURL', () => { | ||
expect(preference.loadURL).toHaveBeenCalledTimes(1); | ||
expect(preference.loadURL).toHaveBeenCalledWith(PREFERENCE_PATH); | ||
}); | ||
|
||
it('match on.close', () => { | ||
expect(mockWindow.on).toHaveBeenCalledTimes(1); | ||
expect(mockWindow.on).toHaveBeenCalledWith('close', expect.any(Function)); | ||
|
||
expect(preference).toEqual(mockWindow); | ||
const cb = mockWindow.on.mock.calls[0][1]; | ||
|
||
cb(); | ||
expect(preference).toEqual(null); | ||
}); | ||
}); | ||
|
||
it('when preference is not null', () => { | ||
const mockWindow = new BrowserWindow(); | ||
BrowserWindow.mockImplementationOnce(() => mockWindow); | ||
|
||
openPreference(); | ||
openPreference(); | ||
|
||
expect(preference.show).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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,10 @@ | ||
import { ipcMain } from 'electron'; | ||
import { openPreference } from 'main/utils/window/preference'; | ||
|
||
function handleIPC() { | ||
ipcMain.on('preference.open', () => { | ||
openPreference(); | ||
}); | ||
} | ||
|
||
export default handleIPC; |
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
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
Oops, something went wrong.