feat(Google Sheets Node): Option how to combine filters when reading rows (#8652)

This commit is contained in:
Michael Kret
2024-02-21 09:59:59 +02:00
committed by GitHub
parent ad82f0c0c8
commit a5e522e536
9 changed files with 236 additions and 21 deletions

View File

@@ -282,3 +282,121 @@ describe('Test Google Sheets, autoMapInputData', () => {
]);
});
});
describe('Test Google Sheets, lookupValues', () => {
const inputData = [
['row_number', 'id', 'num', 'text'],
[2, 1, '111', 'bar'],
[3, 3, 1, 'bar'],
[4, 4, 1, 'baz'],
[5, 5, 1, 'baz'],
[6, 6, 66, 'foo'],
[7, 7, 77, 'foo'],
] as string[][];
it('should return rows by combining filters by OR', async () => {
const fakeExecuteFunction = {
getNode() {
return {};
},
} as unknown as IExecuteFunctions;
const googleSheet = new GoogleSheet('spreadsheetId', fakeExecuteFunction);
const result = await googleSheet.lookupValues(
inputData,
0,
1,
[
{
lookupColumn: 'num',
lookupValue: '1',
},
{
lookupColumn: 'text',
lookupValue: 'foo',
},
],
true,
'OR',
);
expect(result).toBeDefined();
expect(result).toEqual([
{
row_number: 3,
id: 3,
num: 1,
text: 'bar',
},
{
row_number: 4,
id: 4,
num: 1,
text: 'baz',
},
{
row_number: 5,
id: 5,
num: 1,
text: 'baz',
},
{
row_number: 6,
id: 6,
num: 66,
text: 'foo',
},
{
row_number: 7,
id: 7,
num: 77,
text: 'foo',
},
]);
});
it('should return rows by combining filters by AND', async () => {
const fakeExecuteFunction = {
getNode() {
return {};
},
} as unknown as IExecuteFunctions;
const googleSheet = new GoogleSheet('spreadsheetId', fakeExecuteFunction);
const result = await googleSheet.lookupValues(
inputData,
0,
1,
[
{
lookupColumn: 'num',
lookupValue: '1',
},
{
lookupColumn: 'text',
lookupValue: 'baz',
},
],
true,
'AND',
);
expect(result).toBeDefined();
expect(result).toEqual([
{
row_number: 4,
id: 4,
num: 1,
text: 'baz',
},
{
row_number: 5,
id: 5,
num: 1,
text: 'baz',
},
]);
});
});