mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
feat(Microsoft SharePoint Node): New node (#13727)
This commit is contained in:
committed by
GitHub
parent
64b3fa3d17
commit
954b66218f
@@ -0,0 +1,54 @@
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IBinaryData, IExecuteSingleFunctions } from 'n8n-workflow';
|
||||
|
||||
import { downloadFilePostReceive } from '../../helpers/utils';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
let executeSingleFunctions: MockProxy<IExecuteSingleFunctions>;
|
||||
|
||||
beforeEach(() => {
|
||||
executeSingleFunctions = mock<IExecuteSingleFunctions>();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should download file post receive', async () => {
|
||||
const mockResponse = {
|
||||
body: '',
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'content-disposition': "attachment; filename*=UTF-8''encoded%20name.pdf",
|
||||
'content-type': 'application/pdf',
|
||||
},
|
||||
};
|
||||
const mockPrepareBinaryData = jest.fn().mockReturnValueOnce({
|
||||
data: '',
|
||||
mimeType: 'application/pdf',
|
||||
fileName: 'encoded name.pdf',
|
||||
} as IBinaryData);
|
||||
executeSingleFunctions.helpers.prepareBinaryData = mockPrepareBinaryData;
|
||||
|
||||
const result = await downloadFilePostReceive.call(executeSingleFunctions, [], mockResponse);
|
||||
|
||||
expect(mockPrepareBinaryData).toHaveBeenCalledWith(
|
||||
mockResponse.body,
|
||||
'encoded name.pdf',
|
||||
'application/pdf',
|
||||
);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
json: {},
|
||||
binary: {
|
||||
data: {
|
||||
data: '',
|
||||
mimeType: 'application/pdf',
|
||||
fileName: 'encoded name.pdf',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user