summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-05-04 23:06:57 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-05-06 13:16:37 -0400
commit51c3393974c0702f56f22122006606d3e03b668d (patch)
treedad3617e6dacc68c531ade28878d8630061a1a7f /spec/javascripts
parentc96c7cbfb15f3fae50b21862fdc5a863929ef0cd (diff)
downloadgitlab-ce-51c3393974c0702f56f22122006606d3e03b668d.tar.gz
Task List feature and JS specs
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/issue_spec.js.coffee36
-rw-r--r--spec/javascripts/merge_request_spec.js.coffee36
-rw-r--r--spec/javascripts/notes_spec.js.coffee30
3 files changed, 102 insertions, 0 deletions
diff --git a/spec/javascripts/issue_spec.js.coffee b/spec/javascripts/issue_spec.js.coffee
new file mode 100644
index 00000000000..13b25862f57
--- /dev/null
+++ b/spec/javascripts/issue_spec.js.coffee
@@ -0,0 +1,36 @@
+#= require jquery
+#= require jasmine-fixture
+#= require issue
+
+describe 'Issue', ->
+ describe 'task lists', ->
+ selectors = {
+ container: '.issue-details .description.js-task-list-container'
+ item: '.wiki ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
+ textarea: '.wiki textarea.js-task-list-field{- [ ] Task List Item}'
+ form: 'form.js-issue-update[action="/foo"]'
+ close: 'a.btn-close'
+ }
+
+ beforeEach ->
+ $container = affix(selectors.container)
+
+ # # These two elements are siblings inside the container
+ $container.find('.js-task-list-container').append(affix(selectors.item))
+ $container.find('.js-task-list-container').append(affix(selectors.textarea))
+
+ # Task lists don't get initialized unless this button exists. Not ideal.
+ $container.append(affix(selectors.close))
+
+ # This form is used to get the `update` URL. Not ideal.
+ $container.append(affix(selectors.form))
+
+ @issue = new Issue()
+
+ it 'submits an ajax request on tasklist:changed', ->
+ spyOn($, 'ajax').and.callFake (req) ->
+ expect(req.type).toBe('PATCH')
+ expect(req.url).toBe('/foo')
+ expect(req.data.issue.description).not.toBe(null)
+
+ $('.js-task-list-field').trigger('tasklist:changed')
diff --git a/spec/javascripts/merge_request_spec.js.coffee b/spec/javascripts/merge_request_spec.js.coffee
new file mode 100644
index 00000000000..3ebc4a4eed5
--- /dev/null
+++ b/spec/javascripts/merge_request_spec.js.coffee
@@ -0,0 +1,36 @@
+#= require jquery
+#= require jasmine-fixture
+#= require merge_request
+
+describe 'MergeRequest', ->
+ describe 'task lists', ->
+ selectors = {
+ container: '.merge-request-details .description.js-task-list-container'
+ item: '.wiki ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
+ textarea: '.wiki textarea.js-task-list-field{- [ ] Task List Item}'
+ form: 'form.js-merge-request-update[action="/foo"]'
+ close: 'a.btn-close'
+ }
+
+ beforeEach ->
+ $container = affix(selectors.container)
+
+ # # These two elements are siblings inside the container
+ $container.find('.js-task-list-container').append(affix(selectors.item))
+ $container.find('.js-task-list-container').append(affix(selectors.textarea))
+
+ # Task lists don't get initialized unless this button exists. Not ideal.
+ $container.append(affix(selectors.close))
+
+ # This form is used to get the `update` URL. Not ideal.
+ $container.append(affix(selectors.form))
+
+ @merge = new MergeRequest({})
+
+ it 'submits an ajax request on tasklist:changed', ->
+ spyOn($, 'ajax').and.callFake (req) ->
+ expect(req.type).toBe('PATCH')
+ expect(req.url).toBe('/foo')
+ expect(req.data.merge_request.description).not.toBe(null)
+
+ $('.js-task-list-field').trigger('tasklist:changed')
diff --git a/spec/javascripts/notes_spec.js.coffee b/spec/javascripts/notes_spec.js.coffee
new file mode 100644
index 00000000000..de2e8e7f6c8
--- /dev/null
+++ b/spec/javascripts/notes_spec.js.coffee
@@ -0,0 +1,30 @@
+#= require jquery
+#= require jasmine-fixture
+#= require notes
+
+window.gon = {}
+window.disableButtonIfEmptyField = -> null
+
+describe 'Notes', ->
+ describe 'task lists', ->
+ selectors = {
+ container: 'li.note .js-task-list-container'
+ item: '.note-text ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
+ textarea: '.note-edit-form form textarea.js-task-list-field{- [ ] Task List Item}'
+ }
+
+ beforeEach ->
+ $container = affix(selectors.container)
+
+ # These two elements are siblings inside the container
+ $container.find('.js-task-list-container').append(affix(selectors.item))
+ $container.find('.js-task-list-container').append(affix(selectors.textarea))
+
+ @notes = new Notes()
+
+ it 'submits the form on tasklist:changed', ->
+ submitted = false
+ $('form').on 'submit', (e) -> submitted = true; e.preventDefault()
+
+ $('.js-task-list-field').trigger('tasklist:changed')
+ expect(submitted).toBe(true)