@@ -5,26 +5,22 @@ import * as path from 'path';
5
5
6
6
describe ( 'Markitdown Node' , ( ) => {
7
7
let nodeInstance = new Markitdown ( )
8
-
9
8
const sampleFilePath = path . join ( __dirname , 'test.docx' ) ;
10
9
let sampleFileBuffer : Buffer ;
10
+
11
11
beforeAll ( async ( ) => {
12
- // Create a real sample file for testing
13
- sampleFileBuffer = await fsPromise . readFile ( sampleFilePath ) ;
12
+ sampleFileBuffer = await fsPromise . readFile ( sampleFilePath ) ;
14
13
} )
14
+
15
15
afterAll ( async ( ) => {
16
- // Clean up the sample file
17
16
try {
18
17
jest . restoreAllMocks ( ) ; // Reset mocks after each test
19
- await fsPromise . unlink ( sampleFilePath ) ;
20
18
} catch ( error ) {
21
19
// Ignore if already deleted
22
20
}
23
21
} ) ;
24
22
25
23
it ( 'should convert a document to markdown' , async ( ) => {
26
- // jest.spyOn(fsPromise, 'readFile').mockResolvedValue(``)
27
- // jest.spyOn(fsPromise, 'writeFile').mockResolvedValue()
28
24
// Create a mock execution context with real binary data
29
25
const mockExecuteFunctions : IExecuteFunctions = {
30
26
getInputData : ( ) => [ {
@@ -62,12 +58,9 @@ describe('Markitdown Node', () => {
62
58
// Verify the results
63
59
expect ( result ) . toHaveLength ( 1 ) ;
64
60
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 ( ) ) ;
67
63
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"/);
71
64
} , 30000 )
72
65
73
66
} ) ;
0 commit comments