UNCLASSIFIED

You need to sign in or sign up before continuing.
Commit 6c9bf84f authored by Baban Faraj's avatar Baban Faraj
Browse files

Update unit test by mocking new Gitlab request for the latest pipeline title

parent 2badedc1
...@@ -252,7 +252,12 @@ describe('ProjectService', () => { ...@@ -252,7 +252,12 @@ describe('ProjectService', () => {
}) })
// latest pipeline response // latest pipeline response
.mockResolvedValueOnce({ .mockResolvedValueOnce({
data: [{ id: 88, sha: '123', status: 'success', web_url: 'url' }], data: [{ id: 88, sha: '123', status: 'success', web_url: 'url'}],
})
.mockResolvedValueOnce({
data:
{ title: 'title' }
}) })
// pipeline jobs response // pipeline jobs response
.mockResolvedValueOnce({ .mockResolvedValueOnce({
...@@ -273,11 +278,12 @@ describe('ProjectService', () => { ...@@ -273,11 +278,12 @@ describe('ProjectService', () => {
name: '123', name: '123',
latestPipeline: 'url', latestPipeline: 'url',
status: 'passed', status: 'passed',
message: 'title',
}, },
}, },
]); ]);
expect(axios.get).toHaveBeenCalledTimes(4); expect(axios.get).toHaveBeenCalledTimes(5);
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${mockBaseUrl}/api/v4/users?search=${mockEmail}`, `${mockBaseUrl}/api/v4/users?search=${mockEmail}`,
mockHeaders mockHeaders
...@@ -308,6 +314,11 @@ describe('ProjectService', () => { ...@@ -308,6 +314,11 @@ describe('ProjectService', () => {
.mockResolvedValueOnce({ .mockResolvedValueOnce({
data: [{ id: 88, sha: '123', status: 'success', web_url: 'url' }], data: [{ id: 88, sha: '123', status: 'success', web_url: 'url' }],
}) })
.mockResolvedValueOnce({
data:
{ title: 'title' }
})
// pipeline jobs response // pipeline jobs response
.mockResolvedValueOnce({ .mockResolvedValueOnce({
data: 'dummy', data: 'dummy',
...@@ -327,11 +338,12 @@ describe('ProjectService', () => { ...@@ -327,11 +338,12 @@ describe('ProjectService', () => {
name: '123', name: '123',
latestPipeline: 'url', latestPipeline: 'url',
status: 'passed', status: 'passed',
message: 'title',
}, },
}, },
]); ]);
expect(axios.get).toHaveBeenCalledTimes(4); expect(axios.get).toHaveBeenCalledTimes(5);
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${mockBaseUrl}/api/v4/users?search=${mockEmail}`, `${mockBaseUrl}/api/v4/users?search=${mockEmail}`,
mockHeaders mockHeaders
...@@ -362,6 +374,11 @@ describe('ProjectService', () => { ...@@ -362,6 +374,11 @@ describe('ProjectService', () => {
.mockResolvedValueOnce({ .mockResolvedValueOnce({
data: [{ id: 88, sha: '123', status: 'failed', web_url: 'url' }], data: [{ id: 88, sha: '123', status: 'failed', web_url: 'url' }],
}) })
.mockResolvedValueOnce({
data:
{ title: 'title' }
})
// pipeline jobs response // pipeline jobs response
.mockResolvedValueOnce({ .mockResolvedValueOnce({
data: [ data: [
...@@ -370,6 +387,7 @@ describe('ProjectService', () => { ...@@ -370,6 +387,7 @@ describe('ProjectService', () => {
], ],
}); });
const response = await ProjectService.getProjectsLatestPipelineAndJobs( const response = await ProjectService.getProjectsLatestPipelineAndJobs(
mockEmail mockEmail
); );
...@@ -394,12 +412,13 @@ describe('ProjectService', () => { ...@@ -394,12 +412,13 @@ describe('ProjectService', () => {
], ],
name: '123', name: '123',
latestPipeline: 'url', latestPipeline: 'url',
message: 'title',
status: 'failed', status: 'failed',
}, },
}, },
]); ]);
expect(axios.get).toHaveBeenCalledTimes(4); expect(axios.get).toHaveBeenCalledTimes(5);
expect(axios.get).toHaveBeenCalledWith( expect(axios.get).toHaveBeenCalledWith(
`${mockBaseUrl}/api/v4/users?search=${mockEmail}`, `${mockBaseUrl}/api/v4/users?search=${mockEmail}`,
mockHeaders mockHeaders
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment