mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
fix(Gmail Trigger Node): Don't return date instances, but date strings instead (#10582)
This commit is contained in:
parent
3b43ff69a7
commit
9e1dac0465
|
@ -202,6 +202,11 @@ export async function parseRawEmail(
|
|||
headers,
|
||||
headerLines: undefined,
|
||||
attachments: undefined,
|
||||
// Having data in IDataObjects that is not representable in JSON leads to
|
||||
// inconsistencies between test executions and production executions.
|
||||
// During a manual execution this would be stringified and during a
|
||||
// production execution the next node would receive a date instance.
|
||||
date: responseData.date ? responseData.date.toISOString() : responseData.date,
|
||||
}) as IDataObject;
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import type { INode } from 'n8n-workflow';
|
||||
import type { IExecuteFunctions, INode } from 'n8n-workflow';
|
||||
import { DateTime } from 'luxon';
|
||||
import { prepareTimestamp } from '../../GenericFunctions';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { parseRawEmail, prepareTimestamp } from '../../GenericFunctions';
|
||||
|
||||
const node: INode = {
|
||||
id: '1',
|
||||
|
@ -108,3 +109,21 @@ describe('Google Gmail v2, prepareTimestamp', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseRawEmail', () => {
|
||||
it('should return a date string', async () => {
|
||||
// ARRANGE
|
||||
const executionFunctions = mock<IExecuteFunctions>();
|
||||
const rawEmail = 'Date: Wed, 28 Aug 2024 00:36:37 -0700'.replace(/\n/g, '\r\n');
|
||||
|
||||
// ACT
|
||||
const { json } = await parseRawEmail.call(
|
||||
executionFunctions,
|
||||
{ raw: Buffer.from(rawEmail, 'utf8').toString('base64') },
|
||||
'attachment_',
|
||||
);
|
||||
|
||||
// ASSERT
|
||||
expect(typeof json.date).toBe('string');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue