forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiUserContentSpec.coffee
More file actions
26 lines (21 loc) · 1.94 KB
/
Copy pathapiUserContentSpec.coffee
File metadata and controls
26 lines (21 loc) · 1.94 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
define ['compiled/str/apiUserContent'], (apiUserContent) ->
mathml_html = null
QUnit.module "apiUserContent.convert",
setup: ->
mathml_html = "<div><ul>\n" +
"<li><img class=\"equation_image\" data-mathml=\"<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mi>i</mi><mi>n</mi><mi>t</mi><mi>f</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><mo>/</mo><mi>g</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo></math>\"></li>\n" +
"<li><img class=\"equation_image\" data-mathml='<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"inline\"><mo lspace=\"thinmathspace\" rspace=\"thinmathspace\">&Sum;</mo><mn>1</mn><mo>.</mo><mo>.</mo><mi>n</mi></math>'></li>\n" +
"<li><img class=\"nothing_special\"></li>\n"+
"</ul></div>"
teardown: ->
test "moves mathml into a screenreader element", ->
output = apiUserContent.convert(mathml_html)
ok(output.includes("<span class=\"hidden-readable\"><math "))
test "mathml need not be screenreadered if editing content (this would start an update loop)", ->
output = apiUserContent.convert(mathml_html, forEditing: true)
ok(!output.includes("<span class=\"hidden-readable\"><math "))
test "adds media comments for tagged audio content", ->
html = "<div><audio class='instructure_inline_media_comment' data-media_comment_id='42' data-media_comment_type='audio'><span>24</span></audio></div>"
output = apiUserContent.convert(html)
expected = "<div><a id=\"media_comment_42\" data-media_comment_type=\"audio\" class=\"instructure_inline_media_comment audio_comment\"><span>24</span></a></div>"
equal(output, expected)