UNPKG

@graphikartistry/cursor-doc-automation

Version:

Cursor IDE extension for autonomous documentation and ticket management

57 lines (48 loc) 1.51 kB
import axios from 'axios'; import { createJiraTicket } from '../jira/jiraClient'; // Mock axios jest.mock('axios'); const mockedAxios = axios as jest.Mocked<typeof axios>; describe('JiraClient', () => { beforeEach(() => { jest.clearAllMocks(); }); describe('createJiraTicket', () => { it('should create a Jira ticket successfully', async () => { const mockResponse = { data: { key: 'TEST-123', id: '12345' } }; mockedAxios.post.mockResolvedValueOnce(mockResponse); const result = await createJiraTicket( 'Test Summary', 'Test Description', 'TEST' ); expect(result).toBe('TEST-123'); expect(mockedAxios.post).toHaveBeenCalledWith( expect.stringContaining('/rest/api/3/issue'), expect.objectContaining({ fields: expect.objectContaining({ project: { key: 'TEST' }, summary: 'Test Summary', description: 'Test Description' }) }) ); }); it('should handle API errors', async () => { mockedAxios.post.mockRejectedValueOnce(new Error('API Error')); await expect( createJiraTicket('Test Summary', 'Test Description', 'TEST') ).rejects.toThrow('API Error'); }); it('should handle missing project key', async () => { await expect( createJiraTicket('Test Summary', 'Test Description', '') ).rejects.toThrow('Project key is required'); }); }); });