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,67 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { INode, INodeTypeBaseDescription, ITriggerFunctions } from 'n8n-workflow';
|
||||
|
||||
import { type ICredentialsDataImap } from '@credentials/Imap.credentials';
|
||||
|
||||
import { EmailReadImapV2 } from '../../v2/EmailReadImapV2.node';
|
||||
|
||||
jest.mock('@n8n/imap', () => {
|
||||
const originalModule = jest.requireActual('@n8n/imap');
|
||||
|
||||
return {
|
||||
...originalModule,
|
||||
connect: jest.fn().mockImplementation(() => ({
|
||||
then: jest.fn().mockImplementation(() => ({
|
||||
openBox: jest.fn().mockResolvedValue({}),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test IMap V2', () => {
|
||||
const triggerFunctions = mock<ITriggerFunctions>({
|
||||
helpers: {
|
||||
createDeferredPromise: jest.fn().mockImplementation(() => {
|
||||
let resolve, reject;
|
||||
const promise = new Promise((res, rej) => {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
return { promise, resolve, reject };
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
const credentials: ICredentialsDataImap = {
|
||||
host: 'imap.gmail.com',
|
||||
port: 993,
|
||||
user: 'user',
|
||||
password: 'password',
|
||||
secure: false,
|
||||
allowUnauthorizedCerts: false,
|
||||
};
|
||||
|
||||
triggerFunctions.getCredentials.calledWith('imap').mockResolvedValue(credentials);
|
||||
triggerFunctions.getNode.mockReturnValue(mock<INode>({ typeVersion: 2.1 }));
|
||||
triggerFunctions.logger.debug = jest.fn();
|
||||
triggerFunctions.getNodeParameter.calledWith('options').mockReturnValue({
|
||||
name: 'Mark as Read',
|
||||
value: 'read',
|
||||
});
|
||||
|
||||
const baseDescription: INodeTypeBaseDescription = {
|
||||
displayName: 'EmailReadImapV2',
|
||||
name: 'emailReadImapV2',
|
||||
icon: 'file:removeDuplicates.svg',
|
||||
group: ['transform'],
|
||||
description: 'Delete items with matching field values',
|
||||
};
|
||||
|
||||
afterEach(() => jest.resetAllMocks());
|
||||
|
||||
it('should run return a close function on success', async () => {
|
||||
const result = await new EmailReadImapV2(baseDescription).trigger.call(triggerFunctions);
|
||||
|
||||
expect(result.closeFunction).toBeDefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user