test: add tests for BitbucketCloudClient
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
@@ -107,4 +107,59 @@ describe('BitbucketCloudClient', () => {
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].slug).toEqual('repo1');
|
||||
});
|
||||
|
||||
it('listProjectsByWorkspace', async () => {
|
||||
server.use(
|
||||
rest.get(
|
||||
'https://api.bitbucket.org/2.0/workspaces/ws/projects',
|
||||
(_, res, ctx) => {
|
||||
const response = {
|
||||
values: [
|
||||
{
|
||||
type: 'repository',
|
||||
slug: 'project1',
|
||||
} as Models.Project,
|
||||
],
|
||||
};
|
||||
return res(ctx.json(response));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
const pagination = client.listProjectsByWorkspace('ws');
|
||||
|
||||
const results = [];
|
||||
for await (const result of pagination.iterateResults()) {
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].slug).toEqual('project1');
|
||||
});
|
||||
|
||||
it('listWorkspaces', async () => {
|
||||
server.use(
|
||||
rest.get('https://api.bitbucket.org/2.0/workspaces', (_, res, ctx) => {
|
||||
const response = {
|
||||
values: [
|
||||
{
|
||||
type: 'workspace',
|
||||
slug: 'workspace1',
|
||||
} as Models.Workspace,
|
||||
],
|
||||
};
|
||||
return res(ctx.json(response));
|
||||
}),
|
||||
);
|
||||
|
||||
const pagination = client.listWorkspaces();
|
||||
|
||||
const results = [];
|
||||
for await (const result of pagination.iterateResults()) {
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].slug).toEqual('workspace1');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user