Files
n8n-enterprise-unlocked/packages/nodes-base/nodes/Totp/test/Totp.node.test.ts
कारतोफ्फेलस्क्रिप्ट™ 979f9e6327 refactor: Overhaul nodes-testing setup - Part 3 (no-changelog) (#14967)
2025-04-29 17:42:21 +02:00

41 lines
912 B
TypeScript

import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import type { WorkflowTestData } from 'n8n-workflow';
jest.mock('otpauth', () => {
return {
TOTP: jest.fn().mockImplementation(() => {
return {
generate: jest.fn().mockReturnValue('123456'),
};
}),
};
});
describe('Execute TOTP node', () => {
const testHarness = new NodeTestHarness();
const tests: WorkflowTestData[] = [
{
description: 'Generate TOTP Token',
input: {
workflowData: testHarness.readWorkflowJSON('Totp.workflow.test.json'),
},
output: {
nodeData: {
// ignore json.secondsRemaining to prevent flakiness
TOTP: [[{ json: expect.objectContaining({ token: '123456' }) }]],
},
},
credentials: {
totpApi: {
label: 'GitHub:john-doe',
secret: 'BVDRSBXQB2ZEL5HE',
},
},
},
];
for (const testData of tests) {
testHarness.setupTest(testData);
}
});