|
1 | 1 | import {OpenAPIN8NParser} from "../src/OpenAPIN8NParser"; |
| 2 | +import {readdirSync} from 'fs'; |
| 3 | +import {join} from 'path'; |
| 4 | +import {sleep} from "n8n-workflow"; |
2 | 5 |
|
3 | | -test('petstore.json', async () => { |
4 | | - const doc = require('./examples/petstore.json'); |
5 | | - const parser = new OpenAPIN8NParser(doc); |
6 | | - parser.process() |
7 | | -}) |
| 6 | +// Define the path to your 'examples' directory |
| 7 | +const examplesDir = join(__dirname, 'examples'); |
8 | 8 |
|
| 9 | +// Read all JSON files from the examples directory |
| 10 | +const jsonFiles = readdirSync(examplesDir).filter(file => file.endsWith('.json')); |
9 | 11 |
|
10 | | -test('waha.json', async () => { |
11 | | - const doc = require('./examples/waha.json'); |
12 | | - const parser = new OpenAPIN8NParser(doc); |
13 | | - parser.process() |
14 | | -}) |
15 | | - |
16 | | -test('chatwoot.json', () => { |
17 | | - const doc = require('./examples/chatwoot.json'); |
18 | | - const parser = new OpenAPIN8NParser(doc); |
19 | | - parser.process() |
20 | | -}) |
| 12 | +describe('smoke', () => { |
| 13 | + test.each(jsonFiles)('%s', async (fileName) => { |
| 14 | + const filePath = join(examplesDir, fileName); |
| 15 | + const doc = require(filePath); |
| 16 | + const parser = new OpenAPIN8NParser(doc); |
| 17 | + parser.process(); |
| 18 | + await sleep(50) // wait for logs a bit |
| 19 | + }); |
| 20 | +}); |
0 commit comments