mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { type DeepMockProxy, mockDeep } from 'jest-mock-extended';
|
|
import type { IExecuteFunctions } from 'n8n-workflow';
|
|
|
|
import { jiraSoftwareCloudApiRequestAllItems } from '../GenericFunctions';
|
|
|
|
describe('Jira -> GenericFunctions', () => {
|
|
describe('jiraSoftwareCloudApiRequestAllItems', () => {
|
|
let mockExecuteFunctions: DeepMockProxy<IExecuteFunctions>;
|
|
|
|
beforeEach(() => {
|
|
mockExecuteFunctions = mockDeep<IExecuteFunctions>();
|
|
mockExecuteFunctions.getNodeParameter.mockReturnValue('server');
|
|
mockExecuteFunctions.getCredentials.mockResolvedValue({ domain: 'jira.domain.com' });
|
|
mockExecuteFunctions.helpers.requestWithAuthentication.mockImplementation(
|
|
async function (_, options) {
|
|
if (!options.qs?.startAt) {
|
|
return {
|
|
issues: [{ id: 1000 }, { id: 1001 }],
|
|
startAt: 0,
|
|
maxResults: 2,
|
|
total: 3,
|
|
};
|
|
}
|
|
|
|
return {
|
|
issues: [{ id: 1002 }],
|
|
startAt: 2,
|
|
maxResults: 2,
|
|
total: 3,
|
|
};
|
|
},
|
|
);
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('should get all items and not pass the body when the method is GET', async () => {
|
|
const result = await jiraSoftwareCloudApiRequestAllItems.call(
|
|
mockExecuteFunctions,
|
|
'issues',
|
|
'/api/2/search',
|
|
'GET',
|
|
);
|
|
|
|
expect(result).toEqual([{ id: 1000 }, { id: 1001 }, { id: 1002 }]);
|
|
expect(mockExecuteFunctions.helpers.requestWithAuthentication).toBeCalledTimes(2);
|
|
expect(mockExecuteFunctions.helpers.requestWithAuthentication).toHaveBeenCalledWith(
|
|
'jiraSoftwareServerApi',
|
|
expect.not.objectContaining({
|
|
body: expect.anything(),
|
|
}),
|
|
);
|
|
});
|
|
});
|
|
});
|