Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszantas committed Apr 22, 2022
1 parent c0d550f commit ebebd7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions applications/launchpad_v2/__tests__/mocks/mockTauriIPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ export const defaultTauriMockValues: Record<string, unknown> = {
arch: 'x86_64',
platform: 'darwin',
ostype: 'Darwin',
}
},
}

/**
* The Tauri IPC mock.
*
*
* It uses Tauri's mockIPC and returns the value set in the `props`.
* If nothing found in `props`, it will return a value from from `defaultTauriMockValues`.
*
*
* @param {Record<string, unknown>} props - pass the value you expect in tests
*
*
* @example
* // Use default values:
* tauriIPCMock()
*
*
* // Get given value from specific API module (ie. 'platform' from 'os' module)
* tauriIPCMock({
* os: {
Expand All @@ -43,14 +43,25 @@ export const tauriIPCMock = (props: Record<string, unknown> = undefined) => {
})
}

const tauriCmdMock = (cmd: string, args: Record<string, unknown>, props: Record<string, unknown>) => {
const tauriCmdMock = (
cmd: string,
args: Record<string, unknown>,
props: Record<string, unknown>,
) => {
const tauriModule = (args?.__tauriModule as string)?.toLowerCase()
const messageCmd = (args?.message as { cmd?: string })?.cmd?.toLowerCase()

if (tauriModule && messageCmd) {
if (props && Object.keys(props).includes(tauriModule) && Object.keys(props[tauriModule ]).includes(messageCmd)) {
return props[tauriModule][messageCmd ]
} else if (Object.keys(defaultTauriMockValues).includes(tauriModule) && Object.keys(defaultTauriMockValues[tauriModule]).includes(messageCmd)) {
if (
props &&
Object.keys(props).includes(tauriModule) &&
Object.keys(props[tauriModule]).includes(messageCmd)
) {
return props[tauriModule][messageCmd]
} else if (
Object.keys(defaultTauriMockValues).includes(tauriModule) &&
Object.keys(defaultTauriMockValues[tauriModule]).includes(messageCmd)
) {
return defaultTauriMockValues[tauriModule][messageCmd]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface KeyboardKeysProps {
keys: string[]
}
}

0 comments on commit ebebd7c

Please sign in to comment.