queryforge
Version:
A powerful, type-safe SQL query builder for Node.js with support for MySQL, PostgreSQL, and SQLite. Features fluent API, transaction management, and connection pooling.
40 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const QueryForge_1 = require("../QueryForge");
describe('QueryForge', () => {
let queryForge;
beforeEach(() => {
const config = {
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'test',
password: 'test',
database: 'test_db',
};
queryForge = new QueryForge_1.QueryForge(config);
});
test('should build a simple SELECT query', async () => {
const query = queryForge
.table('users')
.select('id', 'name', 'email')
.where('age', '>', 18)
.orderBy('name', 'ASC')
.limit(10)
.getState();
expect(query.table).toBe('users');
expect(query.columns).toEqual(['id', 'name', 'email']);
expect(query.where[0]).toEqual({
column: 'age',
operator: '>',
value: 18,
logic: 'AND',
});
expect(query.orderBy[0]).toEqual({
column: 'name',
direction: 'ASC',
});
expect(query.limit).toBe(10);
});
});
//# sourceMappingURL=QueryForge.test.js.map