Skip to main content
Glama
feature.spec.unit.ts1.72 kB
import { Readable } from 'stream'; import { listCommits } from './feature'; describe('listCommits', () => { it('should return commits with file patches', async () => { const mockCommits = [ { commitId: '123', comment: 'Initial commit', author: { name: 'Author' }, committer: { name: 'Committer' }, url: 'https://example.com', parents: ['abc'], }, ]; const getCommits = jest.fn().mockResolvedValue(mockCommits); const getChanges = jest.fn().mockResolvedValue({ changes: [ { item: { path: '/file.ts', objectId: 'new', originalObjectId: 'old', }, originalPath: '/file.ts', }, ], }); const getBlobContent = jest .fn() .mockImplementation((_repo: string, objectId: string) => { const content = objectId === 'old' ? 'console.log("old");\n' : 'console.log("new");\n'; return Readable.from([content]); }); const mockConnection: any = { getGitApi: jest.fn().mockResolvedValue({ getCommits, getChanges, getBlobContent, }), }; const result = await listCommits(mockConnection, { projectId: 'p', repositoryId: 'r', branchName: 'main', }); expect(result.commits).toHaveLength(1); expect(result.commits[0].files).toHaveLength(1); expect(result.commits[0].files[0].patch).toContain('-console.log("old");'); expect(result.commits[0].files[0].patch).toContain('+console.log("new");'); expect(getCommits).toHaveBeenCalled(); expect(getChanges).toHaveBeenCalledWith('123', 'r', 'p'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Tiberriver256/mcp-server-azure-devops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server