fix(Gmail Trigger Node): Don't return date instances, but date strings instead (#10582)

This commit is contained in:
Danny Martini
2024-08-28 15:43:04 +02:00
committed by GitHub
parent 3b43ff69a7
commit 9e1dac0465
2 changed files with 26 additions and 2 deletions

View File

@@ -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');
});
});