From d5cd58725e6c8921bb1dcdbe5734109de1366982 Mon Sep 17 00:00:00 2001 From: Andrew Shirley Date: Thu, 17 Jun 2021 20:01:16 +0100 Subject: [PATCH] Add tests for BuildProject and remove skipped ones Signed-off-by: Andrew Shirley Signed-off-by: blam --- .../src/service/jenkinsApi.test.ts | 47 ++++--------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts index 43902a40a428b..fc2ccb37488de 100644 --- a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts @@ -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 () => { @@ -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); + }); });