diff options
author | Phil Hughes <me@iamphill.com> | 2017-04-13 20:08:47 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-04-13 20:08:47 +0100 |
commit | 1d99c7755ce337a715847344f4f20df23b29bfc7 (patch) | |
tree | d18b0951f07332939c873e300a4b4079e422ad3c /spec/javascripts/merged_buttons_spec.js | |
parent | a8b7a4b71760932341b3a58542b5702495d65ba9 (diff) | |
parent | 7d7dfee48b3455eec07968e7517f9d843a04da66 (diff) | |
download | gitlab-ce-notebooklab-in-repo.tar.gz |
Merge branch 'master' into notebooklab-in-reponotebooklab-in-repo
Diffstat (limited to 'spec/javascripts/merged_buttons_spec.js')
-rw-r--r-- | spec/javascripts/merged_buttons_spec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/javascripts/merged_buttons_spec.js b/spec/javascripts/merged_buttons_spec.js new file mode 100644 index 00000000000..b5c5e60dd97 --- /dev/null +++ b/spec/javascripts/merged_buttons_spec.js @@ -0,0 +1,44 @@ +/* global MergedButtons */ + +import '~/merged_buttons'; + +describe('MergedButtons', () => { + const fixturesPath = 'merge_requests/merged_merge_request.html.raw'; + preloadFixtures(fixturesPath); + + beforeEach(() => { + loadFixtures(fixturesPath); + this.mergedButtons = new MergedButtons(); + this.$removeBranchWidget = $('.remove_source_branch_widget:not(.failed)'); + this.$removeBranchProgress = $('.remove_source_branch_in_progress'); + this.$removeBranchFailed = $('.remove_source_branch_widget.failed'); + this.$removeBranchButton = $('.remove_source_branch'); + }); + + describe('removeSourceBranch', () => { + it('shows loader', () => { + $('.remove_source_branch').trigger('click'); + expect(this.$removeBranchProgress).toBeVisible(); + expect(this.$removeBranchWidget).not.toBeVisible(); + }); + }); + + describe('removeBranchSuccess', () => { + it('refreshes page when branch removed', () => { + spyOn(gl.utils, 'refreshCurrentPage').and.stub(); + const response = { status: 200 }; + this.$removeBranchButton.trigger('ajax:success', response, 'xhr'); + expect(gl.utils.refreshCurrentPage).toHaveBeenCalled(); + }); + }); + + describe('removeBranchError', () => { + it('shows error message', () => { + const response = { status: 500 }; + this.$removeBranchButton.trigger('ajax:error', response, 'xhr'); + expect(this.$removeBranchFailed).toBeVisible(); + expect(this.$removeBranchProgress).not.toBeVisible(); + expect(this.$removeBranchWidget).not.toBeVisible(); + }); + }); +}); |