Skip to content

Commit

Permalink
Add an assertion for NaN warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and flarnie committed Sep 2, 2017
1 parent acae10d commit ce03f1e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/renderers/dom/shared/__tests__/ReactDOMAttribute-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ describe('ReactDOM unknown attribute', () => {
ReactDOM = require('react-dom');
});

function normalizeCodeLocInfo(str) {
return str && str.replace(/\(at .+?:\d+\)/g, '(at **)');
}

function testUnknownAttributeRemoval(givenValue) {
var el = document.createElement('div');
ReactDOM.render(<div unknown="something" />, el);
Expand Down Expand Up @@ -68,8 +72,11 @@ describe('ReactDOM unknown attribute', () => {
spyOn(console, 'error');

testUnknownAttributeAssignment(NaN, 'NaN');
// TODO: add specific expectations about what the warning says
// expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(...
expectDev(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Received NaN for numeric attribute `unknown`. ' +
'If this is expected, cast the value to a string.\n' +
' in div (at **)',
);
expectDev(console.error.calls.count()).toBe(1);
});

Expand Down

0 comments on commit ce03f1e

Please sign in to comment.