first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/* eslint-disable n8n-nodes-base/node-param-display-name-miscased */
|
||||
import { type ILoadOptionsFunctions } from 'n8n-workflow';
|
||||
|
||||
import { getSheetHeaderRow } from '../../Google/Sheet/v2/methods/loadOptions';
|
||||
import { getSheetHeaderRowWithGeneratedColumnNames } from '../methods/loadOptions';
|
||||
|
||||
jest.mock('../../Google/Sheet/v2/methods/loadOptions', () => ({
|
||||
getSheetHeaderRow: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('getSheetHeaderRowWithGeneratedColumnNames', () => {
|
||||
let mockThis: ILoadOptionsFunctions;
|
||||
|
||||
beforeEach(() => {
|
||||
mockThis = {
|
||||
getNodeParameter: jest.fn(),
|
||||
getCredentials: jest.fn(),
|
||||
} as unknown as ILoadOptionsFunctions;
|
||||
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should return column names as-is if they are not empty', async () => {
|
||||
(getSheetHeaderRow as jest.Mock).mockResolvedValue([
|
||||
{ name: 'Column1', value: 'Column1' },
|
||||
{ name: 'Column2', value: 'Column2' },
|
||||
]);
|
||||
|
||||
const result = await getSheetHeaderRowWithGeneratedColumnNames.call(mockThis);
|
||||
|
||||
expect(getSheetHeaderRow).toHaveBeenCalled();
|
||||
expect(result).toEqual([
|
||||
{ name: 'Column1', value: 'Column1' },
|
||||
{ name: 'Column2', value: 'Column2' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('should generate column names for empty values', async () => {
|
||||
(getSheetHeaderRow as jest.Mock).mockResolvedValue([
|
||||
{ name: '', value: '' },
|
||||
{ name: 'Column2', value: 'Column2' },
|
||||
{ name: '', value: '' },
|
||||
]);
|
||||
|
||||
const result = await getSheetHeaderRowWithGeneratedColumnNames.call(mockThis);
|
||||
|
||||
expect(getSheetHeaderRow).toHaveBeenCalled();
|
||||
expect(result).toEqual([
|
||||
{ name: 'col_1', value: 'col_1' },
|
||||
{ name: 'Column2', value: 'Column2' },
|
||||
{ name: 'col_3', value: 'col_3' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle an empty header row gracefully', async () => {
|
||||
(getSheetHeaderRow as jest.Mock).mockResolvedValue([]);
|
||||
|
||||
const result = await getSheetHeaderRowWithGeneratedColumnNames.call(mockThis);
|
||||
|
||||
expect(getSheetHeaderRow).toHaveBeenCalled();
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user