mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.13.1) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (25.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
Co-authored-by: Jon <jonathan.bennetts@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.4 KiB
TypeScript
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']],
|
|
}),
|
|
);
|
|
},
|
|
});
|
|
});
|