From ded6e4df61f1b6b367248d15417f039321409cbb Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 7 Feb 2024 13:39:01 +0000 Subject: [PATCH] Update the tests to reflect the new parameter and default Signed-off-by: David Roberts --- .../src/service/router.test.ts | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/azure-devops-backend/src/service/router.test.ts b/plugins/azure-devops-backend/src/service/router.test.ts index 65cb27271e..9e8f968826 100644 --- a/plugins/azure-devops-backend/src/service/router.test.ts +++ b/plugins/azure-devops-backend/src/service/router.test.ts @@ -482,7 +482,7 @@ describe('createRouter', () => { }); describe('GET /readme/:projectName/:repoName', () => { - it('fetches readme file', async () => { + it('fetches default readme file', async () => { const content = getReadmeMock(); const url = `https://host.com/myOrg/myProject/_git/myRepo?path=README.md`; @@ -491,14 +491,41 @@ describe('createRouter', () => { url, }); + const response = await request(app).get('/readme/myProject/myRepo'); + expect(azureDevOpsApi.getReadme).toHaveBeenCalledWith( + 'host.com', + 'myOrg', + 'myProject', + 'myRepo', + 'README.md', + ); + expect(response.status).toEqual(200); + expect(response.body).toEqual({ + content, + url, + }); + }); + }); + + describe('GET /readme/:projectName/:repoName with readme path', () => { + it('fetches specified readme file', async () => { + const content = getReadmeMock(); + const url = `https://host.com/myOrg/myProject/_git/myRepo?path=README_NOT_DEFAULT.md`; + + azureDevOpsApi.getReadme.mockResolvedValueOnce({ + content, + url, + }); + const response = await request(app).get( - '/readme/myProject/myRepo?path=README.md', + '/readme/myProject/myRepo?path=README_NOT_DEFAULT.md', ); expect(azureDevOpsApi.getReadme).toHaveBeenCalledWith( 'host.com', 'myOrg', 'myProject', 'myRepo', + 'README_NOT_DEFAULT.md', ); expect(response.status).toEqual(200); expect(response.body).toEqual({