Commit d2256c18 authored by Robert Speicher's avatar Robert Speicher

Stub ajax in JS specs

parent c9788bd9
...@@ -9,11 +9,12 @@ describe 'Issue', -> ...@@ -9,11 +9,12 @@ describe 'Issue', ->
@issue = new Issue() @issue = new Issue()
it 'modifies the Markdown field', -> it 'modifies the Markdown field', ->
spyOn(jQuery, 'ajax').and.stub()
$('input[type=checkbox]').attr('checked', true).trigger('change') $('input[type=checkbox]').attr('checked', true).trigger('change')
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item') expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')
it 'submits an ajax request on tasklist:changed', -> it 'submits an ajax request on tasklist:changed', ->
spyOn($, 'ajax').and.callFake (req) -> spyOn(jQuery, 'ajax').and.callFake (req) ->
expect(req.type).toBe('PATCH') expect(req.type).toBe('PATCH')
expect(req.url).toBe('/foo') expect(req.url).toBe('/foo')
expect(req.data.issue.description).not.toBe(null) expect(req.data.issue.description).not.toBe(null)
......
...@@ -11,11 +11,13 @@ describe 'MergeRequest', -> ...@@ -11,11 +11,13 @@ describe 'MergeRequest', ->
@merge = new MergeRequest({}) @merge = new MergeRequest({})
it 'modifies the Markdown field', -> it 'modifies the Markdown field', ->
spyOn(jQuery, 'ajax').and.stub()
$('input[type=checkbox]').attr('checked', true).trigger('change') $('input[type=checkbox]').attr('checked', true).trigger('change')
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item') expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')
it 'submits an ajax request on tasklist:changed', -> it 'submits an ajax request on tasklist:changed', ->
spyOn($, 'ajax').and.callFake (req) -> spyOn(jQuery, 'ajax').and.callFake (req) ->
expect(req.type).toBe('PATCH') expect(req.type).toBe('PATCH')
expect(req.url).toBe('/foo') expect(req.url).toBe('/foo')
expect(req.data.merge_request.description).not.toBe(null) expect(req.data.merge_request.description).not.toBe(null)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment