Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 18:10:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 18:10:04 +0300
commitf3b1e07903a7f509b11ad7cf188fac46d98f77f6 (patch)
treea6fa5e65d83d94334387952f1f526ed438604408 /spec/frontend/api_spec.js
parentba174c982f40d71a87fd511b091753807174f7e7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/api_spec.js')
-rw-r--r--spec/frontend/api_spec.js28
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);
+ });
+ });
+ });
+ });
});