Files
htmlui/tests/testutils/api-mocks.js
2025-06-07 08:03:18 -07:00

35 lines
924 B
JavaScript

import axios from "axios";
import MockAdapter from "axios-mock-adapter";
export function setupAPIMock() {
let axiosMock = new MockAdapter(axios);
axiosMock.reset();
axiosMock.onGet("/api/v1/repo/algorithms").reply(200, {
defaultEncryption: "e-bar",
encryption: [{ id: "e-foo" }, { id: "e-bar" }, { id: "e-baz" }],
defaultEcc: "ecc-bar",
ecc: [{ id: "ecc-foo" }, { id: "ecc-bar" }, { id: "ecc-baz" }],
defaultSplitter: "s-bar",
splitter: [{ id: "s-foo" }, { id: "s-bar" }, { id: "s-baz" }],
defaultHash: "h-bar",
hash: [{ id: "h-foo" }, { id: "h-bar" }, { id: "h-baz" }],
compression: [{ id: "c-foo" }, { id: "c-bar" }, { id: "c-baz", deprecated: true }],
});
axiosMock.onGet("/api/v1/current-user").reply(200, {
username: "someuser",
hostname: "somehost",
});
axiosMock.onGet("/api/v1/cli").reply(200, {
executable: "kopia",
});
return axiosMock;
}