test: add tests for branches for handleBitbucketCloudRequest

Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
Benjamin Janssens
2024-06-18 15:09:46 +02:00
parent 426bd26366
commit 5588a64e80
@@ -35,6 +35,11 @@ describe('handleAutocompleteRequest', () => {
.fn()
.mockReturnValue([{ values: [{ slug: 'repository1' }] }]),
}),
listBranchesByRepository: jest.fn().mockReturnValue({
iteratePages: jest
.fn()
.mockReturnValue([{ values: [{ name: 'branch1' }] }]),
}),
};
const fromConfig = jest
@@ -89,6 +94,15 @@ describe('handleAutocompleteRequest', () => {
expect(result).toEqual({ results: [{ title: 'repository1' }] });
});
it('should return branches', async () => {
const result = await handleBitbucketCloudRequest('foo', 'branches', {
workspace: 'workspace1',
repository: 'repository1',
});
expect(result).toEqual(['branch1']);
});
it('should throw an error when passing an invalid resource', async () => {
await expect(
handleAutocompleteRequest({