gitlab-org--gitlab-foss/spec/javascripts/merge_request_spec.js.coffee
Rémy Coutable 8aed815b6e
Avoid a TypeError when initializing MergeRequest JS class with no arg
Without this sane default you would get the following error when you
tried to instantiate a new MergeRequest object with no argument (i.e.
`new MergeRequest();`):

TypeError: undefined is not an object (evaluating 'this.opts.action')

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-15 10:33:36 +02:00

23 lines
768 B
CoffeeScript

#= require merge_request
describe 'MergeRequest', ->
describe 'task lists', ->
fixture.preload('merge_requests_show.html')
beforeEach ->
fixture.load('merge_requests_show.html')
@merge = new MergeRequest()
it 'modifies the Markdown field', ->
spyOn(jQuery, 'ajax').and.stub()
$('input[type=checkbox]').attr('checked', true).trigger('change')
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')
it 'submits an ajax request on tasklist:changed', ->
spyOn(jQuery, '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')