diff --git a/lib/__tests__/index-test.js b/lib/__tests__/index-test.js index b0b7ed8..97194f5 100644 --- a/lib/__tests__/index-test.js +++ b/lib/__tests__/index-test.js @@ -8,7 +8,9 @@ var k = () => {}; var captureWarnings = (fn) => { var _warn = console.warn; var msgs = {}; - console.warn = (id, msg) => msgs[msg] = true; + console.warn = (id, msg, srcNode) => { + msgs[msg] = srcNode ? srcNode : true; + }; fn(); console.warn = _warn; return msgs; @@ -557,6 +559,45 @@ describe('labels', () => { }); }); +describe('includeSrcNode is "asString"', () => { + var createElement = React.createElement; + var fixture; + + before(() => { + a11y(React, { includeSrcNode: "asString" }); + fixture = document.createElement('div'); + fixture.id = 'fixture-1'; + document.body.appendChild(fixture); + }); + + after(() => { + React.createElement = createElement; + fixture = document.getElementById('fixture-1'); + if (fixture) + document.body.removeChild(fixture); + }); + + it('returns the outerHTML as a string in the error message', () => { + var Bar = React.createClass({ + _privateProp: 'bar', + + componentDidMount: function() { + return this._privateProp; + }, + render: () => { + return ( +
+ ); + } + }); + + var msgs = captureWarnings(() => {React.render(