This repository was archived by the owner on Mar 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from Financial-Times/obtPa11y
Added pa11y test to obt, with its own test. README updated
- Loading branch information
Showing
9 changed files
with
154 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- pa11y error, no contrast--> | ||
<button style="background-color:blue; color:blue">No contrast</button> | ||
<!-- pa11y warning, not logically nested--> | ||
<h2>Not logically nested</h2> | ||
<!-- no errors --> | ||
<button>Click me</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* global describe, it, before, after */ | ||
'use strict'; | ||
|
||
const expect = require('expect.js'); | ||
const gulp = require('gulp'); | ||
|
||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
|
||
const demo = require('../../lib/tasks/demo'); | ||
const test = require('../../lib/tasks/test'); | ||
|
||
const obtPath = process.cwd(); | ||
const oTestPath = 'test/fixtures/o-test'; | ||
|
||
describe('Test task', function() { | ||
describe('Pa11y', function() { | ||
const pathSuffix = '-test-pa11y'; | ||
const testTestPath = path.resolve(obtPath, oTestPath + pathSuffix); | ||
|
||
before(function(done) { | ||
fs.copySync(path.resolve(obtPath, oTestPath), testTestPath); | ||
process.chdir(testTestPath); | ||
const demoStream = demo(gulp, { | ||
demoConfig: 'origami.json', | ||
demoFilter: ['pa11y'] | ||
}); | ||
demoStream.on('end', done); | ||
demoStream.resume(); | ||
}); | ||
|
||
after(function() { | ||
process.chdir(obtPath); | ||
fs.removeSync(testTestPath); | ||
}); | ||
|
||
it('should not fail when the file is not found', function() { | ||
// run pa11y subtask | ||
return test.pa11yTest(gulp, { | ||
// set an invalid path | ||
pa11yPath: './file.html' | ||
}) | ||
.then(function(results) { | ||
expect(results).to.be(undefined); | ||
}); | ||
}); | ||
|
||
it('should run pa11y correctly', function(done) { | ||
// run pa11y subtask | ||
const res = test.pa11yTest(); | ||
res | ||
.then(function(results) { | ||
expect(results[0].type).to.be('error'); | ||
done(); | ||
}) | ||
.catch(function errorHandler() { | ||
// it should throw an error, not resolve | ||
expect(true).to.be(false); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should run pa11y with custom ignore options', function(done) { | ||
// run pa11y subtask | ||
const res = test.pa11yTest(gulp, { | ||
// set custom ignore options | ||
pa11yIgnore: 'error;notice' | ||
}); | ||
res | ||
.then(function(results) { | ||
expect(results[0].type).to.be('warning'); | ||
done(); | ||
}) | ||
.catch(function errorHandler() { | ||
// it should throw an error, not resolve | ||
expect(true).to.be(false); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |