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:
authorBenedikt Huss <benedikt.huss@gmail.com>2016-05-04 10:34:25 +0300
committerBenedikt Huss <benedikt.huss@gmail.com>2016-05-05 01:07:56 +0300
commit655b2640ae9cbe2737369401969e99caeddf192d (patch)
treead1df021f590dd7b0770ef4cd1980bf13086ff5b /spec/javascripts
parent915a4193b433575a63fd4f5048b341d417b06426 (diff)
Merge request widget displays TeamCity build state and code coverage correctly again
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/merge_request_widget_spec.js.coffee35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/javascripts/merge_request_widget_spec.js.coffee b/spec/javascripts/merge_request_widget_spec.js.coffee
new file mode 100644
index 00000000000..e1fb610654e
--- /dev/null
+++ b/spec/javascripts/merge_request_widget_spec.js.coffee
@@ -0,0 +1,35 @@
+#= require merge_request_widget
+
+describe 'MergeRequestWidget', ->
+
+ beforeEach ->
+ window.notifyPermissions = () ->
+ @opts = {ci_status_url:"http://sampledomain.local/ci/getstatus",ci_status:""}
+ @class = new MergeRequestWidget(@opts)
+ @ciStatusData = {"title":"Sample MR title","sha":"12a34bc5","status":"success","coverage":98}
+
+ describe 'getCIStatus', ->
+ beforeEach ->
+ spyOn(jQuery, 'getJSON').and.callFake (req, cb) =>
+ cb(@ciStatusData)
+
+ it 'should call showCIStatus even if a notification should not be displayed', ->
+ spy = spyOn(@class, 'showCIStatus').and.stub()
+ @class.getCIStatus(false)
+ expect(spy).toHaveBeenCalledWith(@ciStatusData.status)
+
+ it 'should call showCIStatus when a notification should be displayed', ->
+ spy = spyOn(@class, 'showCIStatus').and.stub()
+ @class.getCIStatus(true)
+ expect(spy).toHaveBeenCalledWith(@ciStatusData.status)
+
+ it 'should call showCICoverage when the coverage rate is set', ->
+ spy = spyOn(@class, 'showCICoverage').and.stub()
+ @class.getCIStatus(true)
+ expect(spy).toHaveBeenCalledWith(@ciStatusData.coverage)
+
+ it 'should not call showCICoverage when the coverage rate is not set', ->
+ @ciStatusData.coverage = null
+ spy = spyOn(@class, 'showCICoverage').and.stub()
+ @class.getCIStatus(true)
+ expect(spy).not.toHaveBeenCalled()