n8n/packages/nodes-base/nodes/Snowflake/__tests__/insert.test.ts
Jon 4c369e83f2
fix(Snowflake Node): Fix issue with Insert and Update operations not working (#29339)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 15:47:52 +00:00

49 lines
1.4 KiB
TypeScript

import { NodeTestHarness } from '@nodes-testing/node-test-harness';
const mockExecute = jest.fn();
const mockConnect = jest.fn();
const mockDestroy = jest.fn();
const mockConnection = { connect: mockConnect, execute: mockExecute, destroy: mockDestroy };
jest.mock('snowflake-sdk', () => ({
configure: jest.fn(),
createConnection: jest.fn().mockReturnValue(mockConnection),
}));
const snowflakeCredentials = {
authentication: 'password',
account: 'test-account',
database: 'TEST_DB',
schema: 'PUBLIC',
warehouse: 'WH',
role: 'SYSADMIN',
clientSessionKeepAlive: false,
username: 'user',
password: 'pass',
};
afterEach(() => jest.clearAllMocks());
describe('Test Snowflake, insert - parameter binding', () => {
mockConnect.mockImplementation((callback: (err: null) => void) => callback(null));
mockDestroy.mockImplementation((callback: (err: null) => void) => callback(null));
mockExecute.mockImplementation(
({ complete }: { complete: (err: null, stmt: undefined, rows: unknown[]) => void }) =>
complete(null, undefined, []),
);
new NodeTestHarness().setupTests({
workflowFiles: ['insert.workflow.json'],
credentials: { snowflake: snowflakeCredentials },
customAssertions() {
expect(mockExecute).toHaveBeenCalledTimes(1);
expect(mockExecute).toHaveBeenCalledWith(
expect.objectContaining({
sqlText: 'INSERT INTO "ORDERS" ("NAME","STATUS") VALUES (?,?)',
binds: [['Alice', 'active']],
}),
);
},
});
});