mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
06fa6f1fb3
* 🔧 Adjust base ESLint config * 🔧 Adjust `lint` and `lintfix` in `nodes-base` * 🔧 Include `test` and `utils` in `nodes-base` * 📘 Convert JS tests to TS * 👕 Apply lintfixes
39 lines
919 B
TypeScript
39 lines
919 B
TypeScript
import type { INodeTypeData } from 'n8n-workflow';
|
|
|
|
/**
|
|
* Ensure all pending promises settle. The promise's `resolve` is placed in
|
|
* the macrotask queue and so called at the next iteration of the event loop
|
|
* after all promises in the microtask queue have settled first.
|
|
*/
|
|
export const flushPromises = async () => new Promise(setImmediate);
|
|
|
|
export function mockNodeTypesData(
|
|
nodeNames: string[],
|
|
options?: {
|
|
addTrigger?: boolean;
|
|
},
|
|
) {
|
|
return nodeNames.reduce<INodeTypeData>((acc, nodeName) => {
|
|
return (
|
|
(acc[`n8n-nodes-base.${nodeName}`] = {
|
|
sourcePath: '',
|
|
type: {
|
|
description: {
|
|
displayName: nodeName,
|
|
name: nodeName,
|
|
group: [],
|
|
description: '',
|
|
version: 1,
|
|
defaults: {},
|
|
inputs: [],
|
|
outputs: [],
|
|
properties: [],
|
|
},
|
|
trigger: options?.addTrigger ? async () => undefined : undefined,
|
|
},
|
|
}),
|
|
acc
|
|
);
|
|
}, {});
|
|
}
|