Reload fixtures for tests and finish testing home

This commit is contained in:
Rowan Manning
2013-11-21 13:54:52 +00:00
parent a47fb38d7f
commit b5735b7f05
4 changed files with 42 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ module.exports = function (grunt) {
mochaTest: { mochaTest: {
functional: { functional: {
src: ['test/functional/*.js'], src: ['test/functional/**/*.js'],
options: { options: {
reporter: 'spec' reporter: 'spec'
} }

View File

@@ -1,5 +1,5 @@
/* global beforeEach, describe, it */ /* global beforeEach, describe, it */
/* jshint maxlen: 200, maxstatements: 20 */ /* jshint maxlen: false, maxstatements: false */
'use strict'; 'use strict';
var assert = require('proclaim'); var assert = require('proclaim');
@@ -26,6 +26,34 @@ describe('GET /', function () {
assert.strictEqual(elem[0].getAttribute('href'), '/new'); assert.strictEqual(elem[0].getAttribute('href'), '/new');
}); });
it('should display all of the expected tasks', function () {
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
assert.strictEqual(tasks.length, 3);
assert.match(tasks[0].textContent, /npg home\s+\(wcag2aa\)/i);
assert.match(tasks[1].textContent, /npg home\s+\(wcag2aaa\)/i);
assert.match(tasks[2].textContent, /nature news\s+\(section508\)/i);
});
it('should have links to each task', function () {
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
assert.strictEqual(tasks.length, 3);
assert.strictEqual(tasks[0].querySelectorAll('[href="/abc000000000000000000001"]').length, 1);
assert.strictEqual(tasks[1].querySelectorAll('[href="/abc000000000000000000002"]').length, 1);
assert.strictEqual(tasks[2].querySelectorAll('[href="/abc000000000000000000003"]').length, 1);
});
it('should display the task result counts if the task has been run', function () {
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
assert.match(tasks[0].textContent, /1\s*errors/i);
assert.match(tasks[0].textContent, /2\s*warnings/i);
assert.match(tasks[0].textContent, /3\s*notices/i);
});
it('should display a message indicating that there are no results if the task has not been run', function () {
var tasks = this.last.dom.querySelectorAll('[data-test=task]');
assert.match(tasks[2].textContent, /no results/i);
});
}); });
}); });

View File

@@ -1,9 +1,10 @@
/* global before */ /* global afterEach, before */
/* jshint maxlen: 200 */ /* jshint maxlen: false, maxstatements: false */
'use strict'; 'use strict';
var config = require('../../config/test.json'); var config = require('../../config/test.json');
var createNavigator = require('./helper/navigate'); var createNavigator = require('./helper/navigate');
var loadFixtures = require('pa11y-webservice/data/fixture/load');
var request = require('request'); var request = require('request');
// Run before all tests // Run before all tests
@@ -11,7 +12,14 @@ before(function (done) {
this.baseUrl = 'http://localhost:' + config.port; this.baseUrl = 'http://localhost:' + config.port;
this.last = {}; this.last = {};
this.navigate = createNavigator(this.baseUrl, this.last); this.navigate = createNavigator(this.baseUrl, this.last);
assertTestAppIsRunning(this.baseUrl, done); assertTestAppIsRunning(this.baseUrl, function () {
loadFixtures('test', config.webservice, done);
});
});
// Run after each test
afterEach(function (done) {
loadFixtures('test', config.webservice, done);
}); });
// Check that the test application is running, and exit if not // Check that the test application is running, and exit if not

View File

@@ -15,7 +15,7 @@
{{/if}} {{/if}}
</li> </li>
{{#each tasks}} {{#each tasks}}
<li class="col-md-4 col-sm-6 task-card"> <li class="col-md-4 col-sm-6 task-card" data-test="task">
<a class="well task-card-link crunch-bottom" title="Details for URL {{simplify-url url}}" href="{{href}}"> <a class="well task-card-link crunch-bottom" title="Details for URL {{simplify-url url}}" href="{{href}}">
<p class="h3">{{name}}</p> <p class="h3">{{name}}</p>
<p class="h5">({{standard}})</p> <p class="h5">({{standard}})</p>