Skip to content

Commit f0a460a

Browse files
authored
fix: stabilize tests and clean build warnings (#4)
1 parent 1f821f7 commit f0a460a

6 files changed

Lines changed: 47 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"description": "WASM-powered input obfuscation library for preventing client-side scraping",
66
"scripts": {
7-
"build": "pnpm -r --filter \"./packages/*\" --filter \"!./packages/examples\" build",
7+
"build": "pnpm -r --filter @secure-input/wasm --filter @secure-input/core --filter @secure-input/react build",
88
"build:wasm": "pnpm --filter @secure-input/wasm build",
99
"build:core": "pnpm --filter @secure-input/core build",
1010
"build:react": "pnpm --filter @secure-input/react build",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"scripts": {
3535
"build": "vite build && tsc --project tsconfig.build.json",
3636
"dev": "vite build --watch",
37-
"test": "vitest",
37+
"test": "vitest --run",
3838
"clean": "rm -rf dist"
3939
},
4040
"dependencies": {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { describe, expect, it, vi } from "vitest";
2+
3+
const { MockCryptoWorker } = vi.hoisted(() => {
4+
class MockCryptoWorker {
5+
addEventListener(): void {
6+
// no-op for constructor wiring
7+
}
8+
9+
postMessage(): void {
10+
// no-op for smoke test
11+
}
12+
13+
terminate(): void {
14+
// no-op for destroy smoke test
15+
}
16+
}
17+
18+
return { MockCryptoWorker };
19+
});
20+
21+
vi.mock("./worker/crypto.worker?worker&inline", () => ({
22+
default: MockCryptoWorker,
23+
}));
24+
25+
import { SecureInput } from "./SecureInput";
26+
27+
describe("SecureInput", () => {
28+
it("creates and destroys without throwing", () => {
29+
const instance = new SecureInput();
30+
31+
expect(instance).toBeInstanceOf(SecureInput);
32+
expect(() => instance.destroy()).not.toThrow();
33+
});
34+
});

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"scripts": {
3535
"build": "vite build && tsc --project tsconfig.build.json",
3636
"dev": "vite build --watch",
37-
"test": "vitest",
37+
"test": "vitest --run",
3838
"clean": "rm -rf dist"
3939
},
4040
"dependencies": {

packages/react/src/index.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, it } from "vitest";
2+
import * as reactExports from "./index";
3+
4+
describe("react package exports", () => {
5+
it("exposes SecureInput component and useSecureInput hook", () => {
6+
expect(typeof reactExports.SecureInput).toBe("function");
7+
expect(typeof reactExports.useSecureInput).toBe("function");
8+
});
9+
});

packages/wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use chacha20poly1305::{
22
aead::{Aead, KeyInit},
3-
ChaCha20Poly1305, Nonce, Key,
3+
ChaCha20Poly1305, Nonce,
44
};
55
use wasm_bindgen::prelude::*;
66
use base64::{Engine as _, engine::general_purpose};

0 commit comments

Comments
 (0)