Skip to content

Commit b19445c

Browse files
Copilothotlong
andcommitted
Use typed assertion instead of 'as any'
Define SerializedFilter interface for better type safety when testing the serialize() method. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 8b9b066 commit b19445c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

__tests__/hooks/useQueryBuilder.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
*/
55
import { renderHook, act } from "@testing-library/react-native";
66

7+
/* ---- Types ---- */
8+
interface SerializedFilter {
9+
logic: string;
10+
filters: Array<{
11+
field: string;
12+
operator: string;
13+
value: string;
14+
}>;
15+
}
16+
717
/* ---- Mock query-builder helpers ---- */
818
let mockNextId = 0;
919
jest.mock("~/lib/query-builder", () => ({
@@ -186,7 +196,7 @@ describe("useQueryBuilder", () => {
186196

187197
const serialized = result.current.serialize();
188198
expect(serialized).toBeDefined();
189-
expect((serialized as any).logic).toBe("AND");
199+
expect((serialized as SerializedFilter).logic).toBe("AND");
190200
});
191201

192202
it("manages selected fields and projection", () => {

0 commit comments

Comments
 (0)