Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 8c54417

Browse files
committed
Refactor IPC event names to use "media" instead of "video"
1 parent ed9da8b commit 8c54417

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/enum/ipc-event.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export enum IpcEvent {
22
CANCEL_CONVERSION = 'cancel-conversion',
33
CANCEL_ITEM_CONVERSION = 'cancel-item-conversion',
4-
CONVERT_VIDEO = 'convert-video',
4+
CONVERT_MEDIA = 'convert-media',
55
DIALOG_SELECT_DIRECTORY = 'dialog:select-directory',
66
GET_DESKTOP_PATH = 'get-desktop-path',
77
SHOW_WINDOW = 'show-window',
@@ -19,7 +19,7 @@ export enum IpcEvent {
1919
export const ipcMainEvents = [
2020
IpcEvent.CANCEL_CONVERSION,
2121
IpcEvent.CANCEL_ITEM_CONVERSION,
22-
IpcEvent.CONVERT_VIDEO,
22+
IpcEvent.CONVERT_MEDIA,
2323
IpcEvent.DIALOG_SELECT_DIRECTORY,
2424
IpcEvent.GET_DESKTOP_PATH,
2525
IpcEvent.SHOW_WINDOW,

src/lib/ipc-handlers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function configureIpcHandlers(ipcMain: IpcMain): void {
2424
});
2525

2626
ipcMain.handle(
27-
IpcEvent.CONVERT_VIDEO,
27+
IpcEvent.CONVERT_MEDIA,
2828
async (
2929
event: IpcMainInvokeEvent,
3030
{

src/preload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function setupGlobals() {
3636
return ipcRenderer.invoke(IpcEvent.CANCEL_CONVERSION);
3737
},
3838
convertVideo(id: string, filePath: string, outputFormat: string, saveDirectory: string) {
39-
return ipcRenderer.invoke(IpcEvent.CONVERT_VIDEO, { id, filePath, outputFormat, saveDirectory });
39+
return ipcRenderer.invoke(IpcEvent.CONVERT_MEDIA, { id, filePath, outputFormat, saveDirectory });
4040
},
4141
send(channel: string, ...args: unknown[]) {
4242
ipcRenderer.send(channel, ...args);

tests/main/ipc-handler.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('configureIpcHandlers', () => {
7676
});
7777
});
7878

79-
test('should handle CONVERT_VIDEO', async () => {
79+
test('should handle CONVERT_MEDIA', async () => {
8080
const mockHandleConversion = jest.mocked(handleConversion);
8181
mockHandleConversion.mockImplementation(
8282
(_event, _id, _filePath, _outputFormat, _saveDirectory, resolve) => {
@@ -87,7 +87,7 @@ describe('configureIpcHandlers', () => {
8787
configureIpcHandlers(ipcMain);
8888

8989
const handler = (ipcMain.handle as jest.Mock).mock.calls.find(
90-
([event]) => event === IpcEvent.CONVERT_VIDEO
90+
([event]) => event === IpcEvent.CONVERT_MEDIA
9191
)[1];
9292

9393
const result = await handler(

tests/main/preload.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ describe('setupGlobals', () => {
101101
expect(ipcRenderer.invoke).toHaveBeenCalledWith(IpcEvent.CANCEL_ITEM_CONVERSION, 1);
102102
});
103103

104-
test('should invoke CONVERT_VIDEO event with correct arguments', async () => {
104+
test('should invoke CONVERT_MEDIA event with correct arguments', async () => {
105105
await setupGlobals();
106106
const electron = (contextBridge.exposeInMainWorld as jest.Mock).mock.calls[0][1];
107107

108108
await electron.convertVideo('1', '/mock/path/video.mp4', 'mp4', '/mock/save');
109109

110-
expect(ipcRenderer.invoke).toHaveBeenCalledWith(IpcEvent.CONVERT_VIDEO, {
110+
expect(ipcRenderer.invoke).toHaveBeenCalledWith(IpcEvent.CONVERT_MEDIA, {
111111
id: '1',
112112
filePath: '/mock/path/video.mp4',
113113
outputFormat: 'mp4',

0 commit comments

Comments
 (0)