|
| 1 | +/*global helpers */ |
| 2 | +describe('reporters - raw-env', function() { |
| 3 | + 'use strict'; |
| 4 | + |
| 5 | + var fixture = document.getElementById('fixture'); |
| 6 | + |
| 7 | + function createDqElement() { |
| 8 | + var node = document.createElement('div'); |
| 9 | + fixture.appendChild(node); |
| 10 | + return new axe.utils.DqElement(node); |
| 11 | + } |
| 12 | + |
| 13 | + var mockResults; |
| 14 | + var orig; |
| 15 | + var rawResults; |
| 16 | + const env = helpers.getEnvironmentData(); |
| 17 | + |
| 18 | + before(function() { |
| 19 | + mockResults = [ |
| 20 | + { |
| 21 | + id: 'gimmeLabel', |
| 22 | + helpUrl: 'things', |
| 23 | + description: 'something nifty', |
| 24 | + tags: ['tag1'], |
| 25 | + result: 'passed', |
| 26 | + violations: [], |
| 27 | + passes: [ |
| 28 | + { |
| 29 | + result: 'passed', |
| 30 | + any: [ |
| 31 | + { |
| 32 | + result: true, |
| 33 | + data: 'minkey' |
| 34 | + } |
| 35 | + ], |
| 36 | + all: [], |
| 37 | + none: [], |
| 38 | + node: createDqElement() |
| 39 | + } |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + id: 'idkStuff', |
| 44 | + description: 'something more nifty', |
| 45 | + pageLevel: true, |
| 46 | + result: 'failed', |
| 47 | + impact: 'cats', |
| 48 | + tags: ['tag2'], |
| 49 | + passes: [], |
| 50 | + violations: [ |
| 51 | + { |
| 52 | + result: 'failed', |
| 53 | + all: [ |
| 54 | + { |
| 55 | + result: false, |
| 56 | + data: 'pillock', |
| 57 | + impact: 'cats' |
| 58 | + } |
| 59 | + ], |
| 60 | + any: [], |
| 61 | + none: [], |
| 62 | + node: createDqElement(), |
| 63 | + impact: 'cats' |
| 64 | + } |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + id: 'bypass', |
| 69 | + description: 'something even more nifty', |
| 70 | + tags: ['tag3'], |
| 71 | + impact: 'monkeys', |
| 72 | + result: 'failed', |
| 73 | + passes: [], |
| 74 | + violations: [ |
| 75 | + { |
| 76 | + result: 'failed', |
| 77 | + impact: 'monkeys', |
| 78 | + none: [ |
| 79 | + { |
| 80 | + data: 'foon', |
| 81 | + impact: 'monkeys', |
| 82 | + result: true |
| 83 | + } |
| 84 | + ], |
| 85 | + any: [], |
| 86 | + all: [], |
| 87 | + node: createDqElement() |
| 88 | + } |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + id: 'blinky', |
| 93 | + description: 'something awesome', |
| 94 | + tags: ['tag4'], |
| 95 | + violations: [], |
| 96 | + result: 'passed', |
| 97 | + passes: [ |
| 98 | + { |
| 99 | + result: 'passed', |
| 100 | + none: [ |
| 101 | + { |
| 102 | + data: 'clueso', |
| 103 | + result: true |
| 104 | + } |
| 105 | + ], |
| 106 | + node: createDqElement() |
| 107 | + } |
| 108 | + ] |
| 109 | + } |
| 110 | + ]; |
| 111 | + |
| 112 | + axe.testUtils.fixtureSetup(); |
| 113 | + |
| 114 | + axe._load({}); |
| 115 | + orig = axe._runRules; |
| 116 | + axe._runRules = function(_, __, cb) { |
| 117 | + cb(mockResults, function noop() {}); |
| 118 | + }; |
| 119 | + axe.run({ reporter: 'raw' }, function(err, results) { |
| 120 | + if (err) { |
| 121 | + return {}; |
| 122 | + } |
| 123 | + rawResults = results; |
| 124 | + }); |
| 125 | + }); |
| 126 | + |
| 127 | + after(function() { |
| 128 | + axe._runRules = orig; |
| 129 | + fixture.innerHTML = ''; |
| 130 | + }); |
| 131 | + |
| 132 | + it('should pass raw results and env object', function(done) { |
| 133 | + axe.run({ reporter: 'rawEnv' }, function(err, results) { |
| 134 | + if (err) { |
| 135 | + return done(err); |
| 136 | + } |
| 137 | + assert.deepEqual(results.raw, rawResults); |
| 138 | + assert.deepEqual(results.env, env); |
| 139 | + done(); |
| 140 | + }); |
| 141 | + }); |
| 142 | +}); |
0 commit comments