Initial Commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
describe("tree-shake: selective imports work", () => {
|
||||
it("importing only availability does not throw", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const { isWebCryptoAvailable } = await import(
|
||||
"../src/availability/availability.js"
|
||||
);
|
||||
expect(typeof isWebCryptoAvailable).toBe("function");
|
||||
expect(isWebCryptoAvailable()).toBe(true);
|
||||
});
|
||||
|
||||
it("importing only AEAD engine does not throw", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const { webCryptoAeadEngine } = await import(
|
||||
"../src/engines/webcrypto-aead-engine/webcrypto-aead-engine.js"
|
||||
);
|
||||
expect(typeof webCryptoAeadEngine.encrypt).toBe("function");
|
||||
expect(typeof webCryptoAeadEngine.decrypt).toBe("function");
|
||||
});
|
||||
|
||||
it("importing only errors does not throw", { timeout: 30000 }, async () => {
|
||||
const { BrowserCryptoError, BROWSER_CRYPTO_CODES } = await import(
|
||||
"../src/errors/index.js"
|
||||
);
|
||||
expect(BrowserCryptoError).toBeDefined();
|
||||
expect(BROWSER_CRYPTO_CODES["NOT_AVAILABLE"]).toBe(
|
||||
"BROWSER_CRYPTO.NOT_AVAILABLE"
|
||||
);
|
||||
});
|
||||
|
||||
it("barrel index exports all expected symbols", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const mod = await import("../src/index.js");
|
||||
expect(typeof mod.isWebCryptoAvailable).toBe("function");
|
||||
expect(typeof mod.webCryptoAeadEngine).toBe("object");
|
||||
expect(typeof mod.webCryptoSignEngine).toBe("object");
|
||||
expect(typeof mod.webCryptoAgreeEngine).toBe("object");
|
||||
expect(typeof mod.rsa).toBe("object");
|
||||
expect(typeof mod.aesKw).toBe("object");
|
||||
expect(typeof mod.ecdsaP384).toBe("object");
|
||||
expect(typeof mod.ecdhP384).toBe("object");
|
||||
expect(typeof mod.nonExtractableKey).toBe("function");
|
||||
expect(mod.BrowserCryptoError).toBeDefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user