forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMissingDateDialogViewSpec.coffee
More file actions
45 lines (38 loc) · 1.52 KB
/
Copy pathMissingDateDialogViewSpec.coffee
File metadata and controls
45 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
define [
'jquery'
'compiled/views/calendar/MissingDateDialogView'
], ($, MissingDateDialogView) ->
QUnit.module 'MissingDateDialogView',
setup: ->
$('#fixtures').append('<label for="date">Section one</label><input type="text" id="date" name="date" />')
@dialog = new MissingDateDialogView
validationFn: ->
invalidFields = []
$('input[name=date]').each ->
invalidFields.push($(this)) if $(this).val() == ''
if invalidFields.length > 0 then invalidFields else true
success: @spy()
teardown: ->
@dialog.cancel({})
$('input[name=date]').remove()
$('label[for=date]').remove()
$('.ui-dialog').remove()
$("#fixtures").empty()
test 'should display a dialog if the given fields are invalid', ->
ok @dialog.render()
ok $('.ui-dialog:visible').length > 0
test 'it should list the names of the sections w/o dates', ->
@dialog.render()
ok $('.ui-dialog').text().match(/Section one/)
test 'should not display a dialog if the given fields are valid', ->
$('input[name=date]').val('2013-01-01')
equal @dialog.render(), false
equal $('.ui-dialog').length, 0
test 'should close the dialog on secondary button press', ->
@dialog.render()
@dialog.$dialog.find('.btn:not(.btn-primary)').click()
equal $('.ui-dialog').length, 0
test 'should run the success callback on on primary button press', ->
@dialog.render()
@dialog.$dialog.find('.btn-primary').click()
ok @dialog.options.success.calledOnce