release: WRNexusJS 0.8.0
Quality / quality (ubuntu-latest) (push) Failing after 21s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-02 23:18:51 +05:30
parent 87507edf59
commit 586a6db8ff
625 changed files with 243608 additions and 11210 deletions
+23
View File
@@ -1,6 +1,8 @@
import { afterEach, expect, test } from "bun:test";
import {
MobileUnavailableError,
PushNotifications,
SecureStorage,
invoke,
isNative,
platform,
@@ -59,3 +61,24 @@ test("explains missing plugins", async () => {
root.Capacitor = { isNativePlatform: () => true, Plugins: {} };
expect(invoke("Camera", "getPhoto")).rejects.toBeInstanceOf(MobileUnavailableError);
});
test("normalizes push permission and rejects empty registrations", async () => {
const push = new PushNotifications({
permission: async () => "prompt",
requestPermission: async () => "granted",
register: async () => ({ token: "device-token", platform: "ios" }),
});
expect(await push.register()).toEqual({ token: "device-token", platform: "ios" });
});
test("namespaces and validates secure-storage keys", async () => {
const values = new Map<string, string>();
const storage = new SecureStorage({
get: async (key) => values.get(key) ?? null,
set: async (key, value) => void values.set(key, value),
remove: async (key) => void values.delete(key),
});
await storage.set("session", "encrypted-value");
expect(values.get("wrnexus:session")).toBe("encrypted-value");
expect(() => storage.get("bad key")).toThrow(TypeError);
});