forked from phenom/healer-man
Release Healer Man 0.1.14
This commit is contained in:
1 parent
67d7a8ebe7
commit
7b41b102fa
147 files changed
+169892
-1342
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import { createElement, Fragment, type ReactNode } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const content = vi.hoisted(() => ({
|
||||
installed: true,
|
||||
update: true,
|
||||
bundled: false,
|
||||
install: vi.fn(async () => undefined),
|
||||
remove: vi.fn(async () => undefined),
|
||||
}));
|
||||
|
||||
vi.mock("@capacitor/core", () => ({
|
||||
Capacitor: { isNativePlatform: () => false },
|
||||
}));
|
||||
|
||||
vi.mock("../content/contentManager", () => ({
|
||||
checkForContentUpdates: vi.fn(async () => null),
|
||||
contentPackHasUpdate: () => content.update,
|
||||
contentPackIsBundled: () => content.bundled,
|
||||
contentPackIsInstalled: () => content.installed,
|
||||
installContentPack: content.install,
|
||||
removeContentPack: content.remove,
|
||||
}));
|
||||
|
||||
vi.mock("../content/useContentManager", () => ({
|
||||
useContentManagerSnapshot: () => ({
|
||||
revision: 1,
|
||||
checking: false,
|
||||
manifest: {
|
||||
version: "content-test",
|
||||
packs: [{
|
||||
id: "characters:test",
|
||||
label: "Test Characters",
|
||||
bytes: 1024,
|
||||
fileCount: 1,
|
||||
bundledOnAndroid: false,
|
||||
dependencies: [],
|
||||
}],
|
||||
},
|
||||
bundledManifest: null,
|
||||
installingPackId: null,
|
||||
downloadedBytes: 0,
|
||||
totalBytes: 0,
|
||||
error: "",
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../components/DualDisplayFrame", () => ({
|
||||
DualDisplayFrame: ({ top }: { readonly top: ReactNode }) => createElement(Fragment, null, top),
|
||||
}));
|
||||
|
||||
vi.mock("./LazyLocalCompanionPanel", () => ({
|
||||
LazyLocalCompanionPanel: () => null,
|
||||
}));
|
||||
|
||||
import { ContentManagerScreen } from "./ContentManagerScreen";
|
||||
|
||||
describe("browser Downloads actions", () => {
|
||||
beforeEach(() => {
|
||||
content.installed = true;
|
||||
content.update = true;
|
||||
content.bundled = false;
|
||||
});
|
||||
|
||||
it("offers an update action when an installed browser pack has changed", () => {
|
||||
const markup = renderToStaticMarkup(createElement(ContentManagerScreen, { onClose: () => undefined }));
|
||||
|
||||
expect(markup).toContain("Update available");
|
||||
expect(markup).toContain(">Update</button>");
|
||||
expect(markup).toContain(">Remove</button>");
|
||||
});
|
||||
|
||||
it("offers download and remove actions for optional browser packs", () => {
|
||||
content.installed = false;
|
||||
content.update = false;
|
||||
let markup = renderToStaticMarkup(createElement(ContentManagerScreen, { onClose: () => undefined }));
|
||||
expect(markup).toContain("Not installed");
|
||||
expect(markup).toContain(">Download</button>");
|
||||
|
||||
content.installed = true;
|
||||
markup = renderToStaticMarkup(createElement(ContentManagerScreen, { onClose: () => undefined }));
|
||||
expect(markup).toContain("Installed — offline ready");
|
||||
expect(markup).toContain(">Remove</button>");
|
||||
});
|
||||
|
||||
it("does not offer removal for bundled browser basics", () => {
|
||||
content.update = false;
|
||||
content.bundled = true;
|
||||
const markup = renderToStaticMarkup(createElement(ContentManagerScreen, { onClose: () => undefined }));
|
||||
|
||||
expect(markup).toContain("Included — always available");
|
||||
expect(markup).not.toContain(">Remove</button>");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user