add unit test

This commit is contained in:
Mutasem Aldmour 2024-11-13 20:07:06 +01:00
parent edcb74ad5c
commit 5f491fbde3
No known key found for this signature in database
GPG key ID: 3DFA8122BB7FD6B8
2 changed files with 32 additions and 1 deletions

View file

@ -20,7 +20,8 @@
"lint": "eslint . --quiet",
"lintfix": "eslint . --fix",
"watch": "tsc-watch -p tsconfig.build.json --onCompilationComplete \"tsc-alias -p tsconfig.build.json\"",
"test": "jest"
"test": "jest",
"test:dev": "jest --watch"
},
"files": [
"dist",

View file

@ -17,6 +17,7 @@ import type {
IContextObject,
ICredentialDataDecryptedObject,
ISourceData,
ITaskMetadata,
} from 'n8n-workflow';
import { ApplicationError, NodeHelpers } from 'n8n-workflow';
@ -298,4 +299,33 @@ describe('ExecuteSingleContext', () => {
});
});
});
describe('setMetadata', () => {
it('sets metadata on execution data', () => {
const context = new ExecuteSingleContext(
workflow,
node,
additionalData,
mode,
runExecutionData,
runIndex,
connectionInputData,
inputData,
itemIndex,
executeData,
abortSignal,
);
const metadata: ITaskMetadata = {
subExecution: {
workflowId: '123',
executionId: 'xyz',
},
};
expect(context.getExecuteData().metadata?.subExecution).toEqual(undefined);
context.setMetadata(metadata);
expect(context.getExecuteData().metadata?.subExecution).toEqual(metadata.subExecution);
});
});
});