mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
test(IF Node): Unit tests (no-changelog) (#5404)
* ⚡️move test files * ⚡️IF boolean tests * ⚡️IF string tests * ✅ IF number tests * ✅ IF date-time tests * 🎨 update Test name to make more sense
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import * as Helpers from '../Helpers';
|
||||
import { WorkflowTestData } from '../types';
|
||||
import { executeWorkflow } from '../ExecuteWorkflow';
|
||||
|
||||
describe('Execute If Node', () => {
|
||||
const tests: Array<WorkflowTestData> = [
|
||||
{
|
||||
description: 'should execute IF node true/false boolean',
|
||||
input: {
|
||||
workflowData: Helpers.readJsonFileSync('test/nodes/If/workflow.json'),
|
||||
},
|
||||
output: {
|
||||
nodeData: {
|
||||
'On True': [
|
||||
[
|
||||
{
|
||||
value: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
'On False': [
|
||||
[
|
||||
{
|
||||
value: false,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const nodeTypes = Helpers.setup(tests);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => {
|
||||
// execute workflow
|
||||
const { result } = await executeWorkflow(testData, nodeTypes);
|
||||
|
||||
// check if result node data matches expected test data
|
||||
const resultNodeData = Helpers.getResultNodeData(result, testData);
|
||||
resultNodeData.forEach(({ nodeName, resultData }) =>
|
||||
expect(resultData).toEqual(testData.output.nodeData[nodeName]),
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,115 +0,0 @@
|
||||
{
|
||||
"meta": {
|
||||
"instanceId": "104a4d08d8897b8bdeb38aaca515021075e0bd8544c983c2bb8c86e6a8e6081c"
|
||||
},
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "47003824-c11f-4ae3-80a5-0e1a6d840b21",
|
||||
"name": "On clicking 'execute'",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
720,
|
||||
460
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"boolean": [
|
||||
{
|
||||
"value1": "={{ $json[\"value\"] }}",
|
||||
"value2": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "5420fe7d-a216-44e0-b91f-188ba5b6a340",
|
||||
"name": "IF",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1160,
|
||||
460
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "52d58f32-7faf-4874-afff-e6842bd02430",
|
||||
"name": "On False",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
580
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9be683ac-cd3f-4ba1-8fa4-052102c3d891",
|
||||
"name": "On True",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
340
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return [\n { value: true },\n { value: false }\n];"
|
||||
},
|
||||
"id": "5b3207e7-37e3-43c8-a4da-1ffebb0de134",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
940,
|
||||
460
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"On clicking 'execute'": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"IF": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "On True",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "On False",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "IF",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user