Skip to content

Commit

Permalink
Add tests for BuildProject and remove skipped ones
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Shirley <andrew.shirley@sainsburys.co.uk>
Signed-off-by: blam <ben@blam.sh>
  • Loading branch information
ashirley authored and benjdlambert committed Jul 14, 2021
1 parent 6c7f00e commit d5cd587
Showing 1 changed file with 10 additions and 37 deletions.
47 changes: 10 additions & 37 deletions plugins/jenkins-backend/src/service/jenkinsApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,42 +101,6 @@ describe('JenkinsApi', () => {
status: 'success',
});
});
it.skip('3-layer nesting', async () => {
mockedJenkinsClient.job.get.mockResolvedValueOnce({
jobs: [{ jobs: [project] }],
});

const result = await jenkinsApi.getProjects(jenkinsInfo);

expect(mockedJenkins).toHaveBeenCalledWith({
baseUrl: jenkinsInfo.baseUrl,
headers: jenkinsInfo.headers,
promisify: true,
});
expect(mockedJenkinsClient.job.get).toBeCalledWith({
name: jenkinsInfo.jobName,
tree: expect.anything(),
});
expect(result).toHaveLength(1);
expect(result[0].fullName).toEqual('example-jobName/exampleBuild');
});
it.skip('start at project', async () => {
mockedJenkinsClient.job.get.mockResolvedValueOnce(project);

const result = await jenkinsApi.getProjects(jenkinsInfo);

expect(mockedJenkins).toHaveBeenCalledWith({
baseUrl: jenkinsInfo.baseUrl,
headers: jenkinsInfo.headers,
promisify: true,
});
expect(mockedJenkinsClient.job.get).toBeCalledWith({
name: jenkinsInfo.jobName,
tree: expect.anything(),
});
expect(result).toHaveLength(1);
expect(result[0].fullName).toEqual('example-jobName/exampleBuild');
});
});
describe('filtered by branch', () => {
it('standard github layout', async () => {
Expand Down Expand Up @@ -417,5 +381,14 @@ describe('JenkinsApi', () => {
});
expect(mockedJenkinsClient.build.get).toBeCalledWith(jobName, buildNumber);
});
it('buildProject', () => {});
it('buildProject', async () => {
await jenkinsApi.buildProject(jenkinsInfo, jobName);

expect(mockedJenkins).toHaveBeenCalledWith({
baseUrl: jenkinsInfo.baseUrl,
headers: jenkinsInfo.headers,
promisify: true,
});
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobName);
});
});

0 comments on commit d5cd587

Please sign in to comment.