diff --git a/src/main/Extensions/ApplicationSearch/Linux/LinuxApplication.test.ts b/src/main/Extensions/ApplicationSearch/Linux/LinuxApplication.test.ts new file mode 100644 index 000000000..961759e2e --- /dev/null +++ b/src/main/Extensions/ApplicationSearch/Linux/LinuxApplication.test.ts @@ -0,0 +1,27 @@ +import type { Image } from "@common/Core/Image"; +import { describe, expect, it } from "vitest"; +import { LinuxApplication } from "./LinuxApplication"; + +describe(LinuxApplication, () => { + describe(LinuxApplication.prototype.toSearchResultItem, () => { + it("should have the OpenDesktopFile action as default", () => { + const application = new LinuxApplication("MyApp", "/Path/To/MyApp.desktop", {}); + const defaultAction = application.toSearchResultItem().defaultAction; + expect(defaultAction.handlerId).toBe("LaunchDesktopFile"); + }); + + it("should have ShowItemInFileExplorer and CopyToClipboard as additional actions", () => { + const application = new LinuxApplication("MyApp", "/Path/To/MyApp.desktop", {}); + const additionalActions = application.toSearchResultItem().additionalActions; + expect(additionalActions?.map((a) => a.handlerId)).toEqual(["ShowItemInFileExplorer", "copyToClipboard"]); + }); + }); + + describe(LinuxApplication.prototype.getId, () => { + it("should return a base64 encoded string containing the file path", () => { + const application = new LinuxApplication("MyApp", "/Path/To/MyApp.desktop", {}); + const base64DecodedId = Buffer.from(application.getId(), "base64").toString(); + expect(base64DecodedId).toBe("[LinuxApplication][/Path/To/MyApp.desktop]"); + }); + }); +}); diff --git a/src/main/Extensions/ApplicationSearch/Windows/WindowsApplication.test.ts b/src/main/Extensions/ApplicationSearch/Windows/WindowsApplication.test.ts new file mode 100644 index 000000000..b256f3113 --- /dev/null +++ b/src/main/Extensions/ApplicationSearch/Windows/WindowsApplication.test.ts @@ -0,0 +1,31 @@ +import type { Image } from "@common/Core/Image"; +import { describe, expect, it } from "vitest"; +import { WindowsApplication } from "./WindowsApplication"; + +describe(WindowsApplication, () => { + describe(WindowsApplication.prototype.toSearchResultItem, () => { + it("should have OpenFilePath as the default action", () => { + const application = new WindowsApplication("name", "filePath", {}); + const defaultAction = application.toSearchResultItem().defaultAction; + expect(defaultAction.handlerId).toBe("OpenFilePath"); + }); + + it("should have OpenFilePathAsAdministrator as an additional action", () => { + const application = new WindowsApplication("name", "filePath", {}); + const additionalActions = application.toSearchResultItem().additionalActions; + expect(additionalActions?.map((a) => a.handlerId)).toEqual([ + "WindowsOpenAsAdministrator", + "ShowItemInFileExplorer", + "copyToClipboard", + ]); + }); + }); + + describe(WindowsApplication.prototype.getId, () => { + it("should return a base64 encoded string containing the file path", () => { + const application = new WindowsApplication("name", "filePath", {}); + const base64DecodedId = Buffer.from(application.getId(), "base64").toString(); + expect(base64DecodedId).toBe("[WindowsApplication][filePath]"); + }); + }); +}); diff --git a/src/main/Extensions/ApplicationSearch/macOS/MacOsApplication.test.ts b/src/main/Extensions/ApplicationSearch/macOS/MacOsApplication.test.ts new file mode 100644 index 000000000..3c15a2a1f --- /dev/null +++ b/src/main/Extensions/ApplicationSearch/macOS/MacOsApplication.test.ts @@ -0,0 +1,27 @@ +import type { Image } from "@common/Core/Image"; +import { describe, expect, it } from "vitest"; +import { MacOsApplication } from "./MacOsApplication"; + +describe(MacOsApplication, () => { + describe(MacOsApplication.prototype.toSearchResultItem, () => { + it("should have the OpenFilePath action as default", () => { + const application = new MacOsApplication("MyApp", "/Path/To/MyApp.app", {}); + const defaultAction = application.toSearchResultItem().defaultAction; + expect(defaultAction.handlerId).toBe("OpenFilePath"); + }); + + it("should OpenFileLocation and CopyToclipboard as additional actions", () => { + const application = new MacOsApplication("MyApp", "/Path/To/MyApp.app", {}); + const additionalActions = application.toSearchResultItem().additionalActions; + expect(additionalActions?.map((a) => a.handlerId)).toEqual(["ShowItemInFileExplorer", "copyToClipboard"]); + }); + }); + + describe(MacOsApplication.prototype.getId, () => { + it("should be a base64 encoded string including the file path", () => { + const application = new MacOsApplication("MyApp", "/Path/To/MyApp.app", {}); + const base64DecodedId = Buffer.from(application.getId(), "base64").toString(); + expect(base64DecodedId).toBe("[MacOsApplication][/Path/To/MyApp.app]"); + }); + }); +});