From b5735b7f05c00d0d1a5a90829bdca197398160cc Mon Sep 17 00:00:00 2001 From: Rowan Manning Date: Thu, 21 Nov 2013 13:54:52 +0000 Subject: [PATCH] Reload fixtures for tests and finish testing home --- Gruntfile.js | 2 +- test/functional/index.js | 30 +++++++++++++++++++++++++++++- test/functional/setup.js | 14 +++++++++++--- view/partial/tasks.html | 2 +- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7404844..c2ef07a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -36,7 +36,7 @@ module.exports = function (grunt) { mochaTest: { functional: { - src: ['test/functional/*.js'], + src: ['test/functional/**/*.js'], options: { reporter: 'spec' } diff --git a/test/functional/index.js b/test/functional/index.js index 7044efd..51ece7d 100644 --- a/test/functional/index.js +++ b/test/functional/index.js @@ -1,5 +1,5 @@ /* global beforeEach, describe, it */ -/* jshint maxlen: 200, maxstatements: 20 */ +/* jshint maxlen: false, maxstatements: false */ 'use strict'; var assert = require('proclaim'); @@ -26,6 +26,34 @@ describe('GET /', function () { 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); + }); + }); }); diff --git a/test/functional/setup.js b/test/functional/setup.js index 992ffc6..a8ffabc 100644 --- a/test/functional/setup.js +++ b/test/functional/setup.js @@ -1,9 +1,10 @@ -/* global before */ -/* jshint maxlen: 200 */ +/* global afterEach, before */ +/* jshint maxlen: false, maxstatements: false */ 'use strict'; var config = require('../../config/test.json'); var createNavigator = require('./helper/navigate'); +var loadFixtures = require('pa11y-webservice/data/fixture/load'); var request = require('request'); // Run before all tests @@ -11,7 +12,14 @@ before(function (done) { this.baseUrl = 'http://localhost:' + config.port; 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 diff --git a/view/partial/tasks.html b/view/partial/tasks.html index 4daec67..0fbe148 100644 --- a/view/partial/tasks.html +++ b/view/partial/tasks.html @@ -15,7 +15,7 @@ {{/if}} {{#each tasks}} -
  • +
  • {{name}}

    ({{standard}})