forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflashNotificationSpec.coffee
More file actions
29 lines (25 loc) · 1.02 KB
/
Copy pathflashNotificationSpec.coffee
File metadata and controls
29 lines (25 loc) · 1.02 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
define [
'jquery'
'compiled/jquery.rails_flash_notifications'
], ($) ->
fixtures = null
QUnit.module 'FlashNotifications',
setup: ->
fixtures = document.getElementById("fixtures")
flashHtml = "<div id='flash_message_holder'/><div id='flash_screenreader_holder'/>"
fixtures.innerHTML = flashHtml
$.initFlashContainer()
teardown: ->
fixtures.innerHTML = ""
test 'text notification', ->
$.flashMessage('here is a thing')
ok $('#flash_message_holder .ic-flash-success').text().match(/here is a thing/)
test 'html sanitization', ->
$.flashWarning('<script>evil()</script>')
ok $('#flash_message_holder .ic-flash-warning').html().match(/<script>/)
test 'html messages', ->
$.flashError({html: '<div class="blah">test</div>'})
ok $('#flash_message_holder .ic-flash-error div.blah').text().match(/test/)
test 'screenreader message', ->
$.screenReaderFlashMessage('<script>evil()</script>')
ok $('#flash_screenreader_holder span').html().match(/<script>/)