Skip to content

Commit 945dd4c

Browse files
committed
Refactor InsertQueryBuilder tests to consolidate value placeholder tests, ensuring correct handling of values and nulls.
1 parent 90b7355 commit 945dd4c

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

__tests__/insert-builder.test.ts

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { InsertQueryBuilder } from "../src/query-builder/insert";
2-
import { SqlExecutor } from "../src/types/common";
1+
import {InsertQueryBuilder, SqlExecutor} from "../src";
32

43
// Mock SqlExecutor
54
const mockExecutor: SqlExecutor = {
@@ -132,40 +131,33 @@ describe("InsertQueryBuilder", () => {
132131
// lastName: "Doe",
133132
// dateOfBirth: "1990-01-01",
134133
// };
135-
136134
// const result = builder.values(data).build();
137-
138135
// expect(result.sql).toContain(
139136
// '"first_name", "last_name", "date_of_birth"'
140137
// );
141138
// });
142139
// });
143140

144-
// describe("Value Placeholders", () => {
145-
// it("should generate correct placeholders for values", () => {
146-
// const data = {
147-
// firstName: "John",
148-
// lastName: "Doe",
149-
// age: 30,
150-
// };
151-
152-
// const result = builder.values(data).build();
153-
154-
// expect(result.sql).toContain("VALUES ($1, $2, $3)");
155-
// expect(result.values).toEqual(["John", "Doe", 30]);
156-
// });
157-
158-
// it("should handle null values correctly", () => {
159-
// const data = {
160-
// firstName: "John",
161-
// lastName: null,
162-
// age: 30,
163-
// };
164-
165-
// const result = builder.values(data).build();
166-
167-
// expect(result.sql).toContain("VALUES ($1, $2, $3)");
168-
// expect(result.values).toEqual(["John", null, 30]);
169-
// });
170-
// });
141+
describe("Value Placeholders", () => {
142+
it("should generate correct placeholders for values", () => {
143+
const data = {
144+
firstName: "John",
145+
lastName: "Doe",
146+
age: 30,
147+
};
148+
const result = builder.values(data).build();
149+
expect(result.sql).toContain("VALUES ($1, $2, $3)");
150+
expect(result.values).toEqual(["John", "Doe", 30]);
151+
});
152+
it("should handle null values correctly", () => {
153+
const data = {
154+
firstName: "John",
155+
lastName: null,
156+
age: 30,
157+
};
158+
const result = builder.values(data).build();
159+
expect(result.sql).toContain("VALUES ($1, $2, $3)");
160+
expect(result.values).toEqual(["John", null, 30]);
161+
});
162+
});
171163
});

0 commit comments

Comments
 (0)