mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-26 07:57:17 +00:00
* eslint-setup: rules for frontend and server * setup pre-commit:hook * frontend:eslint fixes * frontend eslint errors and warning fixed * eslint:fix for ./server * fix server/test: expectatin string lint/error * pre-commit:updated * removed unwanted install cmd from docker file * recommended settings and extension for vscode * husky prepare script added * updated extension recommendations * added prettier as recommended extension * added pre-commit to package.json * remove .prettierrc file * resolve changes * resolve changes
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import PostgresQueryService from '.';
|
|
|
|
describe('PostgresQueryService', () => {
|
|
let service: PostgresQueryService;
|
|
|
|
beforeAll(async () => {
|
|
const module: TestingModule = await Test.createTestingModule({
|
|
providers: [PostgresQueryService],
|
|
}).compile();
|
|
|
|
service = module.get<PostgresQueryService>(PostgresQueryService);
|
|
});
|
|
|
|
it('should generate the query for bulk update operation', async () => {
|
|
const queryOptions = {
|
|
table: 'customers',
|
|
primary_key_column: 'id',
|
|
records: [
|
|
{
|
|
id: 1,
|
|
name: 'sam',
|
|
email: 'sam@example.com',
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'jon',
|
|
email: 'jon@example.com',
|
|
},
|
|
],
|
|
};
|
|
|
|
const builtQuery = await service.buildBulkUpdateQuery(queryOptions);
|
|
const expectedQuery =
|
|
"UPDATE customers SET name = 'sam', email = 'sam@example.com' WHERE id = 1; UPDATE customers SET name = 'jon', email = 'jon@example.com' WHERE id = 2;";
|
|
|
|
expect(builtQuery).toBe(expectedQuery);
|
|
});
|
|
});
|