BigW Consortium Gitlab

merge_request_spec.js 1.19 KB
Newer Older
1
/* eslint-disable space-before-function-paren, no-return-assign */
2
/* global MergeRequest */
Fatih Acet committed
3

4
import '~/merge_request';
Fatih Acet committed
5 6 7 8

(function() {
  describe('MergeRequest', function() {
    return describe('task lists', function() {
Simon Knox committed
9
      preloadFixtures('merge_requests/merge_request_with_task_list.html.raw');
Fatih Acet committed
10
      beforeEach(function() {
Simon Knox committed
11
        loadFixtures('merge_requests/merge_request_with_task_list.html.raw');
Fatih Acet committed
12 13 14 15 16 17 18 19 20 21
        return this.merge = new MergeRequest();
      });
      it('modifies the Markdown field', function() {
        spyOn(jQuery, 'ajax').and.stub();
        $('input[type=checkbox]').attr('checked', true).trigger('change');
        return expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
      });
      return it('submits an ajax request on tasklist:changed', function() {
        spyOn(jQuery, 'ajax').and.callFake(function(req) {
          expect(req.type).toBe('PATCH');
Simon Knox committed
22
          expect(req.url).toBe(`${gl.TEST_HOST}/frontend-fixtures/merge-requests-project/merge_requests/1.json`);
Fatih Acet committed
23 24 25 26 27 28
          return expect(req.data.merge_request.description).not.toBe(null);
        });
        return $('.js-task-list-field').trigger('tasklist:changed');
      });
    });
  });
29
}).call(window);