diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 15:10:04 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 15:10:04 +0000 |
commit | f3b1e07903a7f509b11ad7cf188fac46d98f77f6 (patch) | |
tree | a6fa5e65d83d94334387952f1f526ed438604408 /spec/frontend/api_spec.js | |
parent | ba174c982f40d71a87fd511b091753807174f7e7 (diff) | |
download | gitlab-ce-f3b1e07903a7f509b11ad7cf188fac46d98f77f6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/api_spec.js')
-rw-r--r-- | spec/frontend/api_spec.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/frontend/api_spec.js b/spec/frontend/api_spec.js index 179aa3a49d7..fdefa16ac19 100644 --- a/spec/frontend/api_spec.js +++ b/spec/frontend/api_spec.js @@ -631,4 +631,32 @@ describe('Api', () => { }); }); }); + + describe('getRawFile', () => { + const dummyProjectPath = 'gitlab-org/gitlab'; + const dummyFilePath = 'doc/CONTRIBUTING.md'; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${encodeURIComponent( + dummyProjectPath, + )}/repository/files/${encodeURIComponent(dummyFilePath)}/raw`; + + describe('when the raw file is successfully fetched', () => { + it('resolves the Promise', () => { + mock.onGet(expectedUrl).replyOnce(200); + + return Api.getRawFile(dummyProjectPath, dummyFilePath).then(() => { + expect(mock.history.get).toHaveLength(1); + }); + }); + }); + + describe('when an error occurs while getting a raw file', () => { + it('rejects the Promise', () => { + mock.onDelete(expectedUrl).replyOnce(500); + + return Api.getRawFile(dummyProjectPath, dummyFilePath).catch(() => { + expect(mock.history.get).toHaveLength(1); + }); + }); + }); + }); }); |