Skip to content

Commit

Permalink
fix: make toHaveTextContent() work with numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
bcarroll22 committed Apr 8, 2019
1 parent 41f1b69 commit 8e11cbd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/to-have-text-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ function getText(child, currentValue = '') {

if (!child) {
return value;
} else if (typeof child === 'string') {
return `${value}${child}`;
} else {
} else if (typeof child === 'object') {
return getText(path(['props', 'children'], child), value);
} else {
return `${value}${child}`;
}
}

Expand All @@ -25,7 +25,7 @@ export function toHaveTextContent(element, checkWith) {
// step 6: join the resulting array
join(''),
// step 5: map the array to get text content
map(child => (typeof child === 'string' ? child : getText(child))),
map(child => (typeof child === 'object' ? getText(child) : child)),
// step 4: make sure non-array children end up in an array
Array.from,
// step 3: default to an array
Expand Down

0 comments on commit 8e11cbd

Please sign in to comment.