forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassertions.coffee
More file actions
39 lines (28 loc) · 1.18 KB
/
Copy pathassertions.coffee
File metadata and controls
39 lines (28 loc) · 1.18 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
define ['jquery', 'underscore', 'axe-core'], ($, _, axe) ->
isVisible: ($el, message = '') ->
ok $el.length, "elements found"
ok $el.is(':visible'), "#{$el} is visible " + message
isHidden: ($el, message) ->
ok $el.length, "elements found"
ok !$el.is(':visible'), "#{$el} is hidden " + message
hasClass: ($el, className, message) ->
ok $el.length, "elements found"
ok $el.hasClass(className), "#{$el} has class #{className} " + message
isAccessible: ($el, done, options) ->
options = options || {}
el = $el[0]
axeConfig = runOnly:
type: "tag"
values: [ "wcag2a", "wcag2aa", "section508", "best-practice" ]
axe.a11yCheck el, axeConfig, (result) ->
ignores = options.ignores || []
violations = _.reject(result.violations, (violation) ->
ignores.indexOf(violation.id) >= 0
)
err = violations.map((violation) ->
[ "[" + violation.id + "] " + violation.help, violation.helpUrl + "\n" ].join "\n"
)
ok(violations.length is 0, err)
done()
contains: (string, substring) ->
QUnit.assert.push string.indexOf(substring) > -1, string, substring, "expected string not found in actual"