mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-04 08:22:30 +00:00
feat: add WebDAV and PostgREST journal remotes
This commit is contained in:
@@ -4,16 +4,17 @@ const mocks = vi.hoisted(() => ({
|
||||
platform: {
|
||||
isMobile: false,
|
||||
},
|
||||
requestUrl: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/deps.ts", () => ({
|
||||
Platform: mocks.platform,
|
||||
requestUrl: vi.fn(),
|
||||
requestUrl: mocks.requestUrl,
|
||||
}));
|
||||
|
||||
vi.mock("@/deps", () => ({
|
||||
Platform: mocks.platform,
|
||||
requestUrl: vi.fn(),
|
||||
requestUrl: mocks.requestUrl,
|
||||
}));
|
||||
|
||||
vi.mock("@/modules/essentialObsidian/APILib/ObsHttpHandler", () => ({
|
||||
@@ -65,3 +66,24 @@ describe("ObsidianAPIService.showWindowOnRight", () => {
|
||||
expect(workspace.revealLeaf).toHaveBeenCalledWith(rightLeaf);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ObsidianAPIService.nativeFetch", () => {
|
||||
it("converts a binary body supplied with a URL string to an exact ArrayBuffer", async () => {
|
||||
mocks.requestUrl.mockResolvedValue({
|
||||
arrayBuffer: new ArrayBuffer(0),
|
||||
headers: {},
|
||||
status: 200,
|
||||
});
|
||||
const service = createService({});
|
||||
const body = new Uint8Array([0, 1, 2, 255]);
|
||||
|
||||
await service.nativeFetch("https://journal.example/object", {
|
||||
body: body as BodyInit,
|
||||
method: "PUT",
|
||||
});
|
||||
|
||||
const transmittedBody = mocks.requestUrl.mock.calls[0][0].body;
|
||||
expect(transmittedBody).toBeInstanceOf(ArrayBuffer);
|
||||
expect(new Uint8Array(transmittedBody)).toEqual(body);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user