Skip to content

Commit b462e02

Browse files
author
Emil Kais
committed
Fix test so it verifies output.
1 parent 14627a4 commit b462e02

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

nodes/Markitdown/Markitdown.node.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ export class Markitdown implements INodeType {
6363
await execPromise(command);
6464

6565
const outputContent = await fsPromise.readFile(outputTmpFile.path, 'utf-8');
66-
6766
const newItem: INodeExecutionData = {
6867
json: {
6968
data: outputContent
7069
},
7170
binary: { },
7271
};
73-
7472
returnData.push(newItem);
7573

7674
// Clean up temporary files

nodes/Markitdown/test/Markitdown.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,22 @@ import * as path from 'path';
55

66
describe('Markitdown Node', () => {
77
let nodeInstance = new Markitdown()
8-
98
const sampleFilePath = path.join(__dirname, 'test.docx');
109
let sampleFileBuffer: Buffer;
10+
1111
beforeAll(async () => {
12-
// Create a real sample file for testing
13-
sampleFileBuffer = await fsPromise.readFile(sampleFilePath);
12+
sampleFileBuffer = await fsPromise.readFile(sampleFilePath);
1413
})
14+
1515
afterAll(async () => {
16-
// Clean up the sample file
1716
try {
1817
jest.restoreAllMocks(); // Reset mocks after each test
19-
await fsPromise.unlink(sampleFilePath);
2018
} catch (error) {
2119
// Ignore if already deleted
2220
}
2321
});
2422

2523
it('should convert a document to markdown', async () => {
26-
// jest.spyOn(fsPromise, 'readFile').mockResolvedValue(``)
27-
// jest.spyOn(fsPromise, 'writeFile').mockResolvedValue()
2824
// Create a mock execution context with real binary data
2925
const mockExecuteFunctions: IExecuteFunctions = {
3026
getInputData: () => [{
@@ -62,12 +58,9 @@ describe('Markitdown Node', () => {
6258
// Verify the results
6359
expect(result).toHaveLength(1);
6460
expect(result[0]).toHaveLength(1);
65-
const readSample = await fsPromise.readFile(path.join(__dirname, 'test.md'))
66-
expect(result[0][0].json.data).toBe(readSample.toString());
61+
const readSample = await fsPromise.readFile(path.join(__dirname, 'test.md'), 'utf-8')
62+
expect(result[0][0].json.data).toBe(readSample.trimEnd());
6763

68-
// Verify the command execution
69-
expect(nodeInstance.execute).toHaveBeenCalledTimes(1);
70-
// expect(nodeInstance.execute.calls[0][0]).toMatch(/markitdown ".*n8n-markitdown-input-test-sample.docx" -o ".*n8n-markitdown-output-.md"/);
7164
}, 30000)
7265

7366
});

0 commit comments

Comments
 (0)