forked from oliverschwendener/ueli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: application classes (oliverschwendener#1239)
* test: added tests for MacOsApplication and WindowsApplication * Added test for LinuxApplication
- Loading branch information
1 parent
b9fa5cd
commit 37057e1
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/Extensions/ApplicationSearch/Linux/LinuxApplication.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,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", <Image>{}); | ||
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", <Image>{}); | ||
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", <Image>{}); | ||
const base64DecodedId = Buffer.from(application.getId(), "base64").toString(); | ||
expect(base64DecodedId).toBe("[LinuxApplication][/Path/To/MyApp.desktop]"); | ||
}); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
src/main/Extensions/ApplicationSearch/Windows/WindowsApplication.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,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", <Image>{}); | ||
const defaultAction = application.toSearchResultItem().defaultAction; | ||
expect(defaultAction.handlerId).toBe("OpenFilePath"); | ||
}); | ||
|
||
it("should have OpenFilePathAsAdministrator as an additional action", () => { | ||
const application = new WindowsApplication("name", "filePath", <Image>{}); | ||
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", <Image>{}); | ||
const base64DecodedId = Buffer.from(application.getId(), "base64").toString(); | ||
expect(base64DecodedId).toBe("[WindowsApplication][filePath]"); | ||
}); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/main/Extensions/ApplicationSearch/macOS/MacOsApplication.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,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", <Image>{}); | ||
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", <Image>{}); | ||
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", <Image>{}); | ||
const base64DecodedId = Buffer.from(application.getId(), "base64").toString(); | ||
expect(base64DecodedId).toBe("[MacOsApplication][/Path/To/MyApp.app]"); | ||
}); | ||
}); | ||
}); |