forked from dequelabs/axe-webdriverjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc-lang.js
81 lines (73 loc) · 2.05 KB
/
doc-lang.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var runWebdriver = require('../run-webdriver');
var assert = require('chai').assert;
var host = 'localhost';
var AxeBuilder = require('../../lib');
var path = require('path');
var { createServer } = require('http-server');
if (process.env.REMOTE_TESTSERVER_HOST) {
host = process.env.REMOTE_TESTSERVER_HOST;
}
describe('doc-lang.html', function() {
this.timeout(10000);
var driver;
var server;
before(function(done) {
driver = runWebdriver();
server = createServer({
root: path.resolve(__dirname, '../..'),
cache: -1
});
server.listen(9876, err => {
if (err) {
return done(err);
}
driver
.get('http://' + host + ':9876/test/fixtures/doc-lang.html')
.then(function() {
done();
});
});
});
after(function(done) {
server.close();
driver.quit().then(function() {
done();
});
});
it('should find violations', function(done) {
AxeBuilder(driver)
.withRules('html-has-lang')
.analyze()
.then(function(results) {
assert.lengthOf(results.violations, 1);
assert.equal(results.violations[0].id, 'html-has-lang');
assert.lengthOf(results.passes, 0);
done();
});
});
it('should not find violations when given context (document level rule)', function(done) {
AxeBuilder(driver)
.include('body')
.withRules('html-has-lang')
.analyze()
.then(function(results) {
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.passes, 0);
done();
});
});
it('should not find violations when the rule is disabled', function(done) {
AxeBuilder(driver)
.options({ rules: { 'html-has-lang': { enabled: false } } })
.analyze()
.then(function(results) {
results.violations.forEach(function(violation) {
assert.notEqual(violation.id, 'html-has-lang');
});
results.passes.forEach(function(violation) {
assert.notEqual(violation.id, 'html-has-lang');
});
done();
});
});
});