issue_spec.js.coffee 2.2 KB
Newer Older
R
Robert Speicher 已提交
1 2 3 4
#= require issue

describe 'Issue', ->
  describe 'task lists', ->
5
    fixture.preload('issues_show.html')
R
Robert Speicher 已提交
6 7

    beforeEach ->
8
      fixture.load('issues_show.html')
R
Robert Speicher 已提交
9 10
      @issue = new Issue()

11
    it 'modifies the Markdown field', ->
R
Robert Speicher 已提交
12
      spyOn(jQuery, 'ajax').and.stub()
13 14 15
      $('input[type=checkbox]').attr('checked', true).trigger('change')
      expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')

R
Robert Speicher 已提交
16
    it 'submits an ajax request on tasklist:changed', ->
R
Robert Speicher 已提交
17
      spyOn(jQuery, 'ajax').and.callFake (req) ->
R
Robert Speicher 已提交
18 19 20 21 22
        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')
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
describe 'reopen/close issue', ->
  fixture.preload('issues_show.html')
  beforeEach ->
    fixture.load('issues_show.html')
    @issue = new Issue()
  it 'closes an issue', ->
    $.ajax = (obj) ->
      expect(obj.type).toBe('PUT')
      expect(obj.url).toBe('http://gitlab/issues/6/close')
      obj.success saved: true
    $btnClose = $('a.btn-close')
    $btnReopen = $('a.btn-reopen')
    expect($btnReopen.hasClass('hidden')).toBe(true)
    expect($btnClose.text()).toBe('Close')
    expect(typeof $btnClose.prop('disabled')).toBe('undefined')
    $btnClose.trigger('click')
    expect($btnClose.hasClass('hidden')).toBe(true)
    expect($btnReopen.hasClass('hidden')).toBe(false)
    expect($btnClose.prop('disabled')).toBe(false)
    expect($('div.issue-box-open').hasClass('hidden')).toBe(true)
    expect($('div.issue-box-closed').hasClass('hidden')).toBe(false)
  it 'reopens an issue', ->
    $.ajax = (obj) ->
      expect(obj.type).toBe('PUT')
      expect(obj.url).toBe('http://gitlab/issues/6/reopen')
      obj.success saved: true
    $btnClose = $('a.btn-close')
    $btnReopen = $('a.btn-reopen')
    expect(typeof $btnReopen.prop('disabled')).toBe('undefined')
    expect($btnReopen.text()).toBe('Reopen')
    $btnReopen.trigger('click')
    expect($btnReopen.hasClass('hidden')).toBe(true)
    expect($btnClose.hasClass('hidden')).toBe(false)
    expect($btnReopen.prop('disabled')).toBe(false)
    expect($('div.issue-box-open').hasClass('hidden')).toBe(false)
    expect($('div.issue-box-closed').hasClass('hidden')).toBe(true)