mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
Share application adapter and diagnostic helpers
This commit is contained in:
1 parent
4027417bf5
commit
b9dcb0d4c7
26 files changed
+937
-305
No files matched your search
@@ -201,3 +201,27 @@ describe("CLIStorageEventManagerAdapter", () => {
|
||||
processExitSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
describe("CLIStorageEventManagerAdapter type guard", () => {
|
||||
const typeGuard = new CLIStorageEventManagerAdapter("/base").typeGuard;
|
||||
|
||||
it.each([
|
||||
{ label: "null", value: null, expected: false },
|
||||
{ label: "an object without a path", value: { stat: {} }, expected: false },
|
||||
{ label: "an object without a stat", value: { path: "note.md" }, expected: false },
|
||||
{ label: "a file-shaped object", value: { path: "note.md", stat: {} }, expected: true },
|
||||
{ label: "a folder-shaped object", value: { path: "folder", isFolder: true }, expected: false },
|
||||
])("classifies $label as a file", ({ value, expected }) => {
|
||||
expect(typeGuard.isFile(value)).toBe(expected);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ label: "null", value: null, expected: false },
|
||||
{ label: "an object without a path", value: { isFolder: true }, expected: false },
|
||||
{ label: "an object without the folder marker", value: { path: "folder" }, expected: false },
|
||||
{ label: "a folder-shaped object", value: { path: "folder", isFolder: true }, expected: true },
|
||||
{ label: "a file-shaped object", value: { path: "note.md", stat: {} }, expected: false },
|
||||
])("classifies $label as a folder", ({ value, expected }) => {
|
||||
expect(typeGuard.isFolder(value)).toBe(expected);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user