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-01 15:08:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 15:08:00 +0300
commit1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (patch)
treeddb78a8a0d1350dc767f049a21e0f7d37edaa82c /spec/frontend/api_spec.js
parentb11f7057d067885619ee3e513751f180b2e8ad85 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/api_spec.js')
-rw-r--r--spec/frontend/api_spec.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/frontend/api_spec.js b/spec/frontend/api_spec.js
index c0126b2330d..179aa3a49d7 100644
--- a/spec/frontend/api_spec.js
+++ b/spec/frontend/api_spec.js
@@ -570,4 +570,65 @@ describe('Api', () => {
.catch(done.fail);
});
});
+
+ describe('createReleaseLink', () => {
+ const dummyProjectPath = 'gitlab-org/gitlab';
+ const dummyReleaseTag = 'v1.3';
+ const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${encodeURIComponent(
+ dummyProjectPath,
+ )}/releases/${dummyReleaseTag}/assets/links`;
+ const expectedLink = {
+ url: 'https://example.com',
+ name: 'An example link',
+ };
+
+ describe('when the Release is successfully created', () => {
+ it('resolves the Promise', () => {
+ mock.onPost(expectedUrl, expectedLink).replyOnce(201);
+
+ return Api.createReleaseLink(dummyProjectPath, dummyReleaseTag, expectedLink).then(() => {
+ expect(mock.history.post).toHaveLength(1);
+ });
+ });
+ });
+
+ describe('when an error occurs while creating the Release', () => {
+ it('rejects the Promise', () => {
+ mock.onPost(expectedUrl, expectedLink).replyOnce(500);
+
+ return Api.createReleaseLink(dummyProjectPath, dummyReleaseTag, expectedLink).catch(() => {
+ expect(mock.history.post).toHaveLength(1);
+ });
+ });
+ });
+ });
+
+ describe('deleteReleaseLink', () => {
+ const dummyProjectPath = 'gitlab-org/gitlab';
+ const dummyReleaseTag = 'v1.3';
+ const dummyLinkId = '4';
+ const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${encodeURIComponent(
+ dummyProjectPath,
+ )}/releases/${dummyReleaseTag}/assets/links/${dummyLinkId}`;
+
+ describe('when the Release is successfully deleted', () => {
+ it('resolves the Promise', () => {
+ mock.onDelete(expectedUrl).replyOnce(200);
+
+ return Api.deleteReleaseLink(dummyProjectPath, dummyReleaseTag, dummyLinkId).then(() => {
+ expect(mock.history.delete).toHaveLength(1);
+ });
+ });
+ });
+
+ describe('when an error occurs while deleting the Release', () => {
+ it('rejects the Promise', () => {
+ mock.onDelete(expectedUrl).replyOnce(500);
+
+ return Api.deleteReleaseLink(dummyProjectPath, dummyReleaseTag, dummyLinkId).catch(() => {
+ expect(mock.history.delete).toHaveLength(1);
+ });
+ });
+ });
+ });
});