add a test for subfolder as well as filename
Signed-off-by: David Roberts <David.Roberts@orbis.com>
This commit is contained in:
@@ -482,7 +482,7 @@ describe('createRouter', () => {
|
||||
});
|
||||
|
||||
describe('GET /readme/:projectName/:repoName', () => {
|
||||
it('fetches default readme file', async () => {
|
||||
it('fetches default default readme file', async () => {
|
||||
const content = getReadmeMock();
|
||||
const url = `https://host.com/myOrg/myProject/_git/myRepo?path=README.md`;
|
||||
|
||||
@@ -507,7 +507,7 @@ describe('createRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /readme/:projectName/:repoName with readme path', () => {
|
||||
describe('GET /readme/:projectName/:repoName with readme filename', () => {
|
||||
it('fetches specified readme file', async () => {
|
||||
const content = getReadmeMock();
|
||||
const url = `https://host.com/myOrg/myProject/_git/myRepo?path=README_NOT_DEFAULT.md`;
|
||||
@@ -534,6 +534,34 @@ describe('createRouter', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /readme/:projectName/:repoName with readme path', () => {
|
||||
it('fetches specified readme file from subfolder', async () => {
|
||||
const content = getReadmeMock();
|
||||
const url = `https://host.com/myOrg/myProject/_git/myRepo?path=/my-path/README.md`;
|
||||
|
||||
azureDevOpsApi.getReadme.mockResolvedValueOnce({
|
||||
content,
|
||||
url,
|
||||
});
|
||||
|
||||
const response = await request(app).get(
|
||||
'/readme/myProject/myRepo?path=/my-path/README.md',
|
||||
);
|
||||
expect(azureDevOpsApi.getReadme).toHaveBeenCalledWith(
|
||||
'host.com',
|
||||
'myOrg',
|
||||
'myProject',
|
||||
'myRepo',
|
||||
'/my-path/README.md',
|
||||
);
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.body).toEqual({
|
||||
content,
|
||||
url,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getReadmeMock() {
|
||||
|
||||
Reference in New Issue
Block a user